A model training method, device and equipment

By generating sparse parameters Z of the sparse matrix in multi-task learning, fusing features and calculating loss values, the problem of insufficient feature utilization in existing methods is solved, and the training performance and adaptability of multi-task models are improved.

CN115496162BActive Publication Date: 2026-02-06ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211259139.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-14
Publication Date
2026-02-06
Estimated Expiration
2042-10-14

AI Technical Summary

Technical Problem

Existing multi-task learning methods fail to fully utilize the features in deep neural networks, resulting in insufficient model training performance.

Method used

By generating sparse parameters Z in the sparse matrix, sparse features are generated based on the sparse matrix and the output feature matrix. The initial prediction features and sparse features are fused to generate target prediction features. The loss value is calculated and the sparse parameters Z are trained to improve the performance of the multi-task model.

Benefits of technology

This approach enables the introduction of features from arbitrary layers for each task in a multi-task model, improving the model's training performance. Furthermore, this framework is highly adaptable and can be incorporated into any multi-task model to enhance performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115496162B_ABST
    Figure CN115496162B_ABST
Patent Text Reader

Abstract

This specification discloses a training method, apparatus, and device for a model. This is achieved by obtaining the output features x of the j-th layer for the training samples. j Generate a feature matrix consisting of M output features, 1 ≤ j ≤ M; for the i-th task, generate a sparse feature v corresponding to the task based on the i-th row of the sparse matrix and the output feature matrix. i The sparse matrix contains K*M trainable sparse parameters Z; the initial prediction features of the multi-task model for the i-th task are obtained, and the initial prediction features and the sparse features v are fused. i Generate target prediction features y for the i-th task i Based on the target prediction feature y i The difference between the labels of the training samples and the actual labels determines the loss value L for the i-th task. i The total loss value is generated by fusing the loss values ​​of the K tasks, and the sparse parameter Z is trained based on the total loss value.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present specification relates to the technical field of Internet, and particularly relates to a model training method and device and equipment. BACKGROUND

[0002] Multi-task learning (MTL) has been developing rapidly recently. A typical method of MTL with deep neural networks is to use deep neural networks (DNNs) containing multiple layers to establish a feature sharing mechanism that can share all tasks, or to assign a separate parameter set with cross-connections to each task. However, these existing methods only utilize the specific order of features between layers in DNNs, and the use of features is not sufficient, which reduces the training performance of the model.

[0003] Therefore, there is a need for a model training scheme with higher performance in a multi-task model. SUMMARY

[0004] Embodiments of the present specification provide a model training method, device, equipment and storage medium, to solve the technical problem of needing a model training scheme with higher performance in a multi-task model.

[0005] To solve the above technical problem, one or more embodiments of the present specification are implemented as follows:

[0006] In a first aspect, the embodiments of the present specification provide a model training method applied to a multi-task model containing M layers and K tasks, M and K are natural numbers greater than 1, the method comprising: obtaining an output feature x j of the jth layer for a training sample, generating a feature matrix composed of M output features, 1≤j≤M; for the ith task, generating a sparse feature v i corresponding to the task according to the ith row in the sparse matrix and the output feature matrix, wherein the sparse matrix contains K*M trainable sparse parameters Z; obtaining an initial prediction feature of the multi-task model for the ith task, fusing the initial prediction feature and the sparse feature v i to generate a target prediction feature y i of the ith task; determining a loss value L i of the ith task according to the difference between the target prediction feature y i and the label of the training sample; generating a total loss value by fusing the loss values of the K tasks, and training the sparse parameters Z according to the total loss value.

[0007] In a second aspect, the embodiments of the present specification provide a training device of a model, applied to a multi-task model comprising M layers and K tasks, M and K are natural numbers greater than 1, the device comprises: an output feature acquisition module, acquiring output features x of the jth layer for a training sample j , generating a feature matrix composed of M output features, 1≤j≤M; a sparse feature module, for the ith task, generating a sparse feature v corresponding to the task according to the ith row in the sparse matrix and the output feature matrix i , wherein the sparse matrix comprises K*M trainable sparse parameters Z; a target prediction feature module, acquiring an initial prediction feature of the multi-task model for the ith task, fusing the initial prediction feature and the sparse feature v i to generate a target prediction feature y of the ith task i ; a single-task loss module, determining a loss value L of the ith task according to the difference between the target prediction feature y i and the label of the training sample i ; a training module, fusing the generated loss values of the K tasks to generate a total loss value, and training the sparse parameters Z according to the total loss value.

[0008] In a third aspect, one or more embodiments of the present specification provide an electronic device, comprising:

[0009] at least one processor; and

[0010] a memory in communication with the at least one processor; wherein

[0011] the memory stores instructions executable 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 of the first aspect.

[0012] In a fourth aspect, the embodiments of the present specification provide a non-volatile computer storage medium storing computer executable instructions, when a computer reads the computer executable instructions in the storage medium, the instructions enable one or more processors to perform the method of the first aspect.

[0013] The above at least one technical solution adopted by one or more embodiments of the present specification can achieve the following beneficial effects: by acquiring output features x of the jth layer for a training sample j , generating a feature matrix composed of M output features, 1≤j≤M; for the ith task, generating a sparse feature v corresponding to the task according to the ith row in the sparse matrix and the output feature matrix iWherein, the sparse matrix contains K*M trainable sparse parameters Z; obtaining initial prediction features of the i-th task by the multi-task model, fusing the initial prediction features and the sparse features v i Generating target prediction features y of the i-th task i ; determining the loss value L of the i-th task according to the difference between the target prediction features y i and the label of the training sample i ; generating a total loss value by fusing the generated loss values of the K tasks, and training the sparse parameters Z according to the total loss value, thereby introducing features of any layer for each task in the multi-task model training, different tasks can adaptively select different features, and the framework of introducing the sparse routing of each layer of features to different tasks is irrelevant to the structure of the multi-task model, which can be combined into any multi-task model to improve its performance and adaptability. BRIEF DESCRIPTION OF DRAWINGS

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present specification or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the present specification, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.

[0015] Figure 1 A flowchart of a training method provided by an embodiment of the present specification;

[0016] Figure 2 A schematic diagram of the architecture of a system provided by an embodiment of the present specification;

[0017] Figure 3 A schematic diagram of the generation of a loss value provided by an embodiment of the present specification;

[0018] Figure 4 A schematic diagram of the structure of a model training device provided by an embodiment of the present specification;

[0019] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present specification. DETAILED DESCRIPTION

[0020] The embodiments of the present specification provide a model training method, device, equipment and storage medium.

[0021] In order for those skilled in the art to better understand the technical solutions in the specification, the technical solutions in the specification will be clearly and completely described in the specification below in conjunction with the drawings in the specification embodiments. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the specification embodiments, all other embodiments obtained by those of ordinary skill in the art without creative labor should fall within the scope of protection of the present application.

[0022] As shown in Figure 1 , Figure 1 A flowchart of a training method of one type provided by the specification embodiments is shown in FIG. 1. The training method is applied to a multi-task model containing M layers and K tasks, M and K are natural numbers greater than 1, Figure 1 The flow in FIG. 1 can include the following steps:

[0023] S101: Obtain the output feature x j of the jth layer for the training sample, 1≤j≤M.

[0024] The multi-task model is a model based on multi-task learning (MTL), which learns multiple objectives and tasks simultaneously by constructing a single model. For example, a multi-task model simultaneously learns image recognition and image classification (i.e., the training sample at this time can be an image), or a multi-task model simultaneously learns to predict the click rate and reading time of a user for a recommended information, and simultaneously learns the purchase conversion rate of the user in the scene (i.e., the training sample can be data containing the features of the user and the recommended information).

[0025] In the multi-task model, a structure containing multiple layers (larey) can be included, such as an embedding layer, a sharing layer, and multiple output layers, etc.

[0026] The internal structure of these different levels can be based on self-setting, for example, for some sharing layers (sharing layer), it can use a bidirectional long short-term memory network (LSTM), etc. Each layer can contain model parameters to be trained. At the same time, these different hierarchical structures and model parameters can be shared between multi-tasks.

[0027] Thus, for each layer, it will generate a corresponding output feature. For the output feature of the jth layer, it can be denoted as x jTherefore, the M output features generated by the M layers can be denoted as the corresponding feature matrix [x1, x2, ..., x]. M The M output features generated by the M layers are all the same in dimensionality.

[0028] S103, for the i-th task, generate a sparse feature v corresponding to the task based on the i-th row of the sparse matrix and the output feature matrix. i The sparse matrix contains K*M trainable sparse parameters Z.

[0029] like Figure 2 As shown, Figure 2 This is a schematic diagram of a system architecture provided in an embodiment of this specification. The diagram illustrates a multi-task model with two tasks as an example; in practical applications, the number of tasks K is not limited.

[0030] As shown in the figure, for each task, a sparse matrix can be used to sparsely route the aforementioned M features, thereby generating K sparse features corresponding to K tasks, namely [v1, v2, ..., v...]. K ].

[0031] In other words, sparse routing of the feature matrix can be expressed using the following matrix operations:

[0032]

[0033] The sparse parameter Z ij This refers to the routing parameters that route the j-th output feature to the i-th task. ij These are learnable weight parameters. Each sparse parameter Z∈Z ij It can also be called an encoded variable or routing parameter, and should be a binary value, i.e., Z∈{0,1}.

[0034] For example, for the first task, its corresponding sparse feature is actually v1 = Z. 1j *[x1, x2, ..., x M ] T Among them, Z 1j This refers to the first row of the aforementioned sparse matrix, [x1, x2, ..., x...]. M ] T This is the transpose of the aforementioned characteristic matrix.

[0035] Because in a sparse matrix, the sparse parameter Z ij The value of Z is either 0 or 1. ij When the value is 0, it is obvious that the corresponding sparse features will not include the j-th output feature x. jWhen Z ij When the value is 1, the corresponding sparse features include the j-th output feature x. j Meanwhile, x j The weight is determined by the corresponding weight parameter a. ij Given.

[0036] In the embodiments of this specification, the sparse parameter Z and the weight parameter a ij These are all trainable parameters. Their initial values ​​can be given in advance based on requirements (e.g., given initial parameters that conform to a certain expected distribution), or they can be given arbitrarily (e.g., given initial values ​​that are random values ​​within a certain range).

[0037] S105, Obtain the initial prediction features of the multi-task model for the i-th task, and fuse the initial prediction features and the sparse features v. i Generate target prediction features y for the i-th task i .

[0038] For multi-task models, in addition to the aforementioned M-layer hierarchical structure, an initial prediction vector is provided for each task. The initial prediction vector corresponding to the i-th task is denoted as x. si Typically, the initial prediction vector is connected to a fully connected layer to provide the prediction result. Clearly, for each task, the initial prediction vector x... si It is a very representative feature vector.

[0039] Therefore, the sparse features v generated above can be used to... i and the initial prediction feature x si The features are fused to generate the target prediction feature yi for the i-th task. Here, || represents a fusion method, w is the task weight value, b is the offset, and σ is the activation function. The target prediction feature yi obtained after fusion is still used as the input of the aforementioned fully connected layer to produce a prediction result.

[0040] In one embodiment, the fusion method represented by || can be a combination of the initial predicted features and the sparse features v. i Generate target prediction features y for the i-th task i , that is Figure 2 As shown; or, that is, by pre-adjusting the sparse feature v i and the target prediction feature y i The sizes are consistent, thus allowing the initial prediction feature and the sparse feature v to be superimposed. i Generate target prediction features y for the i-th task i .

[0041] S107, predict the target feature y according to the target prediction feature y i The difference between the labels of the training samples and the actual labels determines the loss value L for the i-th task. i .

[0042] like Figure 3 As shown, Figure 3 This diagram illustrates the generation of a loss value as provided in an embodiment of this specification. For each task, the respective loss value is based on the labels of the training samples and the target prediction feature y. i Each loss value is calculated separately, resulting in L corresponding loss values.

[0043] S109, the loss values ​​of the K tasks generated by fusion are used to generate a total loss value, and the sparse parameter Z is trained based on the total loss value.

[0044] One approach to fusion is to directly sum the loss values ​​of the K tasks to generate a total loss value. Alternatively, it can be to generate a total loss value by weighted summation of the loss values ​​of the K tasks based on a preset weight distribution. Calculating the total loss value using the weighted summation method allows for the adjustment of the weight distribution to highlight tasks that require special attention. After obtaining the total loss value, the sparse parameter Z can be trained based on this loss value.

[0045] In one implementation, the parameters in each layer of the multi-task model can be fixed, while only the sparse parameters Z and weight parameters a in the sparse matrix are adjusted. ij Conduct training.

[0046] In this implementation, the training of the multi-task model can be performed in stages. For example, initially, the parameters in the multi-layer structure contained in the multi-task model are trained directly without adding the aforementioned sparse matrix. After the multi-task model reaches a certain accuracy, the parameters in the multi-layer structure are fixed, and the sparse matrix is ​​then added to the model along with the Z and weight parameters a in the sparse matrix. ij Training can be conducted in stages. This phased training approach allows for more convenient training based on user needs.

[0047] In another implementation, training the multi-task model can be performed simultaneously on the sparse parameters Z and the trainable parameters contained in the M layers, based on the total loss value. That is, the loss function is considered as a function of Z, X, W, and Y, where W represents the trainable parameters contained in the M layers, X represents the training samples, and Y represents the joint labels corresponding to multiple tasks.

[0048] At this time, if the preset sparse coefficient Z conforms to a certain expected distribution (the expected distribution is usually discrete, for example, assuming that it conforms to a Bernoulli distribution, i.e., Z ~ p(Z; π)), the training target of the model can be expressed by the following objective function:

[0049]

[0050] where f represents a mapping from the training sample X, the sparse parameter Z and the trainable parameters W contained in the M layers to the target prediction feature y i , and L represents the total loss value. The foregoing objective function and expression are such that, when Z conforms to the Bernoulli distribution, L is minimized by the mapping from X, W and Z.

[0051] However, as shown above, Z is a sparse value, which is either 0 or 1. In other words, for the function L, the variable Z is a discrete and non-differentiable variable, and therefore, the gradient of L with respect to Z cannot be directly calculated in a conventional manner, and it is thus difficult to directly train Z by back propagation.

[0052] Based on this, the expected distribution of the sparse parameter Z can be obtained, an approximate distribution of the expected distribution is determined, where the expected distribution is discrete, and the approximate distribution is continuous; and the sparse parameter Z is trained according to the total loss value and the approximate distribution. By using the continuous approximate distribution, the objective function is actually relaxed.

[0053] For example, when it is assumed that the expected distribution is a Bernoulli distribution, a continuous distribution s ~ q(θ; φ) close to the Bernoulli distribution is first found, and Z is recorded as the activated value of s. For example, Z = g(s) = min(1, max(0, θ)) is used to calculate the value of Z

[0054] where θ and φ are distribution parameters to be trained in the approximate distribution, and θ and φ are continuous and differentiable.

[0055] At this time, the calculation of the foregoing objective function is converted to finding the minimum value given X, W, s and Y. Since s is a continuous distribution containing continuous distribution parameters, the gradient of the distribution parameters contained in s with respect to L can be calculated at this time, and the distribution parameters can be trained according to the gradient.

[0056] In each round of iterative training, when the distribution parameters to be trained change, the corresponding s also changes, and at this time, the corresponding Z will also be updated.

[0057] For example, assuming s obeys the following distribution, s = sigmoid ((log (u) - log (1 - u) + log (a) / b), where log (a) is a trainable continuous distribution parameter, b is a hyperparameter, and u obeys a random distribution U (0, 1), which is a uniform random variable. It can be seen that s is a continuous distribution at this time. The value of b is between 0 and 1, which is used to adjust the sparsity of the sparse matrix. The closer b is to 1, the higher the sparsity of the sparse matrix obtained by training.

[0058] At this time, s can be iterated by iterating log (a) in each iteration by θ = s (ζ - γ) + γ, Z = min (1, max (θ, 0)), and then adjusting the value of the sparse parameter Z to the sparse value 0 or 1. Where γ and ζ are hyperparameters

[0059] In other words, by the foregoing method, the hidden variable log (a) and other parameters in each layer of the model can be trained in the training phase by means of a stochastic gradient. Since the foregoing u smoothes the distribution of Z as noise, the value of Z can be calculated by the following method: z = min (1, max (0, sigmoid (log (a)) (ζ - γ) + γ)). When sigmoid (log (a)) (ζ - γ) + γ < 0, z takes the value 0, thereby achieving training of the sparse value in the sparse matrix.

[0060] By obtaining the output feature x j of the jth layer for the training sample, a feature matrix composed of M output features is generated, 1 ≤ j ≤ M; for the ith task, the ith row of the sparse matrix and the output feature matrix are used to generate a sparse feature v i corresponding to the task, wherein the sparse matrix contains K*M trainable sparse parameters Z; the initial prediction feature of the multi-task model for the ith task is obtained, and the initial prediction feature and the sparse feature v i are fused to generate the target prediction feature y i of the ith task; the loss value L i of the ith task is determined according to the difference between the target prediction feature y i and the label of the training sample; the total loss value is generated by fusing the loss values of the K tasks, and the sparse parameters Z are trained according to the total loss value, thereby introducing features of any layer for each task in the multi-task model training, different tasks can adaptively select different features, and the framework of introducing features of each layer to different tasks is independent of the structure of the multi-task model, which can be combined into any multi-task model to improve its performance and adaptability.

[0061] Furthermore, it should be noted that the model training method described in this specification can be applied to any pre-trained multi-task model. Specifically, the aforementioned sparse matrix is ​​introduced into the pre-trained multi-task model, and the outputs of each layer of the model are connected to the sparse matrix, thereby obtaining the framework as shown below. Figure 2 The multi-task model shown is then retrained to improve its performance. In other words, implementing a sparse routing structure for multi-layer features using sparse matrices can be widely adapted to various multi-task models, regardless of the multi-task model itself.

[0062] Based on the same idea, one or more embodiments of this specification also provide apparatus and devices corresponding to the above methods, such as... Figure 4 , Figure 5 As shown.

[0063] In the second aspect, such as Figure 4 As shown, Figure 4 This is a schematic diagram of a training device for a model provided in an embodiment of this specification. It is applied to a multi-task model containing M layers and K tasks, where M and K are natural numbers greater than 1. The device includes:

[0064] Output feature acquisition module 401 acquires the output feature x of the j-th layer for the training samples. j Generate a feature matrix consisting of M output features, where 1 ≤ j ≤ M;

[0065] Sparse feature module 403, for the i-th task, generates sparse features v corresponding to the task based on the i-th row of the sparse matrix and the output feature matrix. i The sparse matrix contains K*M trainable sparse parameters Z;

[0066] The target prediction feature module 405 obtains the initial prediction features of the multi-task model for the i-th task, and fuses the initial prediction features and the sparse feature v. i Generate target prediction features y for the i-th task i ;

[0067] The single-task loss module 407, based on the target prediction feature y i The difference between the labels of the training samples and the actual labels determines the loss value L for the i-th task. i ;

[0068] Training module 409 merges the loss values ​​of the generated K tasks to generate a total loss value, and trains the sparse parameter Z based on the total loss value.

[0069] Optionally, the training module 409 acquires an expected distribution of the sparse parameter Z, determines an approximate distribution of the expected distribution, wherein the expected distribution is discrete and the approximate distribution is continuous; and trains the sparse parameter Z according to the total loss value and the approximate distribution.

[0070] Optionally, the training module 409 synchronously trains the sparse parameter Z and the trainable parameters included in the M layers according to the total loss value.

[0071] Optionally, the training module 409 determines a distribution parameter to be trained included in the approximate distribution; determines a gradient of the distribution parameter to be trained in the total loss value; and trains the distribution parameter according to the gradient, wherein the distribution parameter is used to adjust the value of the sparse parameter Z to a sparse value in each round of training.

[0072] Optionally, the target prediction feature module 405 concatenates the initial prediction feature and the sparse feature v i to generate the target prediction feature y i of the i-th task; or superimposes the initial prediction feature and the sparse feature v i to generate the target prediction feature y i of the i-th task.

[0073] Optionally, the training module 409 generates a total loss value based on a preset weight distribution weighted sum of loss values of K tasks.

[0074] In a third aspect, as Figure 5 shown, Figure 5 a structural schematic diagram of an electronic device provided by an embodiment of the present specification, the device comprising:

[0075] at least one processor; and

[0076] a memory in communication connection with the at least one processor; wherein

[0077] the memory stores instructions executable 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 execute the method of the first aspect.

[0078] In a fourth aspect, based on the same idea, the present specification also provides a non-volatile computer storage medium corresponding to the above method, which stores computer executable instructions, and when a computer reads the computer executable instructions in the storage medium, the instructions enable one or more processors to execute the method of the first aspect.

[0079] In the 1990s, it was quite obvious to distinguish whether an improvement in a technology was in hardware (e.g., improvement in circuit structures of diodes, transistors, switches, etc.) or in software (improvement in method flow). However, as technology has evolved, many improvements in method flow today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flow into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented by hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming it, rather than by asking a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented by "logic compiler" software, which is similar to software compilers used in program development, and the original code to be compiled is written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit implementing the logical method flow can be easily obtained.

[0080] The controller can be implemented in any suitable way, for example, the controller can take the form of a microprocessor or processor and a computer readable medium storing computer readable program code, such as software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that, in addition to being implemented in pure computer readable program code, the controller can equally well be implemented to perform the same functions using logic gates, switches, an application specific integrated circuit, a programmable logic controller and an embedded microcontroller, etc. by means of a logical programming of the method steps. The controller can thus be considered as a hardware component, and the means comprised therein for performing the various functions can be considered as structures within the hardware component. Alternatively, the means for performing the various functions can even be considered as both a software module implementing the method and a structure within the hardware component.

[0081] The systems, apparatuses, modules or units illustrated by the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0082] For the sake of description, the above apparatuses are described in functional division and are described respectively. Of course, the functions of the units can be implemented in the same or multiple software and / or hardware when implementing the present specification.

[0083] Those skilled in the art will understand that the embodiments of the present specification can be provided as a method, a system or a computer program product. Therefore, the embodiments of the present specification can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0084] The specification is presented with reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing element or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0085] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0086] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.

[0087] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0088] The memory can include non-persistent memory and / or storage mechanisms such as, for example, random access memory (RAM), non-volatile memory (NVM), and / or a persistent memory such as, for example, read-only memory (ROM) or flash memory. The memory is an example of computer-readable media.

[0089] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.

[0090] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not only include those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.

[0091] The specification can be described in the general context of computer-executable instructions, such as program modules, executed by computers. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The specification can also be practiced in a distributed computing environment, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0092] Each embodiment in the specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other, and each embodiment focuses on the difference from other embodiments. In particular, for device, equipment, non-volatile computer storage medium embodiments, because they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.

[0093] The above-described embodiments of the application have special structure and can achieve the desired results. Other embodiments can have different structures and achieve the same results. The purpose of the above-described embodiments is to illustrate the principles of the application and not to limit the scope of the application. The scope of the application is defined by the claims and their equivalents. Other embodiments are within the scope of the claims.

[0094] The above description is merely illustrative of the embodiments of the present application and is not intended to limit the scope of the present application. Various modifications can be made by those skilled in the art based upon the teachings disclosed herein. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present application shall fall within the scope of the claims of the present application.

Claims

1. A training method for a model, applied to a multi-task model comprising M layers and K tasks, where M and K are natural numbers greater than 1, the method comprising: Obtain the output feature x of the j-th layer for the training samples j Generate a feature matrix consisting of M output features, where 1 ≤ j ≤ M; For the i-th task, generate a sparse feature v corresponding to the task based on the i-th row of the sparse matrix and the output feature matrix. i The sparse matrix contains K*M trainable sparse parameters Z; Obtain the initial prediction features of the multi-task model for the i-th task, and fuse the initial prediction features and the sparse features v. i Generate target prediction features y for the i-th task i ; Based on the target prediction feature y i The difference between the labels of the training samples and the actual labels determines the loss value L for the i-th task. i ; The loss values ​​of the K tasks generated by the fusion are used to generate a total loss value, and the sparse parameter Z is trained based on the total loss value; The tasks include at least one of the following: image recognition, image classification, predicting a user's click-through rate for a recommendation, predicting a user's reading time for a recommendation, and purchase conversion rate.

2. The method as described in claim 1, wherein, Training the sparse parameters Z based on the total loss value includes: Obtain the expected distribution of the sparse parameter Z, and determine the approximate distribution of the expected distribution, wherein the expected distribution is discrete and the approximate distribution is continuous; The sparse parameter Z is trained based on the total loss value and the approximate distribution.

3. The method as described in claim 1, wherein, Training the sparse parameters Z based on the total loss value includes: The sparse parameter Z and the trainable parameters contained in the M layer are trained synchronously based on the total loss value.

4. The method of claim 2, wherein, Training the sparse parameter Z based on the total loss value and the approximate distribution includes: Determine the distribution parameters to be trained contained in the approximate distribution; The gradient of the distribution parameters to be trained is determined based on the total loss value; The distribution parameters are trained based on the gradient, wherein the distribution parameters are used to adjust the value of the sparse parameter Z to a sparse value in each training round.

5. The method of claim 1, wherein, The initial prediction features and the sparse features v are fused together. i Generate target prediction features y for the i-th task i ,include: splicing the initial predicted features and the sparse features v i Generate target prediction features y for the i-th task i ;or, The initial prediction features and the sparse features v are superimposed. i Generate target prediction features y for the i-th task i .

6. The method of claim 1, wherein, The total loss value is generated by fusing the loss values ​​of the K tasks, including: The total loss value is generated by weighted summation of the loss values ​​of K tasks based on a preset weight distribution.

7. A training apparatus for a model, applied to a multi-task model comprising M layers and K tasks, where M and K are natural numbers greater than 1, the apparatus comprising: The output feature acquisition module obtains the output features x of the j-th layer for the training samples. j Generate a feature matrix consisting of M output features, where 1 ≤ j ≤ M; The sparse feature module, for the i-th task, generates sparse features v corresponding to that task based on the i-th row of the sparse matrix and the output feature matrix. i The sparse matrix contains K*M trainable sparse parameters Z; The target prediction feature module obtains the initial prediction features of the multi-task model for the i-th task, and fuses the initial prediction features with the sparse feature v. i Generate target prediction features y for the i-th task i ; The single-task loss module predicts the target feature y based on the target prediction feature. i The difference between the labels of the training samples and the actual labels determines the loss value L for the i-th task. i ; The training module merges the loss values ​​of the generated K tasks to generate a total loss value, and trains the sparse parameter Z based on the total loss value; The tasks include at least one of the following: image recognition, image classification, predicting a user's click-through rate for a recommendation, predicting a user's reading time for a recommendation, and purchase conversion rate.

8. An electronic device, comprising: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, such that the at least one processor can perform the method as described in any one of claims 1 to 6.