Model processing method and device, electronic equipment and readable storage medium
By dynamically adjusting the loss weights of each network in the multi-task model, the problem of uneven network convergence speed is solved, and the training efficiency and learning performance are improved.
Patent Information
- Application Number
- CN202510213277.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-09-23
AI Technical Summary
In the existing technology, the convergence speed of each network in the multi-task model is uneven during the training process, resulting in low training efficiency.
By determining the loss value and convergence speed of each network, the loss weight is dynamically adjusted to balance the training progress of each network.
This enables each network to complete training at a similar pace, improving the learning performance and training efficiency of the model.
Smart Images

Figure CN120688587A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to artificial intelligence technology, and in particular to a model processing method, device, electronic device and readable storage medium. Background Art
[0002] Model training is a core technology in the field of artificial intelligence. It involves using large amounts of data through iterative algorithm optimization to enable machine learning models to simulate the human learning process, thereby automating specific tasks. Machine learning models include single-task models and multi-task models. Multi-task models are neural network models that simultaneously incorporate multiple networks, each with its own training objectives. Summary of the Invention
[0003] The embodiments of the present application provide a model processing method, device, electronic device and readable storage medium, which can balance the convergence speed of each network included in the model during the model training process.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present invention provides a model processing method, which includes:
[0006] During the i-th iterative training of the model, determining a loss value of each of the multiple networks included in the model to obtain multiple first loss values;
[0007] For each of the networks, determining a convergence rate of the network based on the first loss value and the second loss value of the network, wherein the second loss value comprises a loss value of the network determined during a first i-1 iterations of training of the model;
[0008] For each of the networks, determining a loss weight value of the network based on the measurement value of the network and the convergence speed;
[0009] Based on the plurality of loss weight values and the plurality of first loss values, the parameters of the model are updated.
[0010] The present invention provides a model processing device, comprising:
[0011] a loss value determination module, configured to determine the loss value of each of the multiple networks included in the model during the i-th iterative training process of the model, to obtain multiple first loss values;
[0012] a loss weight determination module, configured to determine, for each of the networks, a convergence rate of the network based on the first loss value and the second loss value of the network, wherein the second loss value comprises the loss value of the network determined during the first i-1 iterations of training of the model;
[0013] The loss weight determination module is further configured to determine, for each of the networks, a loss weight value of the network based on the measurement value of the network and the convergence speed;
[0014] A back propagation module is used to update the parameters of the model based on the multiple loss weight values and the multiple first loss values.
[0015] An embodiment of the present application provides an electronic device, comprising:
[0016] a memory for storing computer-executable instructions or computer programs;
[0017] The processor is used to implement the model processing method provided in the embodiment of the present application when executing the computer executable instructions or computer program stored in the memory.
[0018] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the model processing method provided in the embodiment of the present application when executed by a processor.
[0019] An embodiment of the present application provides a computer program product, including a computer program or computer-executable instructions. When the computer program or computer-executable instructions are executed by a processor, the model processing method provided in the embodiment of the present application is implemented.
[0020] The embodiments of the present application have the following beneficial effects:
[0021] The training progress of each network in the model is determined by the measurement value and convergence speed of each network during the training process, so as to dynamically adjust the loss weight corresponding to each network, thereby balancing the convergence speed of each network in the model, so that each network can complete the training at a progress as close as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a schematic diagram of the structure of the model processing system architecture provided in an embodiment of the present application;
[0023] Figure 2 is a structural diagram of an electronic device for model processing provided in an embodiment of the present application;
[0024] Figure 3 This is a first flow chart of the model processing method provided in an embodiment of the present application;
[0025] Figure 4 This is a second flow chart of the model processing method provided in an embodiment of the present application;
[0026] Figure 5 This is a third flow chart of the model processing method provided in the embodiment of the present application;
[0027] Figure 6 4 is a schematic diagram of a fourth flow chart of the model processing method provided in an embodiment of the present application;
[0028] Figure 7 This is a fifth flow chart of the model processing method provided in the embodiment of the present application;
[0029] Figure 8 This is a sixth flow chart of the model processing method provided in an embodiment of the present application;
[0030] Figure 9 It is a schematic diagram of the model structure provided in the embodiment of this application.
[0031] It should be pointed out that the above-mentioned "first" and "second" are only used to distinguish different solutions, and do not represent the degree of distinction between the advantages and disadvantages of the solutions or the priority in the implementation process. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0033] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0034] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0035] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0036] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0037] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, and the informed consent or separate consent of the personal information subject should be obtained. Subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.
[0038] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0039] 1) Model training: Model training refers to the process of learning a dataset through an algorithm so that a machine learning model can perform a specific task. Machine learning models include single-task models and multi-task models. A dataset refers to a set of sample data used to train a machine learning model, including a training set, a validation set, and a test set. The sample data in the training set, validation set, and test set do not overlap. Model training mainly involves two processes: forward propagation and back propagation. Taking a multi-task model including an input layer, a hidden layer, and an output layer as an example, forward propagation processing refers to processing through the input layer, hidden layer, and output layer in sequence to finally obtain a prediction result; back propagation processing refers to propagating the calculated loss value to the output layer, hidden layer, and input layer in sequence, thereby updating the weight parameters in each layer.
[0040] 2) Multi-Task Learning (MTL): A multi-task model is a model designed to solve multiple related problems simultaneously. It includes multiple tasks (multiple networks). In a multi-task model, multiple tasks share some underlying feature representations. For example, a multi-task model may simultaneously learn image classification and image segmentation tasks, extracting common features through shared convolutional layers.
[0041] 3) Sample Data: Sample data refers to the data used to train, verify, and test machine learning models. Each sample data typically includes input feature information (Features) and corresponding output label information (Labels). Feature information is the observation value or attribute that describes the sample, which is used to train the model to recognize patterns and regularities in the data. Label information is the target value that the model is expected to recognize or predict. For example, for a model that recognizes cats in pictures, the feature information of each sample data may include the pixel value of the picture, and the label information may be a binary value (0 or 1) indicating whether the picture contains a cat.
[0042] 4) Training Set: Also known as the training sample set, the training set is a collection of sample data for direct parameter model training. The training set includes multiple training sample data. During the model training process, the model will learn how to predict the label information of the training sample data based on the feature information of the training sample data.
[0043] 5) Validation Set: Also known as the validation sample set, the validation set is a collection of sample data used to evaluate the performance of the model during training. Based on the validation sample set, the model convergence progress is observed during training, and then the model parameters are adjusted or the model is selected to ensure that the model has good generalization ability.
[0044] 6) Metrics: Metrics are a series of indicators used to evaluate model performance. They help understand the model's predictive power and assist data scientists and engineers in making decisions to improve model performance. These metrics include accuracy, precision, recall, and F1 score. Accuracy is the ratio of samples correctly predicted by the model to the total number of samples, while precision is the ratio of samples whose actual labeled values are also true, among samples predicted by the model to be true.
[0045] 7) Convergence rate: Convergence rate is a key performance indicator in model training. It describes how quickly the algorithm approaches the optimal solution as the number of training iterations increases. A fast convergence rate means that the algorithm can quickly stabilize and reduce the value of the loss function, thereby achieving good performance within a fewer number of iterations.
[0046] Embodiments of the present application provide a model processing method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can balance the convergence speed of each network included in the model during the model training process.
[0047] The model processing method provided in the embodiments of the present application can be applied to various scenarios, such as robot dialogue systems, recommendation systems, autonomous driving systems, medical diagnosis systems, image and video analysis systems, and robot control systems, etc., which are not limited here.
[0048] The electronic devices for model processing provided in the embodiments of the present application can be various types of terminals or servers, wherein the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services; the terminal can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smart TV, smart watch, etc., but is not limited to these. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0049] See also Figure 1 , Figure 1 It is a structural diagram of the model processing system architecture provided in an embodiment of the present application. In the model processing system 10 provided in an embodiment of the present application, in order to support a model processing application, the terminal 400 is connected to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.
[0050] Terminal 400 can be used to obtain a model processing request including multiple first loss values.
[0051] In some embodiments, a model processing plug-in may be implanted in the client running in the terminal 400 to implement the model processing method locally on the client. For example, the terminal 400 calls the model processing plug-in to implement the model processing method. During the i-th iterative training of the model, the loss value of each of the multiple networks included in the model is determined to obtain multiple first loss values. For each network, the convergence speed of the network is determined based on the first loss value and the second loss value of the network. For each network, the loss weight value of the network is determined based on the measurement value and convergence speed of the network. Based on the multiple loss weight values and the multiple first loss values, the parameters of the model are updated to obtain the parameters of the model after the i-th training.
[0052] It is worth noting that the parameters of the model after the i-th training can be stored locally in the terminal 400 and called when needed.
[0053] In some embodiments, after the terminal 400 obtains a model processing request containing multiple first loss values, it calls the model processing interface of the server 200 (which can be provided in the form of a cloud service, such as a model processing service). The server 200 implements the model processing method through the model processing plug-in. For each network, the convergence speed of the network is determined based on the first loss value and the second loss value of the network. For each network, the loss weight value of the network is determined based on the measurement value and convergence speed of the network. Based on the multiple loss weight values and the multiple first loss values, the parameters of the model are updated to obtain the parameters of the model after the i-th training.
[0054] It is worth noting that the parameters of the model after the i-th training can be stored locally on the server 200 and called when needed.
[0055] In the application scenario of the robot dialogue system, the robot dialogue model used for the robot dialogue system includes multiple networks, such as an entity recognition network, an emotion calculation network, and a similarity determination network. During the i-th iterative training of the robot dialogue model, the first loss values corresponding to the entity recognition network, the emotion calculation network, and the similarity determination network, as well as the loss weight values corresponding to the entity recognition network, the emotion calculation network, and the similarity determination network, are determined. Based on the first loss values and loss weight values of the above three networks, the parameters of the robot dialogue model are updated.
[0056] In the application scenarios of the recommendation system, the recommendation models used on e-commerce, video streaming, social media and other platforms include multiple networks, such as a browsing behavior analysis network, a purchase history analysis network and an evaluation feedback analysis network. During the i-th iterative training of the recommendation model, the first loss values corresponding to the browsing behavior analysis network, the purchase history analysis network and the evaluation feedback analysis network, as well as the loss weight values corresponding to the browsing behavior analysis network, the purchase history analysis network and the evaluation feedback analysis network, are determined respectively. Based on the first loss values and loss weight values of the above three networks, the parameters of the recommendation model are updated.
[0057] In the application scenario of the autonomous driving system, the autonomous driving model used for the autonomous driving system includes multiple networks, such as an image recognition network, an obstacle detection network, and a path planning network. During the i-th iterative training of the autonomous driving model, the first loss values corresponding to the image recognition network, the obstacle detection network, and the path planning network, as well as the loss weight values corresponding to the image recognition network, the obstacle detection network, and the path planning network, are determined respectively. Based on the first loss values and loss weight values of the above three networks, the parameters of the autonomous driving model are updated.
[0058] The model processing method provided in the embodiment of the present application can be implemented independently by the terminal or the server, or can be implemented collaboratively by the terminal and the server. For example, the terminal independently undertakes the model processing method described below, or the terminal sends a model processing request containing multiple first loss values to the server. The server executes the model processing method based on the received model processing request containing multiple first loss values. During the i-th iterative training of the model, the loss value of each network in the multiple networks included in the model is determined to obtain multiple first loss values. For each network, the convergence speed of the network is determined based on the first loss value and the second loss value of the network. For each network, the loss weight value of the network is determined based on the measurement value and convergence speed of the network. Based on the multiple loss weight values and the multiple first loss values, the parameters of the model are updated to obtain the parameters of the model after the i-th training.
[0059] In some embodiments, the terminal or server can implement the model processing method provided in the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP, Application), that is, a program that needs to be installed in the operating system to run, such as a live broadcast application; it can also be a small program, that is, a program that can be run only by downloading it into a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0060] In some embodiments, the server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms. Among them, the cloud service can be a model processing service for terminals to call.
[0061] See also Figure 2 , Figure 2 is a structural diagram of an electronic device for model processing provided in an embodiment of the present application, Figure 2 The electronic device 500 shown may be Figure 1The terminal 400 or server 200 in the electronic device 500 includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together through a bus system 540. It can be understood that the bus system 540 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 2 Various buses are labeled as bus system 540 .
[0062] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0063] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, a hard drive, an optical drive, etc. The memory 550 may optionally include one or more storage devices physically located away from the processor 510.
[0064] The memory 550 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.
[0065] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.
[0066] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0067] A network communication module 552 for reaching other computing devices via one or more (wired or wireless) network interfaces 520 , exemplary network interfaces 520 including Bluetooth, WiFi, and USB;
[0068] In some embodiments, the apparatus provided in the embodiments of the present application may be implemented in software. Figure 2 The model processing device 555 stored in the memory 550 is shown. This device can be software in the form of a program or plug-in, and includes the following software modules: a loss value determination module 5551, a loss weight determination module 5552, and a backpropagation module 5553. These modules are logical and can be arbitrarily combined or further separated according to the functions implemented. The functions of each module will be described below.
[0069] In other embodiments, the apparatus provided in the embodiments of the present application may be implemented in hardware. As an example, the apparatus provided in the embodiments of the present application may be a processor in the form of a hardware decoding processor, which is programmed to execute the model processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor may be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0070] See also Figure 3 , Figure 3 This is a first flow chart of the model processing method provided in the embodiment of the present application, which will be combined with Figure 3 The steps shown are used for illustration. The model processing method provided in the embodiment of the present application can be implemented by the server or the terminal alone, or by the server and the terminal in collaboration. Therefore, the execution entity of each step will not be repeated below.
[0071] In step 101, during the i-th iterative training process of the model, the loss value of each network in the multiple networks included in the model is determined to obtain multiple first loss values.
[0072] The model is a multi-task model consisting of multiple networks, each of which performs a different task. For example, in the application scenario of a robot dialogue system, the robot dialogue model includes an entity recognition network, an emotion calculation network, and a similarity determination network. The entity recognition network is responsible for performing entity recognition processing on the input information, the emotion calculation network is responsible for determining the emotion label of the input information, and the similarity determination network is responsible for identifying the text in the question-and-answer database that is most similar to the input information.
[0073] As an example, for a model obtained after the i-1th iterative training, during the i-th iterative training, the loss value of each of the J networks included in the model is determined to obtain J first loss values, where the network and the first loss value correspond one-to-one, and J is a positive integer greater than 1. For example, in an application scenario of a robot dialogue system, the robot dialogue model includes an entity recognition network, an emotion calculation network, and a similarity determination network. During the i-th iterative training of the robot dialogue model, the first loss value corresponding to the entity recognition network, the first loss value corresponding to the emotion calculation network, and the first loss value corresponding to the similarity determination network are obtained.
[0074] In some embodiments, see Figure 4 , Figure 4 This is a second flow chart of the model processing method provided in the embodiment of the present application. Figure 3 The illustrated step 101 can be implemented by following the steps 1011 to 1012 , which are described in detail below.
[0075] In step 1011, based on the feature information of the second sample data included in the training sample set, the model is forward propagated to obtain a plurality of output data corresponding to the plurality of networks.
[0076] The second sample data includes feature information and multiple tag information, and the network and tag information correspond one to one.
[0077] As an example, the model includes a parameter sharing layer and a parameter exclusive layer. The parameter sharing layer refers to the underlying network structure shared by the multiple networks included in the model, and the parameter exclusive layer refers to the network structure that is exclusive to the multiple networks included in the model. The characteristic information of the second sample data is predicted and processed through the parameter sharing layer of the model to obtain the output characteristics of the parameter sharing layer. For each network in the multiple networks included in the model, the following processing is performed: the output characteristics of the parameter sharing layer are predicted and processed through the parameter exclusive layer corresponding to the network to obtain the output data of the network.
[0078] See also Figure 9 , Figure 9 : This is a schematic diagram of the model structure provided by an embodiment of the present application. The model includes J tasks (i.e., networks). The input data (i.e., the feature information of the second sample data) is predicted and processed through the parameter sharing layer of the model to obtain the output feature v of the parameter sharing layer. The output feature v is predicted and processed through the parameter exclusive layer 1 corresponding to task 1 to obtain the output data v1 of task 1. The output feature v is predicted and processed through the parameter exclusive layer 2 corresponding to task 2 to obtain the output data v2 of task 2. Similarly, the output feature v is predicted and processed through the parameter exclusive layer J corresponding to task J to obtain the output data v of task J. J .
[0079] For example, in the application scenario of the robot dialogue system, the robot dialogue model includes an entity recognition network, an emotion calculation network and a similarity determination network. The text encoder (i.e., the parameter sharing layer) included in the robot dialogue model is used to encode the feature information of the second sample data "What is the weather like in community s today" (i.e., prediction processing) to obtain the output features of the text encoder. The output features of the text encoder are processed by the entity recognition network to obtain the output data of the entity recognition network "today, weather"; the output features of the text encoder are processed by the emotion calculation network to obtain the output result of the emotion recognition network "neutral"; the output features of the text encoder are processed by the similarity determination network to obtain the output result of the similarity determination network "what to wear today".
[0080] In step 1012, a plurality of first loss values are obtained based on the plurality of output data and the plurality of label information of the second sample data.
[0081] The second sample data includes a plurality of tag information, and the network and the tag information correspond one to one.
[0082] As an example, for each of the multiple networks included in the model, the label information corresponding to the network is determined from the multiple label information of the second sample data, and the output data of the network and the label information corresponding to the network are encoded respectively to obtain the encoding features of the output data of the network and the encoding features of the label information corresponding to the network. A loss function is constructed based on the encoding features of the output data of the network and the encoding features of the label information corresponding to the network, and the value of the loss function is determined as the first loss value.
[0083] The loss function corresponding to each network can be the same type of loss function or different types of loss functions, which are not limited here. The loss function can be cross entropy loss (CE loss, Cross-Entropy Loss), L1 loss, mean squared error loss (MSE loss, Mean Squared Error Loss), Kruskal-Leibler divergence loss (KL divergence loss, Kullback-Leibler Loss), etc., which are not limited here. The encoding feature can be obtained by encoding the data based on the bidirectional encoder model (BERT, Bidirectional Encoder Representations from Transformers), or by encoding the data based on the word2vec model, which is not limited here.
[0084] See also Figure 9Based on the loss function 1 corresponding to task 1, calculate the loss between the output data v1 of task 1 and the label information corresponding to task 1, and obtain the loss value of task 1 (i.e., the first loss value). Similarly, obtain the loss values of tasks 2 to task J.
[0085] For example, in an application scenario of a robot dialogue system, the robot dialogue model includes an entity recognition network, and the characteristic information of the second sample data is: "How is the weather in s community today?" The label information corresponding to the entity recognition network included in the second sample data is "s community, today, weather". Forward propagation is performed based on the characteristic information of the second sample data, and the output data of the entity recognition network "today, weather" is obtained. The output data of the entity recognition network is encoded to obtain the encoding features of the output data of the entity recognition network. The label information corresponding to the entity recognition network is encoded to obtain the encoding features of the label information corresponding to the entity recognition network. Based on the cross-entropy loss function, the cross-entropy loss value of the encoding features of the output data and the encoding features of the label information is calculated, and the cross-entropy loss value is determined as the first loss value obtained in the i-th iterative training process corresponding to the entity recognition network.
[0086] In an embodiment of the present application, the model includes a parameter sharing layer and a parameter exclusive layer. The underlying network of the model is shared by multiple networks included in the parameter sharing layer model, so that the multiple networks can utilize each other's useful information obtained during the training process, thereby achieving better learning effects. At the same time, sharing the underlying network can effectively reduce the number of parameters of the model, while improving the training efficiency of the model and reducing the model's occupancy of local hardware resources. In addition, the multiple parameter exclusive layers corresponding to the multiple networks are decoupled from each other, and the parameter exclusive layers corresponding to the network can be flexibly added or deleted in the model framework to adjust the model to adapt to different application scenarios.
[0087] The model can include J networks, which can be represented as network 1, network 2...network J. During the i-th iterative training process of the model, the J first loss values of the J networks included in the model can be represented as l 1,i 、l 2,i 、……、l J,i Next, for the j-th network among the J networks included in the model, the following steps 102 and 103 are performed, wherein j and J are both positive integers, 1≤j≤J.
[0088] In step 102, a convergence speed of the network is determined based on a first loss value and a second loss value of the network.
[0089] The second loss value includes the loss value determined by the network during the first i-1 iterations of training the model.
[0090] As an example, the first loss value of the jth network included in the model can be represented as l j,i , the second loss can be characterized as l j,1 、l j,2 ……l j,i-1 , based on the first loss value l of the j-th network j,i and the second loss value l j,1 、l j,2 ……l j,i-1 , determines the convergence rate of the jth network during the i-th iterative training of the model.
[0091] In some embodiments, see Figure 5 , Figure 5 This is a third flow chart of the model processing method provided in the embodiment of the present application. Figure 3 The illustrated step 102 can be implemented by following the steps 1021 to 1022 , which are described in detail below.
[0092] In step 1021 , a plurality of loss difference values are determined based on a first loss value and a second loss value of the network.
[0093] The loss difference is determined based on the loss values obtained from two adjacent iterative trainings.
[0094] As an example, in the first i-1 iteration training, for the adjacent qth iteration training and q-1th iteration training, the loss value obtained by the qth iteration training can be represented as l j,q , the loss value obtained from the q-1th iteration training can be represented as l j,q-1 , the loss value l obtained from the qth iteration training j,q The loss value l obtained from the q-1th iteration training j,q-1 The loss difference between includes but is not limited to the difference, the absolute value of the difference, and the square of the absolute value of the difference, where q is an integer and 1<q≤i.
[0095] For example, when the loss difference is the absolute value of the difference, the loss value l obtained in the qth iteration training process is j,q And the loss value l obtained in the q-1th iteration training process j,q-1 The loss difference between them can be represented as |l j,q -l j,q-1 The loss difference can be used to measure the contribution of the qth iterative training to the convergence progress of the jth network. The sum of the i-1 loss differences between the loss values obtained from two adjacent iterative training of the jth network can be represented as
[0096] In step 1022, a convergence speed of the network is determined based on the plurality of loss differences.
[0097] As an example, the average of multiple loss differences is determined, and the average of multiple loss differences is determined as the convergence speed of the network. The convergence speed can be used to measure the average convergence speed of the network's first i-1 iterative training. The convergence speed is negatively correlated with the network's loss weight value. The greater the network's convergence speed, the smaller the corresponding loss weight value of the network. Similarly, the smaller the network's convergence speed, the larger the corresponding loss weight value of the network.
[0098] For example, when the loss difference is the absolute value of the difference, the mean of the multiple loss differences corresponding to the j-th network can be represented as And the mean of multiple loss differences is determined as the convergence rate of the j-th network.
[0099] In an embodiment of the present application, the convergence speed of the network is determined by the first loss value and the second loss value, so that the training progress and status of the network can be understood in real time, which helps to adjust the training strategy of the model in a timely manner. Further, it helps to formulate a more scientific training plan and avoid unnecessary training iterations, thereby significantly saving computing resources.
[0100] In step 103, the loss weight value of the network is determined based on the measurement value and convergence speed of the network.
[0101] As an example, the measurement value is used to evaluate the performance index of the network obtained after iterative training. The measurement values include: accuracy, precision, recall rate and F1 score. For the model obtained after the i-1th iterative training, the measurement value of the jth network included in the model during the i-th iterative training process can be represented as p j,i-1 , based on the measure value p of the jth network j,i-1 and convergence speed Determine the loss weight value of the j-th network.
[0102] In some embodiments, the measurement value of the network can be the prediction accuracy of the network on a validation sample set, where the validation sample set includes a first number of third sample data. The measurement value of the network can be determined by the following steps: forward propagation of the first number of third sample data included in the validation sample set to obtain a first number of output data of the network; determining a second number of accurately predicted data in the first number of output data; and determining the measurement value of the network based on the ratio of the second number to the first number.
[0103] For example, in the application scenario of the robot dialogue system, the prediction accuracy of the emotion computing network included in the robot dialogue model on the verification sample set is calculated. The verification sample set includes two (i.e., the first quantity) third sample data. The third sample data A is {feature information: "The scenery of my hometown is so beautiful!"; label information: "positive"}, and the third sample data B is {feature information: "How is the weather today."; label information: "neutral"}. The above two third sample data are forward propagated, and the prediction result of the emotion computing network for the feature information of the third sample data A "The scenery of my hometown is so beautiful!" is "positive", and the prediction result for the feature information of the third sample data B "How is the weather today" is "negative", that is, the emotion computing network's prediction for the third sample data A is correct, and the prediction for the third sample data B is wrong. Therefore, the measure value of the emotion computing network is 0.5.
[0104] In some embodiments, Figure 3 The illustrated step 103 can be implemented by the following steps: determining a ratio of a first loss value to a convergence speed; performing a numerical transformation on the measurement value to obtain a first numerical value; and determining a loss weight value based on the ratio and the first numerical value.
[0105] As an example, determine the ratio of the first loss value to the convergence speed. When the measure value is positively correlated with the convergence speed, the first value is negatively correlated with the measure value, indicating that as the measure value increases, the first value decreases and the convergence speed accelerates. At this time, it is necessary to reduce the loss weight value corresponding to the j-th network. The numerical transformation of the measure value can be to perform a logarithmic transformation on the measure value to obtain the logarithmically transformed measure value, and the negative value of the logarithmically transformed measure value is determined as the first value. During the i-th iterative training process of the model, according to formula (1.1), based on the ratio and the first value, the loss weight value of the j-th network included in the model is determined. The loss weight value is positively correlated with the ratio and the first value, respectively. Formula (1.1) is as follows:
[0106]
[0107] Among them, during the i-th iteration training of the model, w j,i is the loss weight value of the j-th network, l j,i is the first loss value of the j-th network, is the convergence speed of the jth network, p j,i-1 is the measure value of the j-th network, -logp j,i-1 is the first value.
[0108] In contrast, when the measurement value is negatively correlated with the convergence speed, the first value is positively correlated with the measurement value, indicating that as the measurement value increases, the first value increases and the convergence speed slows down. At this time, the loss weight value corresponding to the j-th network needs to be increased.
[0109] In an embodiment of the present application, by dynamically adjusting the loss weight value of the network, the convergence speed of networks of different complexity is made as close as possible, avoiding the problem that some networks converge very quickly while other networks converge very slowly or even stagnate, thereby improving the training efficiency of the model training.
[0110] In step 104 , parameters of the model are updated based on the multiple loss weight values and the multiple first loss values.
[0111] As an example, based on multiple loss weight values, multiple first loss values are fused to obtain the total loss value of the i-th iterative training of the model, and the parameters of the model are updated based on the total loss value of the i-th iterative training of the model, wherein the fusion processing includes: weighted summation processing, weighted average processing, voting processing, etc., which are not limited here.
[0112] When the fusion process is a weighted summation process, the loss weight values w can be calculated based on the formula (1.2). 1,i 、w 2,i 、……、w j,i 、……、w J,i , for J first loss values l 1,i 、l 2,i 、……、l j,i 、……、l J,i Perform fusion processing to obtain the total loss value of the i-th iterative training. Formula (1.2) is as follows:
[0113]
[0114] Among them, L i is the total loss value of the i-th iteration training, w j,i is the loss weight value of the j-th network, l j,i The first loss value of the j-th network.
[0115] The total loss value is used to characterize the difference between the model's predicted results and the actual results. By minimizing the total loss value of the i-th iterative training, the model parameters are updated (back propagation) to obtain the model after the i-th iterative training. The method for updating the model parameters can use gradient descent or other optimization algorithms, which are not limited here.
[0116] In an embodiment of the present application, the real-time training progress and status of each network can be determined by the measurement value and convergence speed of each network during the training process, and then the loss weight corresponding to each network can be dynamically adjusted to balance the convergence speed of each network in the model, so that different networks can complete convergence at a similar progress, significantly improving the learning performance and training efficiency of the model.
[0117] In some embodiments, see Figure 6 , Figure 6 This is a fourth flow chart of the model processing method provided in the embodiment of the present application. Figure 3 Before step 101 shown, the following steps 201 to 204 may be performed, which are described in detail below.
[0118] In step 201 , M cluster center data are screened out from N first sample data.
[0119] Wherein, N is an integer greater than M, M is an integer greater than 0, and the similarity between any two cluster center data among the M cluster center data is greater than the similarity threshold.
[0120] As an example, N first sample data may be represented as t1, t2, ..., t N , M cluster center data can be represented as k1, k2, ..., k M The first sample data includes feature information and multiple label information. For example, in the application scenario of the robot dialogue system, the robot dialogue model includes an entity recognition network, an emotion calculation network and a similarity determination network. The first sample data includes feature information and three label information. The feature information of the first sample data is "What is the weather like today?", the label information corresponding to the entity recognition network is "today, weather", the label information corresponding to the emotion calculation network is "neutral", and the label information corresponding to the similarity determination network is "what is the temperature today".
[0121] In some embodiments, Figure 6 The shown step 201 can be implemented by the following steps: determining one of the N first sample data as the 1st cluster center data; among the N first sample data, determining the first sample data different from the first m cluster center data as Nm fourth sample data; among the Nm fourth sample data, determining the fourth sample data with the smallest sum of m similarities with the first m cluster center data as the m+1th cluster center data.
[0122] Here, m is an integer that increases successively, and 1≤m<M.
[0123] As an example, any one of the N first sample data is determined as the first cluster center data. When determining the m+1th cluster center data, the first sample data other than the first m cluster center data in the N first sample data is determined as the fourth sample data. For each of the Nm fourth sample data, the sum of the m similarities between the fourth sample data and the first m cluster center data is determined. The fourth sample data with the smallest sum of the m similarities with the first m cluster center data among the Nm fourth sample data and that satisfies the cluster center data screening formula (1.3) is determined as the m+1th cluster center data. The similarity between the fourth sample data and the cluster center data can be obtained by calculating the distance between the fourth sample data and the cluster center data. The higher the similarity between the fourth sample data and the cluster center data, the smaller the distance between the fourth sample data and the cluster center data, and vice versa. The distance between the fourth sample data and the cluster center data can include cosine distance, Euclidean distance, etc., which are not limited here.
[0124] For example, from N first sample data t1, t2, ..., t N The first cluster center data k1 is randomly selected from the remaining N-1 sample data, and the fourth sample data that is farthest from the first cluster center data k1 and satisfies the cluster center data screening formula (1.3) is determined as the second cluster center data k2. Similarly, from the Nm fourth sample data, the distances to k1, k2, and so on are added to the distances to k1, k2, and k m The fourth sample data with the longest sum of distances and satisfying the cluster center data screening formula (1.3) is determined as the m+1th cluster center data k m+1 .
[0125] The cluster center data screening formula (1.3) is as follows:
[0126]
[0127] Among them, k m+1 is the fourth sample data with the smallest sum of m similarities with the first m cluster center data, k i is the i-th cluster center data among the first m cluster center data, i is a positive integer less than or equal to m, d(k m+1 ,k i ) represents the fourth sample data k m+1 With cluster center data k i The distance between them, d(t i ,t j ) represents the first sample data t i With the first sample data t j The distance between represents the fourth sample data k m+1With the first m cluster center data k1, k2, ..., k m The average of the sum of distances, is the average distance between the first sample data, which represents the average value of the sum of the distances between any two first sample data among the N first sample data.
[0128] For the fourth sample data that does not meet the cluster center data screening formula (1.3), the fourth sample data k is characterized as follows: m+1 If the average distance to the determined m cluster center data is less than 2 times the average distance between the first sample data, then the fourth sample data is considered unsuitable as the (m+1)th cluster center data, and the cluster center data construction is stopped.
[0129] In the embodiment of the present application, the number of cluster center data can be determined dynamically with low computational complexity, which not only ensures the diversity of classification but also avoids excessive computation, thus helping to improve classification efficiency and reduce hardware requirements.
[0130] In step 202 , based on the M cluster center data, the N first sample data are divided into M sample data sets.
[0131] As an example, each of the M sample data sets corresponds to a cluster center data, and the first sample data included in each sample data set is different from each other.
[0132] In some embodiments, see Figure 7 , Figure 7 This is a fifth flow chart of the model processing method provided in the embodiment of the present application. Figure 6 The illustrated step 202 may be implemented by executing the following steps 2021 to 2024, which are described in detail below.
[0133] In step 2021, M initial sample data sets are constructed based on the M cluster center data.
[0134] Among them, the M cluster center data correspond one-to-one to the M initial sample data sets.
[0135] As an example, one cluster center data corresponds to one initial sample data set, and the initial sample data set only includes its corresponding cluster center data.
[0136] In step 2022 , among the N first sample data, the first sample data that is different from the M cluster center data is determined as the fifth sample data.
[0137] As an example, NM first sample data different from M cluster center data are determined as the fifth sample data. For example, if the five first sample data are {sample 1, sample 2, sample 3, sample 4, sample 5}, and the two cluster center data are {sample 1, sample 2}, then the three fifth sample data are {sample 3, sample 4, sample 5}.
[0138] In step 2023, for each fifth sample data, the first cluster center data having the highest similarity to the fifth sample data is determined from the M cluster center data, and the fifth sample data is divided into the initial sample data set corresponding to the first cluster center data.
[0139] As an example, determine M similarities between the fifth sample data and M cluster center data respectively, and determine the cluster center data with similarity to the fifth sample data, determine the cluster center data with similarity to the fifth sample data as the first cluster center data, and divide the fifth sample data into the initial sample data set corresponding to the first cluster center data, wherein the method for calculating the similarity between the cluster center data and the fifth sample data can be referred to step 201 above and will not be repeated here.
[0140] In step 2024, after the N first sample data are divided, the M initial sample data sets divided with the fifth sample data are determined as M sample data sets.
[0141] Among them, one initial sample data set corresponds to one sample data set.
[0142] As an example, each fifth sample data among NM fifth sample data is divided into its corresponding initial sample data set to obtain M initial sample data sets, and the M initial sample data sets are determined as M sample data sets, wherein each sample data set in the M sample data sets includes at least one fifth sample data.
[0143] In the embodiment of the present application, by dividing the fifth sample data into the initial sample data set where the cluster center data with the highest similarity is located, the sample data sets have better discrimination.
[0144] In step 203 , the second sample data in each of the M sample data sets are divided into a training sample set.
[0145] As an example, based on the first division ratio, the second sample data in each sample data set in M sample data sets is determined, and the second sample data is divided into a training sample set, and the second sample data included in the training sample set is used to train the model, wherein the first division ratio is used to control the number of samples in the training sample set and can be configured by technical personnel.
[0146] For example, for three sample data sets, sample data set 1, sample data set 2 and sample data set 3, the first division ratio is ninety percent, ninety percent of the sample data in sample data set 1 is determined as the second sample data, ninety percent of the sample data in sample data set 2 is determined as the second sample data, and ninety percent of the sample data in sample data set 3 is determined as the second sample data, and the above-mentioned second sample data from sample data set 1, sample data set 2 and sample data set 3 are divided into the training sample set.
[0147] In an embodiment of the present application, by dividing the second sample data in each sample data set into the training sample set, diverse samples are injected into the training process of the model, thereby enhancing the generalization ability and adaptability of the model, helping to improve the performance of the model between different tasks, and at the same time helping to improve the model's ability to handle complex and dynamically changing scenarios, making the model more robust and reliable in practical applications.
[0148] In step 204 , the third sample data in each of the M sample data sets is divided into a validation sample set.
[0149] As an example, each sample data set in the M sample data sets includes second sample data and third sample data, the third sample data is different from the second sample data, the third sample data in each sample data set in the M sample data sets is determined, and the third sample data is divided into a verification sample set, and the third sample data included in the verification sample set is used to determine the measurement value of the subtask model.
[0150] For example, for three sample data sets, sample data set 1, sample data set 2, and sample data set 3, remove the second sample data from sample data set 1, and the remaining ten percent of the sample data are determined as the third sample data. Similarly, determine the third sample data in sample data set 2 and the third sample data in sample data set 3, and divide the third sample data into the verification sample set.
[0151] In an embodiment of the present application, by dividing the third sample data in each sample data set into the verification sample set, the independence and diversity of the data in the verification sample set are ensured, so that the verification sample set can cover a variety of different data situations, thereby providing a more comprehensive and realistic testing environment for the performance evaluation of the model.
[0152] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.
[0153] In the field of machine learning, machine learning models include single-task machine learning models and multi-task machine learning models (i.e., the models mentioned above). Single-task learning refers to designing a model for a specific task and then iteratively optimizing it. For slightly more complex tasks, each part of the task is generally modeled by decomposing the task. There is an obvious problem with single-task learning, that is, when modeling each subtask, it is easy to ignore the relationships, conflicts, and constraints between tasks, resulting in the overall effect of multiple tasks not being better; multi-task learning (i.e., model training) is a concept opposite to single-task learning. In multi-task learning, multiple related tasks (i.e., the network mentioned above) are often put together for learning. For example, in a recommendation system, the ranking model simultaneously estimates the click-through rate and browsing time of the candidate. Therefore, multi-task learning has the following advantages over single-task learning: multiple tasks share a model, which reduces the amount of memory used; multiple tasks are forward-calculated at one time to obtain results, which increases the inference speed; related tasks can improve each other's performance by sharing information and complementing each other.
[0154] However, in related technologies, some tasks in multi-task learning converge quickly, while others converge slowly or even stagnate, and different tasks cannot be learned at a similar speed; or the training data is single, affecting the generalization performance of the model and the mutual promotion of related tasks; or the difficulty of each task is different, resulting in inconsistent convergence between tasks.
[0155] To solve the above problems, the present invention proposes a model processing method to improve the learning performance of the multi-task model. The present invention proposes a model processing method including a data diversity processing module and a model optimization module. The following will describe the above two models.
[0156] 1) Data diversity processing module
[0157] See also Figure 8 , Figure 8 This is the sixth flow chart of the model processing method provided in an embodiment of the present application. Data diversity processing can be implemented by following steps 1 to 4, which are described in detail below.
[0158] Step 1: Determine the first seed point (i.e. the cluster center data above).
[0159] Determine the first seed point k1. Assume that there are N samples (i.e., the N first sample data above), namely t1, t2, ..., t N , randomly select a sample from N samples as the first seed point k1.
[0160] Among them, N samples are shared by multiple tasks. For example, suppose there are two tasks, one is a sentiment classification task and the other is an entity recognition task. For a text sample, in the sentiment classification task, the sample label (that is, the label information above) can be one of positive, negative, and neutral; in the entity recognition task, the sample label is one of entities such as a person's name and a place name.
[0161] Step 2: Determine the remaining m-1 seed points.
[0162] From the remaining N-1 samples, determine the remaining m-1 seed points k2, ..., k m First, determine the sample with the largest distance from the seed point K1 as the second seed point K2; then, from the remaining N-2 samples, determine the sample with the largest sum of distances from the seed point K1 and the seed point K2 as the third seed point K3 (that is, the sum of the distance from the seed point K3 to the seed point K1 and the distance from the seed point K3 to the seed point K2 is the largest); and so on, construct M seed points (that is, the M cluster center data above), where the distance between seed points refers to the cosine distance, Euclidean distance, etc. between the text representations of the seed points (that is, the encoding features above). The text representations of the seed points can be obtained by encoding the seed points through methods such as BERT and Word2VEC. The distance between the seed points is the similarity between the sample data above. The closer the distance between the seed points, the higher the similarity between the sample data above.
[0163] When the value of m satisfies the condition for stopping seed point construction, the seed point construction is stopped. The condition formula (1.4) for stopping seed point construction is as follows:
[0164]
[0165] Among them, d(k m+1 ,k i ) represents the seed point k m+1 With seed point k i The distance between them; d(t i ,t j ) represents sample t i With sample t j the distance between them; represents the seed point k m+1 With seed points k1, k2, ..., k m the average of the sums of distances; It represents the average value of the sum of the distances between any two samples in N samples.
[0166] Explanation of formula (1.4): Formula (1.4) indicates that if the average distance from the m+1th seed point to the m constructed seed points is less than 2 times the average distance between any two samples in the N samples, the m+1th seed point is considered unsuitable as a seed point, so a total of m seed points are obtained.
[0167] Regarding the selection of the number of seed points, the embodiment of this application uses "the average value of the distance between any two samples in 2 times the N samples" as the threshold (i.e., the similarity threshold above). If the distance between m seed points is less than the threshold, it means that the distance between the m seed points is large enough and has sufficient discrimination; otherwise, it means that the distance between the m seed points is insufficient and does not have good discrimination.
[0168] Step 3: Based on the m seed points, determine m sample sets (ie, the sample data set mentioned above).
[0169] The remaining Nm samples are divided into different sample sets according to the distance from the m seed points (that is, for each sample in the remaining Nm samples, the sample with the smallest distance from the seed point is divided into the sample set where the seed point is located), and m sample sets are obtained.
[0170] For N samples, it is impossible to determine how many categories are most appropriate to divide the N samples into. Too many or too few seed points are not optimal. Therefore, before classifying the samples based on the seed points, the embodiment of the present application first ensures that the seed points have good discrimination.
[0171] Step 4: Determine the training set (ie, the training sample set mentioned above) and the test set (ie, the verification sample set mentioned above; in this embodiment of the present application, the test set and the verification sample set are the same data set).
[0172] 90% of the samples are randomly selected from each of the m sample sets to form the training set, and the remaining 10% of the samples in each sample set to form the test set.
[0173] After the remaining Nm samples are divided into sets corresponding to different seed points according to their distance, each set is regarded as a category, and then a certain amount of data is selected from each category to form a training set, thus ensuring the data diversity of the training set.
[0174] 2) Model optimization module.
[0175] See also Figure 9 The multi-task model in the embodiment of the present application includes n tasks, namely task 1, task 2, ..., task n, and the corresponding loss functions are loss1, loss2, ..., loss nIn the multi-task model, the parameter sharing layer refers to the model parameters shared by all tasks, and the parameter exclusive layer refers to the model parameters unique to each different task.
[0176] First, see Figure 9 , input the i-th training sample, pass through the parameter sharing layer, and obtain the text representation vector V (that is, the output feature v of the parameter sharing layer above), and pass through n parameter exclusive layers to obtain the text representation vectors v1, v2, ..., v respectively. n .
[0177] Then, refer to the loss function formula (1.2) above to calculate the loss of the multi-task model on the i-th training sample (i.e., the first loss value above).
[0178] Among them, L i represents the sum of the losses of the i-th sample on n tasks, l j,i represents the loss of the i-th sample on the j-th task, w j,i represents the weight coefficient corresponding to the loss function of the jth task when training the i-th sample (i.e., the loss weight value above), w j,i The calculation formula of is shown in formula (1.1) above.
[0179] Among them, p j,i-1 It represents the accuracy of the j-th task on the test set after training the i-1-th sample (i.e., the measurement rate above). The accuracy is the number of correctly predicted samples divided by the total number of predicted samples. For example, when the i-1-th sample is trained, multiple tasks are predicted based on 100 test samples, and 90 sample data are obtained for the j-th task to be predicted correctly. Then the accuracy of the model on the j-th task is 90%.
[0180] Formula explanation: |l j,q -l j,q-1 | represents the absolute value of the difference between the loss values of the qth sample and the q-1th sample on the jth task (i.e., the loss difference between the two adjacent constructed loss values above), which measures the contribution of the qth sample to the loss of the jth task; It represents the sum of the absolute value of the difference between the losses of two adjacent samples on the jth task in the first i training samples; It measures the average convergence speed of the jth task on the first i training samples (i.e., the convergence speed mentioned above). The larger the average convergence speed value, the faster the convergence speed of the jth task. Therefore, it is placed in the denominator to slow down the convergence speed of the jth task. Similarly, the smaller the average convergence speed value, the slower the convergence speed of the jth task. Therefore, it is placed in the denominator to speed up the convergence speed of the jth task. The numerator uses l j,i The purpose is to j,iThe smaller the value, the faster the convergence speed of the j-th task. Therefore, putting it in the numerator can slow down the convergence speed of the j-th task. Similarly, l j,i The larger it is, the slower the convergence speed of the j-th task is. Therefore, putting it in the numerator can accelerate the convergence speed of the j-th task.
[0181] For tasks with faster convergence speed, The larger the l j,i The smaller the value is, the slower the convergence speed of the task will be. Therefore, for tasks with faster convergence speed, The smaller the value of is, the smaller the weight is added to the task with faster convergence speed, so It plays a role in balancing the convergence speed between tasks.
[0182] p j,i-1 The larger the value of , the better the training effect of the corresponding task, that is, the smaller the training difficulty of the task, so it is necessary to give the task a smaller weight. j,i-1 The larger the value of -logp j,i-1 The smaller the value of , the smaller the weight given to tasks with lower difficulty, so -logp j,i-1 It plays a role in balancing the difficulty of tasks.
[0183] In summary, the weight coefficient w j,i It can effectively balance the convergence speed and difficulty between tasks and improve the overall performance of the multi-task model.
[0184] Finally, based on the loss function value (i.e. the total loss value above), update the parameters of the parameter-shared layer and the parameter-exclusive layer, and repeat the above steps until the training is completed.
[0185] Below, an exemplary application of the embodiment of the present application in an application scenario of a conversational robot system will be described.
[0186] A conversational robot system includes multiple different types of tasks, such as entity recognition tasks, sentiment calculation tasks, similarity calculation tasks, intent recognition tasks, etc. In such a complex system, if each task is deployed using an independent model, it will take up a huge amount of memory, thereby increasing the reasoning time of the entire system, resulting in extremely high system complexity and poor user experience.
[0187] Some tasks are related to each other, such as entity extraction and intent recognition. Therefore, a model can be shared by multiple tasks to solve the problems of large memory usage and slow inference speed.
[0188] Specifically, first, the sample set is processed according to the scheme proposed in the data diversity processing module to ensure the diversity of the training set and the test set. The diversity of the training set helps to improve the generalization of the model and the mutual promotion between tasks. The diversity of the test set helps to accurately evaluate the difficulty of the task and the effect of the model. Then, the model training and loss function optimization are carried out according to the scheme in the model optimization module. A dynamic weight coefficient is designed for the loss function of each task. The weight coefficient w j,i It can effectively balance the convergence speed and difficulty between tasks and improve the overall performance of the multi-task model.
[0189] Through the embodiments of the present application, the following effects can be produced: the embodiments of the present application propose a model processing method, design a sample diversity processing method, and optimize the loss function, which can significantly improve the learning performance of the multi-task model; by performing diversity processing on the sample set, the diversity of the training set and the test set is ensured. The diversity of the training set helps to improve the generalization of the model and the mutual promotion between tasks. The diversity of the test set helps to accurately evaluate the difficulty of the task and the effect of the model; during the training process, by optimizing the loss function, the convergence speed and difficulty between tasks can be effectively balanced, avoiding the problem that some tasks converge quickly while other tasks converge very slowly or even stagnate, thereby improving the overall performance of the multi-task model.
[0190] The following continues to describe the exemplary structure of the model processing device 555 provided in the embodiment of the present application as a software module. In some embodiments, such as Figure 2 As shown, the software modules stored in the model processing device 555 of the memory 550 may include:
[0191] The loss value determination module 5551 is used to determine the loss value of each network in the multiple networks included in the model during the i-th iterative training process of the model to obtain multiple first loss values.
[0192] The loss weight determination module 5552 is used to determine the convergence speed of the network for each of the networks based on the first loss value and the second loss value of the network, wherein the second loss value includes the loss value determined by the network during the first i-1 iterative training of the model.
[0193] The loss weight determination module 5552 is further configured to determine, for each network, a loss weight value of the network based on the measurement value of the network and the convergence speed.
[0194] The back propagation module 5553 is used to update the parameters of the model based on the multiple loss weight values and the multiple first loss values.
[0195] In some embodiments, the loss weight determination module 5552 is further used to determine multiple loss differences based on the first loss value and the second loss value of the network, wherein the loss difference is determined based on the loss values obtained from two adjacent iterative trainings; and based on the multiple loss differences, determine the convergence speed of the network.
[0196] In some embodiments, the loss weight determination module 5552 is also used to determine the ratio of the first loss value to the convergence rate; perform a numerical transformation on the measurement value to obtain a first numerical value, wherein, when the measurement value is positively correlated with the convergence rate, the first numerical value is negatively correlated with the measurement value; when the measurement value is negatively correlated with the convergence rate, the first numerical value is positively correlated with the measurement value; based on the ratio and the first numerical value, determine the loss weight value, wherein the loss weight value is positively correlated with the ratio and the first numerical value, respectively.
[0197] The model processing device 555 provided in the embodiment of the present application may also include a sample construction module, wherein the sample construction module is used to screen out M cluster center data from N first sample data, wherein N is an integer greater than M, M is an integer greater than 0, and the similarity between any two cluster center data in the M cluster center data is greater than a similarity threshold; based on the M cluster center data, the N first sample data are divided into M sample data sets; the second sample data in each sample data set in the M sample data sets is divided into a training sample set, wherein the second sample data included in the training sample set is used to train the model; the third sample data in each sample data set in the M sample data sets is divided into a verification sample set, wherein the third sample data is different from the second sample data, and the third sample data included in the verification sample set is used to determine the measurement value of the network.
[0198] In some embodiments, the sample construction module is also used to determine one of the N first sample data as the first cluster center data; among the N first sample data, the first sample data different from the first m cluster center data is determined as Nm fourth sample data, where m is an integer that increases successively, 1≤m<M; among the Nm fourth sample data, the fourth sample data with the smallest sum of m similarities with the first m cluster center data is determined as the m+1th cluster center data.
[0199] In some embodiments, the sample construction module is also used to construct M initial sample data sets based on the M cluster center data, wherein the M cluster center data correspond one-to-one to the M initial sample data sets; among the N first sample data, the first sample data different from the M cluster center data is determined as the fifth sample data; for each fifth sample data, the first cluster center data with the highest similarity to the fifth sample data is determined from the M cluster center data, and the fifth sample data is divided into the initial sample data set corresponding to the first cluster center data; after the N first sample data are divided, the M initial sample data sets divided with the fifth sample data are determined as the M sample data sets, wherein one initial sample data set corresponds to one sample data set.
[0200] The present invention provides a computer program product including a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the model processing method described in the present invention.
[0201] The embodiment of the present application provides a computer-readable storage medium in which computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will execute the model processing method provided in the embodiment of the present application, for example, Figures 3 to 7 The model processing method shown.
[0202] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0203] In some embodiments, computer-executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0204] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (e.g., files storing one or more modules, subroutines, or code portions).
[0205] By way of example, computer-executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.
[0206] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.
Claims
1. A model processing method, characterized in that: The method comprises: During the i-th iterative training of the model, determining a loss value of each of the multiple networks included in the model to obtain multiple first loss values; For each of the networks, determining a convergence rate of the network based on the first loss value and the second loss value of the network, wherein the second loss value comprises a loss value of the network determined during a first i-1 iterations of training of the model; For each of the networks, determining a loss weight value of the network based on the measurement value of the network and the convergence speed; Based on the plurality of loss weight values and the plurality of first loss values, the parameters of the model are updated.
2. The method according to claim 1, characterized in that The determining the convergence speed of the network based on the first loss value and the second loss value of the network includes: Determining a plurality of loss differences based on the first loss value and the second loss value of the network, wherein the loss differences are determined based on loss values obtained from two adjacent iterative trainings; A convergence speed of the network is determined based on the multiple loss differences.
3. The method according to claim 1, characterized in that The determining of the loss weight value of the network based on the measurement value of the network and the convergence speed includes: determining a ratio of the first loss value to the convergence rate; Performing a numerical transformation on the measurement value to obtain a first numerical value, wherein, when the measurement value is positively correlated with the convergence rate, the first numerical value is negatively correlated with the measurement value; and when the measurement value is negatively correlated with the convergence rate, the first numerical value is positively correlated with the measurement value; Based on the ratio and the first numerical value, the loss weight value is determined, wherein the loss weight value is positively correlated with the ratio and the first numerical value, respectively.
4. The method according to claim 1, wherein The method further comprises: Filtering M cluster center data from N first sample data, where N is an integer greater than M, M is an integer greater than 0, and the similarity between any two cluster center data in the M cluster center data is greater than a similarity threshold; Based on the M cluster center data, the N first sample data are divided into M sample data sets; dividing the second sample data in each sample data set in the M sample data sets into a training sample set, wherein the second sample data included in the training sample set is used to train the model; The third sample data in each of the M sample data sets is divided into a validation sample set, wherein the third sample data is different from the second sample data, and the third sample data included in the validation sample set is used to determine the measurement value of the network.
5. The method according to claim 4, characterized in that The step of selecting M cluster center data from N first sample data includes: Determine one of the N first sample data as the first cluster center data; Among the N first sample data, first sample data different from the first m cluster center data are determined as Nm fourth sample data, where m is an integer that increases in sequence, and 1≤m<M; Among the Nm fourth sample data, the fourth sample data having the smallest sum of m similarities with the first m cluster center data is determined as the (m+1)th cluster center data.
6. The method according to claim 4, characterized in that The dividing the N first sample data into M sample data sets based on the M cluster center data includes: Based on the M cluster center data, construct M initial sample data sets, wherein the M cluster center data have a one-to-one correspondence with the M initial sample data sets; Among the N first sample data, determining the first sample data different from the M cluster center data as the fifth sample data; For each fifth sample data, determine the first cluster center data having the highest similarity to the fifth sample data from the M cluster center data, and divide the fifth sample data into the initial sample data set corresponding to the first cluster center data; After the N first sample data are divided, the M initial sample data sets divided with the fifth sample data are determined as the M sample data sets, wherein one initial sample data set corresponds to one sample data set.
7. A model processing device, characterized in that: The device comprises: a loss value determination module, configured to determine the loss value of each of the multiple networks included in the model during the i-th iterative training process of the model, to obtain multiple first loss values; a loss weight determination module, configured to determine, for each of the networks, a convergence rate of the network based on the first loss value and the second loss value of the network, wherein the second loss value comprises the loss value of the network determined during the first i-1 iterations of training of the model; The loss weight determination module is further configured to determine, for each of the networks, a loss weight value of the network based on the measurement value of the network and the convergence speed; A back propagation module is used to update the parameters of the model based on the multiple loss weight values and the multiple first loss values.
8. An electronic device, characterized in that: The electronic device comprises: a memory for storing computer-executable instructions or computer programs; A processor is configured to implement the model processing method according to any one of claims 1 to 6 when executing the computer executable instructions or computer program stored in the memory.
9. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the model processing method according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the model processing method according to any one of claims 1 to 6 is implemented.