Model training method and device, electronic equipment and storage medium
By adding adaptation layers to the coding layer of the model and adjusting parameters, the problem of long model iteration maintenance cycle and impact on the accuracy of inference of existing tasks is solved, and more efficient model training and inference are achieved.
Patent Information
- Application Number
- CN202411884765.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
AI Technical Summary
When the model is implemented with new functions, the existing technology requires the model to be built separately or regress all tasks, resulting in a long iteration maintenance cycle and an impact on the accuracy of the inference of existing tasks.
By adding an adaptation layer to the coding layer of the original model and adjusting the adaptation layer parameters based on the training data set, keeping the encoding layer parameters unchanged, transfer learning and reasoning for new tasks are realized.
It reduces the iterative maintenance cycle of the model, reduces the impact on the accuracy of inference of existing tasks, and does not increase the number of parameters during inference, improving efficiency.
Smart Images

Figure CN119830007A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, in particular to the field of artificial intelligence technology, and specifically to a model training method and device, an electronic device, and a storage medium. Background Art
[0002] With the development of science and technology, the accuracy of algorithm reasoning has become the focus of users' attention. As business needs increase, the functions covered by the model also need to increase. When the model implements new functions, a separate model can be built according to the new functions, using single-point iteration, but the required data volume is large and the iteration maintenance cycle is long. In addition, new functions can be added based on the original public features, but all tasks need to be regressed, and the new iteration will cause the indicators of the original functions to drop. Summary of the invention
[0003] The present disclosure provides a model training method and device, an electronic device and a storage medium, the main purpose of which is to reduce the iterative maintenance cycle of the model while reducing the impact on the accuracy of existing task reasoning.
[0004] According to one aspect of the present disclosure, a model training method is provided, comprising:
[0005] Obtain a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task;
[0006] When receiving requirement information for using the first model to infer the newly added task, adding an adaptation layer to each coding layer in the at least one coding layer, initializing parameters of the adaptation layer, and obtaining a second model;
[0007] Keeping parameters of at least one coding layer in the second model unchanged, using the training data set to train parameters of the adaptation layer corresponding to each coding layer, and obtaining adaptation layer parameters of the adaptation layer corresponding to each coding layer;
[0008] When the training output result of the second model meets the model storage requirement, the third model is obtained and stored.
[0009] According to another aspect of the present disclosure, a model training device is provided, comprising:
[0010] A set acquisition unit, configured to acquire a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task;
[0011] a model acquisition unit, configured to, upon receiving requirement information for using the first model to infer a newly added task, add an adaptation layer to each coding layer in the at least one coding layer, initialize parameters of the adaptation layer, and acquire a second model;
[0012] A model training unit, used to keep parameters of at least one coding layer in the second model unchanged, train parameters of the adaptation layer corresponding to each coding layer using the training data set, and obtain adaptation layer parameters of the adaptation layer corresponding to each coding layer;
[0013] The model acquisition unit is also used to acquire and store a third model when the training output result of the second model meets the model storage requirements.
[0014] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any one of the methods described in the above aspect.
[0018] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods described in the above aspect.
[0019] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the methods described in the above aspect.
[0020] In one or more embodiments of the present disclosure, a training data set and a first model are obtained, wherein the first model includes at least one coding layer, and the first model is used to perform at least one existing task; when receiving the demand information for using the first model to reason about the newly added task, an adaptation layer is added to each coding layer in the at least one coding layer, and the parameters of the adaptation layer are initialized to obtain a second model; the parameters of at least one coding layer in the second model are kept unchanged, and the parameters of the adaptation layer corresponding to each coding layer are trained using the training data set to obtain the adaptation layer parameters of the adaptation layer corresponding to each coding layer; when the training output result of the second model meets the model storage requirements, a third model is obtained and stored. Therefore, each coding layer corresponds to an adaptation layer, and the parameters of the adaptation layer can be trained by the training data set corresponding to the adaptation layer. Since the data volume of the training data set is much smaller than the training data volume required for the complete model, the transfer learning of the newly added task can be completed by using fewer training resources, and the reasoning of the newly added task can be realized. In the reasoning, the parameter volume is not increased, which can reduce the impact on the reasoning speed, and there is no need to regress all the tasks of the model, which can reduce the impact on the original indicators of the model, and can reduce the iterative maintenance cycle of the model while reducing the impact on the reasoning accuracy of the existing tasks.
[0021] 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
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0023] Figure 1 is a flowchart of a model training method according to the first embodiment of the present disclosure;
[0024] Figure 2 is a flowchart of a model training method according to the second embodiment of the present disclosure;
[0025] FIG3( a ) is a schematic diagram of an example of classification task migration according to an embodiment of the present disclosure;
[0026] FIG3( b ) is a schematic diagram showing an example of a structural diagram of a TA-Block according to an embodiment of the present disclosure;
[0027] FIG3( c ) is a schematic diagram showing an example of a structural diagram of a TA-Block according to another embodiment of the present disclosure;
[0028] Figure 4 is an exemplary schematic diagram of a model test according to an embodiment of the present disclosure;
[0029] FIG5( a ) is a schematic diagram of the structure of a model training device for implementing the model training method of an embodiment of the present disclosure;
[0030] FIG5( b ) is a second structural schematic diagram of a model training device for implementing the model training method of an embodiment of the present disclosure;
[0031] FIG5( c ) is a third structural schematic diagram of a model training device for implementing the model training method of an embodiment of the present disclosure;
[0032] Figure 6 It is a block diagram of an electronic device used to implement the model training method of an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] 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.
[0034] The present disclosure is described in detail below with reference to specific embodiments.
[0035] In the first embodiment, if Figure 1 As shown, Figure 1 This is a flow chart of a model training method according to the first embodiment of the present disclosure, which can be implemented by a computer program and can be run on a device for model training. The computer program can be integrated into an application or run as an independent tool application.
[0036] The model training device may be an electronic device with artificial intelligence interaction capability, including but not limited to: an autonomous vehicle, a wearable device, a handheld device, a personal computer, a tablet computer, a vehicle-mounted device, a smart phone, a computing device or other processing device connected to a wireless modem, etc. In different networks, the terminal may be called by different names, such as: user equipment, access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), fifth generation mobile communication technology (5G) network, fourth generation mobile communication technology (4G) network, third generation mobile communication technology (3G) network or electronic device in future evolution network, etc.
[0037] Specifically, the model training method includes:
[0038] S101, obtaining a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task;
[0039] According to some embodiments, the training data set may be used to indicate a data set for training the adaptation layer corresponding to each coding layer in the first model. The training data set may include, for example, at least one data, and the amount of data corresponding to the training data set is less than the amount of data of the training data corresponding to the first model. The training data set does not specifically refer to a fixed data set. For example, when a new task changes, the training data set may also change accordingly. For example, when the amount of data included in the training data set changes, the training data set may also change accordingly. For example, when a certain training data in the training data set changes, the training data set may also change accordingly.
[0040] In some embodiments, the first model refers to a model that has been trained and can perform reasoning on reasoning tasks corresponding to the training phase. The first model may, for example, include at least one coding layer. The "first" in the first model is used to distinguish it from the remaining models, and the first model does not specifically refer to a fixed model. For example, when the number of coding layers corresponding to the first model changes, the first model may also change accordingly. For example, when the model parameters corresponding to the first model change, the first model may also change accordingly.
[0041] In some embodiments, an existing task refers to a task that the first model has been trained and can be inferred. That is, the first model can be used to infer the existing task. The existing task does not specifically refer to a fixed task. For example, when the first model changes, the existing task corresponding to the first model can also change accordingly.
[0042] According to some embodiments, a training data set and a first model may be obtained, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task.
[0043] According to some embodiments, the execution order of "obtaining a training data set" is not limited, and it can be performed before "using the training data set to train the parameters of the adaptation layer corresponding to each coding layer to obtain the adaptation layer parameters of each coding layer corresponding to the adaptation layer" in step S103.
[0044] S102, when receiving requirement information for using the first model to infer a newly added task, adding an adaptation layer to each coding layer in at least one coding layer, and initializing parameters of the adaptation layer to obtain a second model;
[0045] In some embodiments, the newly added task may be different from the existing task, that is, the newly added task may be a task that the first model cannot reason before adding the adaptation layer. The newly added task does not specifically refer to a fixed task. For example, when the first model changes and the existing tasks that the first model can reason about change, the newly added task may also change accordingly.
[0046] In some embodiments, the requirement information may be used, for example, to indicate that the first model is required to be able to perform reasoning on the newly added task. The requirement information corresponds to the newly added task. The requirement information does not specifically refer to a fixed information. For example, when the accuracy of the reasoning result included in the requirement information or the newly added task to be reasoned changes, the requirement information may also change accordingly.
[0047] According to some embodiments, the adaptation layer of the disclosed embodiment is used to fine-tune at least one original encoder according to the newly added task, that is, to fine-tune the first model.
[0048] In some embodiments, the second model may be, for example, a model obtained by adding an adaptation layer to each coding layer in the first model and initializing the parameters of the adaptation layer. In other words, the second model is an initial model for reasoning about the newly added task. The "second" in the second model is used to distinguish it from the other models.
[0049] S103, keeping parameters of at least one coding layer in the second model unchanged, using the training data set to train parameters of the adaptation layer corresponding to each coding layer, and obtaining adaptation layer parameters of the adaptation layer corresponding to each coding layer;
[0050] According to some embodiments, the adaptation layer parameters may be, for example, parameters corresponding to each adaptation layer, wherein different newly added tasks may correspond to different adaptation layer parameters.
[0051] In some embodiments, the parameters of at least one coding layer in the second model may be kept unchanged, and the parameters of the adaptation layer corresponding to each coding layer may be trained using a training data set to obtain the adaptation layer parameters of the adaptation layer corresponding to each coding layer.
[0052] S104: When the training output result of the second model meets the model storage requirement, obtain and store the third model.
[0053] According to some embodiments, the third model may be, for example, a model that has been trained and can perform reasoning on a newly added task. The "third" in the third model is used to distinguish it from the remaining models.
[0054] In some embodiments, the model storage requirement may be, for example, that the difference between the training output result and the preset result is less than a difference threshold.
[0055] In some embodiments, for example, the third model can be acquired and stored when the training output result of the second model meets the model storage requirements.
[0056] In one or more embodiments of the present disclosure, a training data set and a first model are obtained, wherein the first model includes at least one coding layer, and the first model is used to perform at least one existing task; when receiving the demand information for using the first model to reason about the newly added task, an adaptation layer is added to each coding layer in at least one coding layer, and the parameters of the adaptation layer are initialized to obtain a second model; the parameters of at least one coding layer in the second model are kept unchanged, and the parameters of the adaptation layer corresponding to each coding layer are trained using the training data set to obtain the adaptation layer parameters corresponding to the adaptation layer of each coding layer; when the training output result of the second model meets the model storage requirements, a third model is obtained and stored. Therefore, each coding layer corresponds to an adaptation layer, and the parameters of the adaptation layer can be trained by the training data set corresponding to the adaptation layer. Since the data volume of the training data set is much smaller than the training data volume required for the complete model, the transfer learning of the newly added task can be completed by using fewer training resources, and the reasoning of the newly added task can be realized. In the reasoning, the parameter volume is not increased, which can reduce the impact on the reasoning speed, and there is no need to regress all the tasks of the model, which can reduce the impact on the original indicators of the model, and can reduce the iterative maintenance cycle of the model while reducing the impact on the reasoning accuracy of the existing tasks.
[0057] See also Figure 2 , Figure 2is a flow chart of a model training method according to the second embodiment of the present disclosure. Specifically,
[0058] S201, obtaining a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task;
[0059] The relevant process has been described above and will not be repeated here.
[0060] In some embodiments, the embodiments of the present disclosure can be applied to the construction of smart cities, and specifically can involve vehicle-road cooperative perception services. The models involved can include, for example, gun 2D detection, gun 3D detection, fisheye detection, vehicle structuring, pedestrian structuring, non-motor vehicle structuring, DMS and other models. Various structurings themselves include detection and recognition functions of multiple attributes, that is, multiple detection and recognition tasks.
[0061] According to some embodiments, the technical solution of the embodiments of the present disclosure can be used, for example, to maintain the original model capabilities while quickly iterating the functions of new requirements, and can realize reasoning for more tasks.
[0062] According to some embodiments, the third model of the embodiment of the present disclosure may be, for example, an image classification model for classifying an image set. An example schematic diagram of classification task migration may be, for example, as shown in FIG3(a), wherein the first model includes a feature characterizer, and the feature characterizer is composed of a TA-Block. The structure diagram of the TA-Block may be, for example, as shown in FIG3(a). Figure 3(b) and 3(c) As shown. It includes the original representation encoding and the added adaptation layer. FFN is a feedforward network, stage represents the stage, Task-Adapter is the adapter, that is, the adaptation layer of the embodiment of the present disclosure, Norm represents normalization, and Multi-Head Attention is multi-head attention.
[0063] The role of the adapter is to fine-tune the original feature characterizer according to the new task data. The adaptation layer parameters of different tasks are different. The feature characterizer can be, for example, an already developed one, or it can be the best feature characterizer that can be obtained, and the embodiments of the present disclosure are not limited to this.
[0064] S202, when receiving requirement information for using the first model to infer a newly added task, adding an adaptation layer to each coding layer in at least one coding layer, and initializing parameters of the adaptation layer to obtain a second model;
[0065] The relevant process has been described above and will not be repeated here.
[0066] According to some embodiments, as shown in FIG. 3( b ), the existing weights are loaded into the original coding layer, and the parameters of the adaptation layer are initialized.
[0067] S203, keeping parameters of at least one coding layer in the second model unchanged, using the training data set to train parameters of the adaptation layer corresponding to each coding layer, and obtaining adaptation layer parameters of the adaptation layer corresponding to each coding layer;
[0068] The relevant process has been described above and will not be repeated here.
[0069] S204, when the training output result of the second model meets the model storage requirement, obtain and store the third model;
[0070] The relevant process has been described above and will not be repeated here.
[0071] According to some embodiments, as shown in FIG. 3(b) and FIG. 3(c), the existing weights are loaded in the original coding layer, and the parameters of the adaptation layer are initialized. The training data set is input into the second model, and forward propagation is performed to obtain the training output result output by the second model, which can be, for example, an image classification result. The error between the image classification result and the pre-label label is obtained, and based on the error, the existing weights loaded in the original coding layer are kept unchanged, and the parameters of the adaptation layer are updated until the error between the image classification result output by the second model and the pre-label is less than the error threshold, and it is determined that the third model is obtained.
[0072] During model inference, the adaptation layer parameters can be merged into the original model framework without increasing the model inference time. The specific schematic diagram of the model test at this time is as follows: Figure 4 shown.
[0073] S205, using the third model to reason the data to be reasoned, and obtaining reasoning results corresponding to the data to be reasoned;
[0074] In some embodiments, when the third model is obtained, the third model can be used to infer the data to be inferred to obtain the inference result corresponding to the data to be inferred.
[0075] According to some embodiments, further comprising:
[0076] Acquire first data to be inferred;
[0077] In the case where the reasoning requirement corresponding to the first data to be inferred is to reason about a new task, at least one encoding layer and an adaptation layer parameter corresponding to the new task are used to reason about the first data to be inferred, and the reasoning result corresponding to the new task is obtained. Therefore, the data to be inferred can be reasoned, and the reasoning of the new task can be realized. The amount of data required for training the third model is small, and there is no need to increase the amount of parameters during reasoning. On the basis of reusing the existing model, the ability of the original model can be migrated without destroying the new task, thereby improving the convenience of reasoning for the new task.
[0078] According to some embodiments, the first data to be inferred may be, for example, data required for inferring a newly added task. The "first" in the first data to be inferred is used to distinguish it from the remaining data to be inferred, and the first data to be inferred does not specifically refer to a fixed data. For example, when the specific data included in the first data to be inferred changes or the amount of data changes, the first data to be inferred may also change accordingly.
[0079] According to some embodiments, further comprising:
[0080] Acquire the second data to be inferred;
[0081] When the reasoning requirement corresponding to the second data to be inferred is to reason about at least one newly added task, obtaining an adaptation layer parameter set in the third model, wherein the adaptation layer parameter set includes adaptation layer parameters corresponding to multiple newly added tasks;
[0082] Determine an adaptation layer parameter set and an adaptation layer parameter subset corresponding to each newly added task;
[0083] At least one encoding layer and a subset of adaptation layer parameters corresponding to each newly added task are used to infer the second data to be inferred, and at least one inference result is obtained. Therefore, the data to be inferred can be inferred, and the corresponding adaptation layer parameters can be used for inference, and the inference of multiple newly added tasks can be realized. The amount of data required for training the third model is small, and there is no need to increase the amount of parameters during inference. On the basis of reusing the existing model, the ability of the original model can be not destroyed when migrating the newly added tasks, thereby improving the convenience of inference of the newly added tasks.
[0084] According to some embodiments, for example, the first model may have a general ability, and the ability of the reasoning model may be controlled by hyperparameters, that is, the adaptation layer parameters of different newly added tasks may be trained independently, and the reasoning of newly added tasks may be achieved by hyperparameters. For example, when the model has the original reasoning ability, adding the adaptation layer parameters of the newly added task one to the model may enable the updated model to have the ability to reason about the newly added task one; when the model has the original reasoning ability, adding the adaptation layer parameters of the newly added task two to the model may enable the updated model to have the ability to reason about the newly added task two; when the model has the original reasoning ability, adding the adaptation layer parameters of the newly added task one and adding the adaptation layer parameters of the newly added task two to the model respectively may enable the updated model to have the ability to reason about the newly added task one and the ability to reason about the newly added task two. Among them, when there are multiple new task capabilities, the specific reasoning task can be determined according to the data to be reasoned.
[0085] According to some embodiments, further comprising:
[0086] Obtaining third data to be inferred;
[0087] When the reasoning requirement corresponding to the third data to be reasoned is to reason about an existing task, the adaptation layer parameters are deleted;
[0088] At least one coding layer is used to infer the third data to be inferred, and an inference result corresponding to the existing task is obtained. Therefore, when inferring the existing task, the adaptation layer parameters corresponding to the newly added task can be deleted, and the ability of the original model can be not destroyed when migrating the newly added task on the basis of reusing the existing model, thereby improving the convenience of reasoning for the newly added task and the existing task.
[0089] According to some embodiments, the third data to be inferred may be, for example, data for inferring an existing task.
[0090] S206, when the inference result corresponding to the data to be inferred meets the result update condition, the historical inference result corresponding to the data to be inferred is deleted, and the inference result corresponding to the data to be inferred is stored.
[0091] According to some embodiments, a third model is used to reason about the data to be reasoned, and an inference result corresponding to the data to be reasoned is obtained; when the inference result corresponding to the data to be reasoned satisfies a result update condition, the historical inference result corresponding to the data to be reasoned is deleted, and the inference result corresponding to the data to be reasoned is stored. Therefore, on the basis of adding an adaptation layer to each coding layer, a model that can realize the reasoning of new tasks can be obtained. The model can be used to reason about new tasks, thereby reducing the iterative maintenance cycle of the model and the impact on existing tasks, and improving the reasoning accuracy and efficiency of new tasks.
[0092] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0093] Please refer to Figure 5(a), which shows a first structural schematic diagram of a model training device for implementing the model training method of the embodiment of the present disclosure. The model training device can be implemented as all or part of the device through software, hardware, or a combination of both. The model training device 500 includes a set acquisition unit 501, a model acquisition unit 502, and a model training unit 503, wherein:
[0094] A set acquisition unit 501 is used to acquire a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task;
[0095] The model acquisition unit 502 is used to add an adaptation layer to each coding layer in at least one coding layer and initialize the parameters of the adaptation layer to obtain a second model when receiving the requirement information of using the first model to reason about the newly added task;
[0096] The model training unit 503 is used to keep the parameters of at least one coding layer in the second model unchanged, train the parameters of the adaptation layer corresponding to each coding layer using the training data set, and obtain the adaptation layer parameters of the adaptation layer corresponding to each coding layer;
[0097] The model acquisition unit 502 is further used to acquire and store the third model when the training output result of the second model meets the model storage requirement.
[0098] According to some embodiments, wherein the adaptation layers corresponding to the respective coding layers in at least one coding layer are connected in parallel with the respective coding layers;
[0099] or,
[0100] The adaptation layers corresponding to the coding layers in the at least one coding layer are connected in series with the coding layers.
[0101] According to some embodiments, FIG. 5( b) is a second structural diagram of a model training device for implementing the model training method of the embodiment of the present disclosure, wherein the model training device 500 further includes a model reasoning unit 504 for:
[0102] Acquire first data to be inferred;
[0103] When the reasoning requirement corresponding to the first data to be inferred is to reason about a newly added task, at least one coding layer and an adaptation layer parameter corresponding to the newly added task are used to reason about the first data to be inferred to obtain a reasoning result corresponding to the newly added task.
[0104] According to some embodiments, a model inference unit 504 is further included, which is used to:
[0105] Acquire the second data to be inferred;
[0106] When the reasoning requirement corresponding to the second data to be inferred is to reason about at least one newly added task, obtaining an adaptation layer parameter set in the third model, wherein the adaptation layer parameter set includes adaptation layer parameters corresponding to multiple newly added tasks;
[0107] Determine an adaptation layer parameter set and an adaptation layer parameter subset corresponding to each newly added task;
[0108] At least one coding layer and a subset of adaptation layer parameters corresponding to each newly added task are used to infer the second data to be inferred, and at least one inference result is obtained.
[0109] According to some embodiments, a model inference unit 504 is further included, which is used to:
[0110] Obtaining third data to be inferred;
[0111] When the reasoning requirement corresponding to the third data to be reasoned is to reason about an existing task, the adaptation layer parameters are deleted;
[0112] At least one encoding layer is used to reason about the third data to be reasoned, and a reasoning result corresponding to the existing task is obtained.
[0113] According to some embodiments, according to some embodiments, FIG. 5( c ) is a third structural schematic diagram of a model training device for implementing the model training method of the embodiment of the present disclosure, and the model training device 500 further includes a model updating unit 505 for:
[0114] The third model is used to infer the data to be inferred, and an inference result corresponding to the data to be inferred is obtained;
[0115] When the inference result corresponding to the data to be inferred meets the result update condition, the historical inference result corresponding to the data to be inferred is deleted, and the inference result corresponding to the data to be inferred is stored.
[0116] It should be noted that the model training device provided in the above embodiment only uses the division of the above functional modules as an example when executing the model training method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the model training device provided in the above embodiment belongs to the same concept as the model training method embodiment. The implementation process is detailed in the method embodiment and will not be repeated here.
[0117] The serial numbers of the above-mentioned embodiments of the present disclosure are only for description and do not represent the advantages or disadvantages of the embodiments.
[0118] In summary, the device provided by the embodiment of the present disclosure includes a set acquisition unit for acquiring a training data set and a first model, wherein the first model includes at least one coding layer, and the first model is used to execute at least one existing task; a model acquisition unit for adding an adaptation layer to each coding layer in at least one coding layer and initializing the parameters of the adaptation layer to obtain a second model when receiving requirement information for inferring a newly added task using the first model; a model training unit for keeping the parameters of at least one coding layer in the second model unchanged, training the parameters of the adaptation layer corresponding to each coding layer using the training data set, and obtaining the adaptation layer parameters of the adaptation layer corresponding to each coding layer; the model acquisition unit is also used to acquire and store a third model when the training output result of the second model meets the model storage requirements. Therefore, each encoding layer corresponds to an adaptation layer, and the parameters of the adaptation layer can be trained through the training data set corresponding to the adaptation layer. Since the data amount of the training data set is much smaller than the training data amount required for the complete model, the transfer learning of the new task can be completed with fewer training resources, and the reasoning of the new task can be realized. Without increasing the number of parameters during reasoning, the impact on the reasoning speed can be reduced. There is no need to regress all the tasks of the model, which can reduce the impact on the original indicators of the model, reduce the iterative maintenance cycle of the model, and reduce the impact on the reasoning accuracy of existing tasks.
[0119] In the technical solution disclosed herein, the acquisition, storage and application 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.
[0120] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0121] 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 components, their connections and relationships, and their functions shown herein are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0122] like Figure 6As shown, the electronic device 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 electronic device 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.
[0123] Multiple components in the electronic device 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 electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0124] 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 a model training method. For example, in some embodiments, the model training method 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 an electronic device via ROM 602 and / or a 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 model training method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the model training method in any other appropriate manner (e.g., by means of firmware).
[0125] 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.
[0126] 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 provided 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, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or electronic device.
[0127] 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.
[0128] To provide interaction with a user, the systems and techniques described herein can 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; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0129] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data electronic device), or a computing system that includes middleware components (e.g., an application electronic device), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend 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), the Internet, and a blockchain network.
[0130] A computer system may include a client and an electronic device. The client and the electronic device are generally remote from each other and usually interact through a communication network. The relationship between the client and the electronic device is generated by computer programs running on the corresponding computers and having a client-electronic device relationship with each other. The electronic device may be a cloud electronic device, also known as a cloud computing electronic device or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The electronic device may also be an electronic device of a distributed system, or an electronic device combined with a blockchain.
[0131] 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.
[0132] 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 model training method, comprising: Obtain a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task; When receiving requirement information for using the first model to infer the newly added task, adding an adaptation layer to each coding layer in the at least one coding layer, initializing parameters of the adaptation layer, and obtaining a second model; Keeping parameters of at least one coding layer in the second model unchanged, using the training data set to train parameters of the adaptation layer corresponding to each coding layer, and obtaining adaptation layer parameters of the adaptation layer corresponding to each coding layer; When the training output result of the second model meets the model storage requirement, the third model is obtained and stored.
2. The method according to claim 1, wherein: The adaptation layer corresponding to each coding layer in the at least one coding layer is connected in parallel with the coding layers; or, The adaptation layer corresponding to each coding layer in the at least one coding layer is connected in series with the coding layers.
3. The method according to claim 1, further comprising: Acquire first data to be inferred; When the reasoning requirement corresponding to the first data to be inferred is to reason about the newly added task, the first data to be inferred is reasoned using the at least one coding layer and the adaptation layer parameters corresponding to the newly added task to obtain the reasoning result corresponding to the newly added task.
4. The method according to claim 1, further comprising: Acquire the second data to be inferred; When the reasoning requirement corresponding to the second data to be inferred is to reason about at least one newly added task, obtaining an adaptation layer parameter set in the third model, wherein the adaptation layer parameter set includes adaptation layer parameters corresponding to a plurality of newly added tasks; Determine the adaptation layer parameter set and the adaptation layer parameter subset corresponding to each newly added task; The second data to be inferred is inferred using the at least one coding layer and the adaptation layer parameter subset corresponding to each newly added task to obtain at least one inference result.
5. The method according to claim 1, further comprising: Obtaining third data to be inferred; When the reasoning requirement corresponding to the third data to be inferred is to reason about the existing task, deleting the adaptation layer parameters; The at least one coding layer is used to reason about the third data to be reasoned, so as to obtain a reasoning result corresponding to the existing task.
6. The method according to claim 1, further comprising: Using the third model to infer the data to be inferred, and obtaining an inference result corresponding to the data to be inferred; When the inference result corresponding to the data to be inferred meets the result update condition, the historical inference result corresponding to the data to be inferred is deleted, and the inference result corresponding to the data to be inferred is stored.
7. The method according to claim 1, wherein: The first model includes a feature characterizer, and the feature characterizer is composed of TA-Blocks.
8. A model training device, comprising: A set acquisition unit, configured to acquire a training data set and a first model, wherein the first model includes at least one encoding layer, and the first model is used to perform at least one existing task; a model acquisition unit, configured to, upon receiving requirement information for using the first model to infer a newly added task, add an adaptation layer to each coding layer in the at least one coding layer, initialize parameters of the adaptation layer, and acquire a second model; A model training unit, used to keep parameters of at least one coding layer in the second model unchanged, train parameters of the adaptation layer corresponding to each coding layer using the training data set, and obtain adaptation layer parameters of the adaptation layer corresponding to each coding layer; The model acquisition unit is also used to acquire and store a third model when the training output result of the second model meets the model storage requirements.
9. The device according to claim 8, wherein: The adaptation layer corresponding to each coding layer in the at least one coding layer is connected in parallel with the coding layers; or, The adaptation layer corresponding to each coding layer in the at least one coding layer is connected in series with the coding layers.
10. The apparatus according to claim 8, further comprising a model reasoning unit, configured to: Acquire first data to be inferred; When the reasoning requirement corresponding to the first data to be inferred is to reason about the newly added task, the first data to be inferred is reasoned using the at least one coding layer and the adaptation layer parameters corresponding to the newly added task to obtain the reasoning result corresponding to the newly added task.
11. The apparatus according to claim 8, further comprising a model inference unit, configured to: Acquire the second data to be inferred; When the reasoning requirement corresponding to the second data to be inferred is to reason about at least one newly added task, an adaptation layer parameter set in the third model is obtained, wherein: The adaptation layer parameter set includes adaptation layer parameters corresponding to a plurality of newly added tasks; Determine the adaptation layer parameter set and the adaptation layer parameter subset corresponding to each newly added task; The second data to be inferred is inferred using the at least one coding layer and the adaptation layer parameter subset corresponding to each newly added task to obtain at least one inference result.
12. The apparatus according to claim 8, further comprising a model inference unit, configured to: Obtaining third data to be inferred; When the reasoning requirement corresponding to the third data to be inferred is to reason about the existing task, deleting the adaptation layer parameters; The at least one coding layer is used to reason about the third data to be reasoned, so as to obtain a reasoning result corresponding to the existing task.
13. The apparatus according to claim 8, further comprising a model updating unit, configured to: Using the third model to infer the data to be inferred, and obtaining an inference result corresponding to the data to be inferred; When the inference result corresponding to the data to be inferred meets the result update condition, the historical inference result corresponding to the data to be inferred is deleted, and the inference result corresponding to the data to be inferred is stored.
14. The device according to claim 8, wherein: The first model includes a feature characterizer, and the feature characterizer is composed of TA-Blocks.
15. An electronic device, comprising: at least one processor; as well as A memory communicatively connected to the at least one processor; characterized in that The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.
17. 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 7.