Model reasoning method and device based on continuous learning and storage medium

By using the correlation between the memory data set and the model output data to determine the inference results in continuous learning, the problem of storage burden and reduced reasoning efficiency caused by the increase in model tasks is solved, and efficient model reasoning is achieved.

CN118780333APending Publication Date: 2024-10-15TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310390229.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-04
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

Existing continuous learning methods need to save multiple output layer parameters when the number of model tasks increases, causing the model to become bloated and affecting inference efficiency.

Method used

By obtaining the data of the target inference task and inputting it into the trained neural network model, the inference results are determined by using the correlation between the cluster feature data in the memory data set and the model output data, avoiding the need to reconstruct the output layer and reducing the storage burden.

Benefits of technology

It improves model inference efficiency, avoids performance degradation caused by increased storage burden, and improves model scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118780333A_ABST
    Figure CN118780333A_ABST
Patent Text Reader

Abstract

The invention discloses a model reasoning method and device based on continuous learning and a storage medium. The method comprises the steps of obtaining a target reasoning task and reasoning data corresponding to the target reasoning task; inputting the reasoning data into the trained neural network model to obtain model output data; acquiring associated memory data associated with the target reasoning task from the memory data set; determining a plurality of target memory data in the associated memory data according to an association relationship between the associated memory data and the model output data; and determining a reasoning result based on the label data corresponding to the multiple pieces of target memory data. The method can improve the efficiency of model reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to a model reasoning method, device and storage medium based on continuous learning. Background Art

[0002] In recent years, with the continuous development of Internet technology, the data in the Internet has also shown an explosive growth. In machine learning algorithms, it is difficult for training data and test data to achieve a state of similar distribution, and general machine learning algorithms are also difficult to continuously and adaptively learn in a dynamic environment. Therefore, scholars have proposed continuous learning algorithms to solve the above problems. Among them, continuous learning (CL), also known as continuous learning or lifelong learning. Continuous learning simulates the learning and thinking mode of the human brain and can learn non-independent and identically distributed data streams. Its essence is that it can not only utilize the incoming new data, and based on the experience accumulated from previous tasks, it can complete the task well on the new data; it can also avoid the problem of forgetting and maintain high accuracy for tasks that have been trained.

[0003] However, in the related art, the continuous learning method requires an output layer for each task (for example, a classification task requires a classification layer) to solve the task, and different weights are required to construct the output layer for different tasks to adapt to new tasks. As the number of model tasks for continuous learning increases, the parameters of the output layer that the model needs to save will gradually increase the storage burden, which will make the model bloated, thereby affecting the model's reasoning efficiency. Summary of the invention

[0004] The embodiments of the present application provide a model reasoning method, device and storage medium based on continuous learning, which can improve the reasoning efficiency of model reasoning based on continuous learning.

[0005] The first aspect of the present application provides a model reasoning method based on continuous learning, the method comprising:

[0006] Obtaining a target reasoning task and reasoning data corresponding to the target reasoning task;

[0007] Inputting the inference data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple inference tasks, wherein the multiple inference tasks include the target inference task;

[0008] Acquire associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features of corresponding training sample data by a trained task model during continuous learning of the task model;

[0009] Determining a plurality of target memory data in the associated memory data according to an association relationship between the associated memory data and the model output data;

[0010] An inference result is determined based on the label data corresponding to the multiple target memory data.

[0011] Accordingly, the second aspect of the present application provides a model reasoning device based on continuous learning, the device comprising:

[0012] A first acquisition unit, used to acquire a target reasoning task and reasoning data corresponding to the target reasoning task;

[0013] An input unit, used to input the reasoning data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, wherein the multiple reasoning tasks include the target reasoning task;

[0014] A second acquisition unit is used to acquire associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features of corresponding training sample data by a trained task model during continuous learning of the task model;

[0015] A first determining unit, configured to determine a plurality of target memory data in the associated memory data according to an association relationship between the associated memory data and the model output data;

[0016] The second determining unit is used to determine the inference result based on the label data corresponding to the multiple target memory data.

[0017] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0018] A first acquisition subunit is used to acquire training sample data sets corresponding to multiple reasoning tasks to obtain multiple training sample data sets;

[0019] The training subunit is used to train the task models corresponding to the multiple reasoning tasks in turn using the training sample data set corresponding to each reasoning task to obtain a trained neural network model.

[0020] Optionally, in some embodiments, the multiple reasoning tasks are arranged in a preset order, and the training subunit includes:

[0021] A first acquisition module, used to acquire a target training sample data set for training the task model, wherein the target training sample data set is a training sample data set corresponding to a current reasoning task, and the current reasoning task is a first reasoning task among the multiple reasoning tasks;

[0022] A training module, used for training the task model according to the target training sample data set;

[0023] an execution module, configured to, when the current reasoning task is not the last reasoning task among the multiple reasoning tasks, obtain a next second reasoning task and use the second reasoning task to update the current reasoning task, and return to execute the step of obtaining a target training sample data set for training the task model, and training the task model according to the target training sample data set;

[0024] The termination module is used to terminate the training of the task model when the current reasoning task is the last reasoning task among the multiple reasoning tasks, so as to obtain a trained neural network model.

[0025] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0026] Constructing subunits for constructing memory data sets;

[0027] Training modules include:

[0028] A training submodule, used for training the task model according to the memory data set and the target training sample data set;

[0029] The updating submodule is used to extract features from the training sample data in the target training sample data set using the trained task model, and to update the memory data set based on the extracted features.

[0030] Optionally, in some embodiments, the training submodule is further used to:

[0031] Obtaining a round of training for the task model, and obtaining batch sample data from the target training sample data set;

[0032] When the round is not an integer multiple of the preset number of times, training the task model according to the batch sample data;

[0033] When the round is an integer multiple of the preset number of times, training the task model according to the batch sample data and the memory data in the memory data set;

[0034] The task model is updated in a loop by obtaining batch sample data from the target training sample data set, and when the round is not an integer multiple of a preset number of times, the task model is trained according to the batch sample data; and when the round is an integer multiple of the preset number of times, the task model is trained according to the batch sample data and the memory data in the memory data set.

[0035] Optionally, in some embodiments, the training submodule is further used to:

[0036] Inputting the batch sample data into the task model, and calculating a contrastive learning loss based on an output of the task model and label data in the batch sample data;

[0037] The parameters of the task model are updated based on the contrastive learning loss.

[0038] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0039] A first calculation subunit is used to calculate the instance relationship distillation loss when the current reasoning task is not the first reasoning task among the multiple reasoning tasks, wherein the instance relationship distillation loss is used to constrain the difference between task models trained based on training sample data sets corresponding to different reasoning tasks;

[0040] The training submodule is further used for:

[0041] Calculating a target loss based on the contrastive learning loss and the instance relation distillation loss;

[0042] Parameters of the task model are updated based on the target loss.

[0043] Optionally, in some embodiments, the first computing subunit includes:

[0044] A second acquisition module is used to acquire a sample feature set corresponding to each reasoning task when the current reasoning task is not the first reasoning task among the multiple reasoning tasks, wherein the sample feature is a feature obtained by extracting features from corresponding training sample data using the trained task model after training the task model;

[0045] The calculation module is used to calculate the instance relationship distillation loss based on the similarity relationship between sample features corresponding to similar labels in different sample feature sets.

[0046] Optionally, in some embodiments, the updating submodule is further used to:

[0047] Using the trained task model to extract features from the target training sample data to obtain multiple sample features;

[0048] Performing feature clustering on the multiple sample features based on the label data corresponding to the multiple sample features, and determining multiple target sample features from the multiple sample features according to the clustering result;

[0049] The multiple target sample features are added to the memory data set to update the memory data set.

[0050] Optionally, in some embodiments, the first determining unit includes:

[0051] A second calculation subunit, used for calculating the similarity between each memory data in the associated memory data and the model output data;

[0052] A determination subunit is used to determine multiple target memory data in the associated memory data according to the similarity.

[0053] Optionally, in some embodiments, the second determining unit includes:

[0054] A second acquisition subunit is used to acquire label data corresponding to the plurality of target memory data to obtain a plurality of label data;

[0055] The processing subunit is used to perform clustering processing on the multiple label data and determine the label corresponding to the category with the largest number of labels as the inference result.

[0056] The third aspect of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in the model inference method based on continuous learning provided in the first aspect of the present application.

[0057] The fourth aspect of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the model inference method based on continuous learning provided in the first aspect of the present application when executing the computer program.

[0058] The fifth aspect of the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in the model inference method based on continuous learning provided in the first aspect.

[0059] The model inference method based on continuous learning provided in the embodiment of the present application obtains a target inference task and inference data corresponding to the target inference task; inputs the inference data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple inference tasks, and the multiple inference tasks include the target inference task; obtains associated memory data associated with the target inference task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features from corresponding training sample data by the trained task model during the continuous learning process of the task model; determines multiple target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data; and determines the inference result based on the label data corresponding to the multiple target memory data.

[0060] In this way, the model reasoning method based on continuous learning provided by the present application, when continuously learning the multi-task model, not only outputs the trained neural network model, but also outputs a memory data set for assisting model reasoning. When model task reasoning is required, the neural network model obtained by continuous learning can be used to extract features from the reasoning data to obtain model output data, and then the final reasoning result is determined based on the similarity relationship between the model output data and the memory data set corresponding to the model reasoning task. In this way, there is no need to construct a model output layer, which avoids the problem of increasing the storage burden due to the increase in model tasks, which in turn affects the efficiency of model reasoning. Thereby, the efficiency of model reasoning can be greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0062] Figure 1 This is a schematic diagram of a scenario of model reasoning based on continuous learning in this application;

[0063] Figure 2 It is a flowchart of the model reasoning method based on continuous learning provided by this application;

[0064] Figure 3 It is a schematic diagram of data flow during model training;

[0065] Figure 4 It is a schematic diagram of data flow during model reasoning;

[0066] Figure 5 is another flowchart of the model reasoning method based on continuous learning provided by the present application;

[0067] Figure 6 It is a structural diagram of a model reasoning device based on continuous learning provided by the present application;

[0068] Figure 7 It is a structural schematic diagram of the computer device provided by this application. DETAILED DESCRIPTION

[0069] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0070] The embodiment of the present invention provides a model reasoning method, device and storage medium based on continuous learning. Among them, the model reasoning method based on continuous learning can be used in a model reasoning device based on continuous learning. The model reasoning device based on continuous learning can be integrated in a computer device, which can be a terminal or a server. Among them, the terminal can be a mobile phone, a tablet computer, a laptop computer, a smart TV, a wearable smart device, a personal computer (PC, Personal Computer) and other devices. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Among them, the server can be a node in a blockchain.

[0071] See also Figure 1, which is a schematic diagram of a scenario of the model reasoning method based on continuous learning provided by the present application. As shown in the figure, the model reasoning method based on continuous learning provided by the present application can be applied to a terminal A equipped with a model reasoning device based on continuous learning, and the terminal A obtains the target reasoning task and the reasoning data corresponding to the target reasoning task; the reasoning data is input into the trained neural network model to obtain the model output data, and the neural network model is a neural network model obtained by continuously learning the task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; the associated memory data associated with the target reasoning task is obtained from the memory data set, and the data in the memory data set is the data obtained by clustering the feature data, and the feature data is the data obtained by extracting the features of the corresponding training sample data by the trained task model during the continuous learning process of the task model; according to the association relationship between the associated memory data and the model output data, multiple target memory data are determined in the associated memory data; the reasoning result is determined based on the label data corresponding to the multiple target memory data.

[0072] It should be noted that Figure 1 The schematic diagram of the model reasoning scenario based on continuous learning is only an example. The model reasoning scenario based on continuous learning described in the embodiment of the present application is to more clearly illustrate the technical solution of the present application and does not constitute a limitation on the technical solution provided by the present application. A person of ordinary skill in the art will know that with the evolution of the model reasoning scenario based on continuous learning and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.

[0073] Based on the above implementation scenarios, detailed descriptions are given below.

[0074] The embodiments of the present application will be described from the perspective of a model reasoning device based on continuous learning, which can be integrated in a computer device. The computer device can be a terminal or a server. The terminal can be a mobile phone, a tablet computer, a laptop computer, a smart TV, a wearable smart device, a personal computer (PC) and other devices. The server 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, network acceleration services (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms. Figure 2 As shown, it is a flow chart of the model reasoning method based on continuous learning provided by the present application, and the method comprises:

[0075] Step 101, obtaining a target reasoning task and reasoning data corresponding to the target reasoning task.

[0076] Among them, in the related art, the important evaluation indicators of the traditional task continuous learning method include plasticity and stability. Plasticity refers to the ability to learn new data and to complete tasks well on new data; stability refers to maintaining a high accuracy for tasks that have been trained, that is, avoiding the problem of catastrophic forgetting. In the related art, the continuous learning methods under a fixed model structure can be mainly divided into regularization-based methods and replay-based methods. Among them, the regularization-based method controls the drift of sentence representation by designing regularization terms, thereby maintaining the effect of the original task. The replay-based method saves data samples from previous tasks into a memory buffer, and retrains the model to restore knowledge during the training process of the current task.

[0077] However, the model learned by the continuous learning method in the related art needs to be equipped with an output layer for each model task. When performing model reasoning corresponding to the model task, the output layer can be used to input the reasoning result corresponding to the task. For different model tasks, different weights are also needed to construct the output layer to adapt to different model tasks. In this way, as the number of model tasks increases, the parameters of the output layer that the model needs to save will also increase greatly, which will cause a huge storage burden, and then lead to a decrease in the reasoning efficiency of the model. In this regard, in order to solve the problem that the above-mentioned continuous learning model needs to adapt the corresponding model output layer to each model task, resulting in a decrease in the model reasoning efficiency, the present application provides a model reasoning method based on continuous learning. The method is described in detail below.

[0078] When a model inference request is received, the specific inference task and the corresponding inference data in the model inference request can be obtained first. The inference task in the model inference request can be a target inference task, which is one of the preset multiple inference tasks. The preset multiple inference tasks here can be multiple inference tasks for continuous learning of the model. For example, the multiple inference tasks include image recognition tasks, image classification tasks, image detection tasks, and image segmentation tasks. When the model is continuously learned, the model can be trained with the training sample data corresponding to the image recognition task first, so that the model can learn to obtain the ability of image recognition; then the model can be further trained with the training sample data corresponding to the image classification task, so that the model can learn to obtain the ability of image classification; then the model can be continuously learned with the training sample data corresponding to other image processing tasks one by one, so that the model can learn to obtain other image processing capabilities. After the model is continuously learned, the model obtained by continuous learning can be used to process the corresponding task, that is, the model can be used for image recognition, image classification, or image segmentation. Specifically, the target inference task here can be an image classification task. Then the corresponding inference data can be the image to be classified. The several image processing tasks listed here are only examples of the above-mentioned preset multiple reasoning tasks. The preset multiple reasoning tasks can also be other forms of processing tasks such as language processing tasks and text processing tasks, which are not specifically limited here.

[0079] Step 102, input the inference data into the trained neural network model to obtain model output data.

[0080] Among them, after obtaining the target reasoning task and the corresponding reasoning data in the reasoning request, the trained neural network model can be used to reason about the reasoning data. In an embodiment of the present application, the trained neural network model can specifically be an encoder, which can be used to perform feature encoding on the reasoning data to be subjected to model reasoning to obtain model output data. Among them, the trained neural network model here can be a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks here include the above-mentioned target reasoning task. As described in the actual examples given above, it will not be repeated here.

[0081] It is understandable that before receiving the model inference request, the neural network model needs to be trained first, that is, before obtaining the target inference task and the inference data corresponding to the target inference task, it also includes:

[0082] 1. Obtain training sample data sets corresponding to multiple reasoning tasks to obtain multiple training sample data sets;

[0083] 2. Use the training sample data set corresponding to each reasoning task in turn to train the task models corresponding to multiple reasoning tasks to obtain a trained neural network model.

[0084] Among them, in an embodiment of the present application, continuous learning can be to use training sample data sets corresponding to multiple reasoning tasks to train task models corresponding to these reasoning tasks. Here, the multiple reasoning tasks can be the multiple image processing tasks, speech processing tasks, or text processing tasks listed above. The acquisition of training sample data sets corresponding to multiple reasoning tasks can be simultaneous acquisition or one by one in a certain time sequence, so as to obtain multiple training sample data sets. It can be understood that each training sample data set in the multiple training sample data sets corresponds to an reasoning task.

[0085] The training sample data set corresponding to each reasoning task may include a plurality of training sample data of the corresponding reasoning task, and the training sample data may include sample images, sample voices or sample texts and label data corresponding to each sample.

[0086] After obtaining one or more training sample data sets in the training sample data sets corresponding to multiple reasoning tasks, the task model can be trained using the obtained training sample data sets. Among them, since the task model is trained using a continuous learning method, the task model can be trained using the training sample data sets corresponding to each reasoning task one by one. Specifically, the training sample data sets corresponding to multiple reasoning tasks can be obtained one by one. When a training sample data set corresponding to a reasoning task is obtained, the task model can be trained using the training sample data set corresponding to the reasoning task; then the training sample data set corresponding to the next reasoning task is obtained, and the task model is trained according to the training sample data set corresponding to the next reasoning task; the training sample data sets corresponding to the new reasoning task are obtained in this way, and the task model is trained using the newly obtained training sample data sets. Alternatively, the training sample data sets corresponding to all reasoning tasks can be obtained at one time, and then the arrangement order of the multiple reasoning tasks can be determined, and the task model is trained using the corresponding training sample data sets in sequence according to the arrangement order of the reasoning tasks.

[0087] In some embodiments, the task models corresponding to the multiple reasoning tasks are trained in turn using the training sample data set corresponding to each reasoning task to obtain the trained neural network model, including:

[0088] 2.1. Obtain a target training sample data set for training the task model, where the target training sample data set is a training sample data set corresponding to the current reasoning task, and the current reasoning task is a first reasoning task among multiple reasoning tasks;

[0089] 2.2. Train the task model according to the target training sample data set;

[0090] 2.3. When the current reasoning task is not the last reasoning task among the multiple reasoning tasks, obtain the next second reasoning task and use the second reasoning task to update the current reasoning task, and return to execute the steps of obtaining a target training sample data set for training the task model, and training the task model according to the target training sample data set;

[0091] 2.4. When the current reasoning task is the last reasoning task among multiple reasoning tasks, the training of the task model is terminated to obtain the trained neural network model.

[0092] Among them, in an embodiment of the present application, when the task model is trained using a training sample data set corresponding to multiple reasoning tasks, continuous learning of the task model can be automatically achieved. Specifically, the task model that is sorted first can be used as the current task model, and then the target training sample data set corresponding to the current task model can be obtained to train the task model. After the task model is trained using the target training sample data set corresponding to the current task model, it can be automatically detected whether the current reasoning task is the last reasoning task in the sorting sequence. If not, a reasoning task after the reasoning task in the sorting sequence can be obtained, and the newly obtained reasoning task can be used as the current reasoning task, and the step of obtaining the target training sample data set of the current reasoning task and using the obtained target training sample data set to train the task model is returned. If it is detected that the current reasoning task is the last reasoning task in the sorting sequence, it means that the training of the task model is completed, and the trained neural network model can be output.

[0093] Among them, in some embodiments, the model reasoning method based on continuous learning provided by the present application also includes:

[0094] a. Construct a memory data set;

[0095] The task model is trained according to the target training sample data set, including:

[0096] b. Train the task model based on the memory data set and the target training sample data set;

[0097] c. Use the trained task model to extract features from the training sample data in the target training sample data set, and update the memory data set based on the extracted features.

[0098] Among them, in an embodiment of the present application, in order to avoid the problem of catastrophic forgetting that occurs during continuous learning and to improve the stability of the model obtained by continuous learning, a memory data set can be constructed in the process of training the task model using multiple training sample data sets. Among them, the memory data set here can be specifically obtained by extracting features from the sample data using the trained task model after each training of the task model according to the training sample data set corresponding to a task model, and then clustering the extracted features. Among them, the clustering process here can specifically be clustering using the kmeans algorithm. Moreover, the memory data in the constructed memory data set can also be further involved in the process of training the task model using the training sample data set corresponding to the next reasoning task, thereby realizing the memory replay of the model.

[0099] Specifically, the initially constructed memory data set can be an empty set, and can be constructed before the task model is trained using the training sample data set. Then, the task model is trained using the training sample data set corresponding to the first reasoning task to obtain a trained task model. Furthermore, the trained task model can be used to extract features from the training sample data set corresponding to the first reasoning task to obtain sample features. Then, the kmeans algorithm can be used to cluster the obtained sample features, thereby filtering out several sample features from multiple sample features, and storing the filtered sample features in the memory data set to update the memory data set.

[0100] Furthermore, when the training sample data set corresponding to the next reasoning task is obtained and the task model is trained accordingly, the training sample data set corresponding to the next reasoning task and the updated memory data set can be used to train the task model. After the trained task model is obtained, the trained task model can continue to be used to extract features from the training sample data of the reasoning task, cluster to obtain sample features, and use the sample features to add to the memory data set to further update the memory data set. The above steps are repeated in this way until the task model is trained using the training sample data set and the memory data set corresponding to the last reasoning task to obtain the final output neural network model. And then the final output neural network model is used to extract features from the training sample data corresponding to the last reasoning task and update the memory data set to obtain the final output memory data set.

[0101] In some embodiments, training the task model according to the memory data set and the target training sample data set includes:

[0102] b1. Obtain the rounds for training the task model and obtain batch sample data from the target training sample data set;

[0103] b2. When the round number is not an integer multiple of the preset number, the task model is trained based on the batch sample data;

[0104] b3. When the round is an integer multiple of the preset number, the task model is trained according to the batch sample data and the memory data in the memory data set;

[0105] b4. Loop execution updates the rounds of training the task model and obtains batch sample data from the target training sample data set. When the rounds are not an integer multiple of the preset number of times, the task model is trained according to the batch sample data. When the rounds are an integer multiple of the preset number of times, the task model is trained according to the batch sample data and the memory data in the memory data set.

[0106] Among them, in the embodiment of the present application, the specific process of training the task model using the training sample data set and the memory data set corresponding to the reasoning task can be to obtain multiple rounds of batch sample data from the training sample data set, and then perform multiple rounds of training on the task model according to the batch sample data obtained in each round. Among them, in the process of performing multiple rounds of training on the task model, the task model can be trained with the memory data in the memory data set at a certain frequency. Among them, it can be understood that the sample features in the memory data also have corresponding label data, and the label data can be the same label data as the sample data corresponding to the sample features in the sample data set.

[0107] Specifically, when training the task model, the training rounds can be continuously detected. When it is detected that the training rounds are not an integer multiple of the preset number, batch sample data can be obtained from the target training sample data set to train the task model; when it is detected that the training rounds are an integer multiple of the preset number, the task model can be trained using the memory data in the memory data set, or the task model can be trained using both the batch sample data and the memory data.

[0108] In some embodiments, training the task model according to the batch sample data includes:

[0109] b21. Input the batch sample data into the task model, and calculate the contrastive learning loss based on the output of the task model and the label data in the batch sample data;

[0110] b22. Update the parameters of the task model based on contrastive learning loss.

[0111] Among them, in an embodiment of the present application, when the task model is trained using the training sample data corresponding to the reasoning task, a contrastive learning method can be used for training. That is, when constructing a loss function for training the task model, a contrastive learning loss can be constructed. Compared with the method of using cross entropy as a loss function to train the task model in the related art, the use of contrastive learning loss can improve the generalization ability and robustness of the trained task model. However, using cross entropy as a loss function to train the task model can easily cause problems such as poor model generalization ability, weak robustness, and unstable training.

[0112] Specifically, in one round of training the task model, the obtained batch sample data can be input into the task model. Then, the contrastive learning loss is calculated based on the output of the task model and its label. The contrastive learning loss constrains the model output of the positive sample to be close to its label data, and the model output of the negative sample to be far from its label. Then, the model parameters of the task model can be further updated based on the calculated contrastive learning loss. Repeat multiple rounds of training of the task model to obtain the trained task model.

[0113] Among them, in some embodiments, the model reasoning method based on continuous learning provided by the present application may also include:

[0114] A. When the current reasoning task is not the first reasoning task among multiple reasoning tasks, the instance relationship distillation loss is calculated. The instance relationship distillation loss is used to constrain the differences between task models trained based on training sample data sets corresponding to different reasoning tasks;

[0115] The parameters of the task model are updated based on contrastive learning loss, including:

[0116] B. Calculate the target loss based on contrastive learning loss and instance relation distillation loss;

[0117] C. Update the parameters of the task model based on the target loss.

[0118] Among them, in an embodiment of the present application, in order to further preserve the knowledge learned in previous tasks and avoid catastrophic forgetting problems, when constructing the loss function for training the task model, the instance relationship distillation loss is further used to constrain the instance similarity relationship between the task models trained corresponding to different reasoning tasks. Among them, the instance relationship distillation loss is used to constrain the differences between the task models trained based on the training sample data sets corresponding to different reasoning tasks. Specifically, it can be understood as constraining the similarity between the data generated by the current model to be similar to the similarity between the data generated by the previous model. For example, the feature data obtained by data a and data b after being processed by the previous model are relatively similar, so it is hoped that the feature data obtained by the current model for processing data a and data b are also relatively similar.

[0119] Specifically, when it is detected that the current reasoning task is not the first reasoning task, the example relationship distillation loss between the task models corresponding to the current reasoning task and the reasoning task before the current reasoning task can be calculated. Then, the target loss is calculated based on the instance relationship distillation loss and the contrastive learning loss, and the target loss can specifically be the sum of the contrastive learning loss and the instance relationship distillation loss. Then, the model parameters of the task model can be updated based on the target loss. Using the method provided in this embodiment to train the task model can further avoid the catastrophic forgetting problem in the continuous learning process, thereby improving the stability of the learned model.

[0120] In some embodiments, when the current reasoning task is not the first reasoning task among multiple reasoning tasks, the instance relationship distillation loss is calculated, and the instance relationship distillation loss is used to constrain the differences between task models trained based on training sample data sets corresponding to different reasoning tasks, including:

[0121] A1. When the current reasoning task is not the first reasoning task among multiple reasoning tasks, a sample feature set corresponding to each reasoning task is obtained, where the sample feature is a feature obtained by extracting features from corresponding training sample data using the trained task model after training the task model;

[0122] A2. Calculate the instance relationship distillation loss based on the similarity relationship between sample features corresponding to similar labels in different sample feature sets.

[0123] Among them, in the embodiment of the present application, the specific steps for calculating the instance relationship distillation loss are to obtain the sample features obtained by extracting the training sample data using the trained task model after the task model is trained based on the training sample data corresponding to each reasoning task, and the label data corresponding to each sample feature. Among the sample features output by the task model trained corresponding to the same reasoning task, the sample features of similar labels should have similar relationships. In this way, the instance relationship distillation loss can be calculated based on the similar relationships between the sample features corresponding to similar labels in different sample feature sets.

[0124] In some embodiments, the trained task model is used to extract features from the training sample data in the target training sample data set, and the memory data set is updated based on the extracted features, including:

[0125] c1. Use the trained task model to extract features from the target training sample data to obtain multiple sample features;

[0126] c2. clustering the multiple sample features based on the label data corresponding to the multiple sample features, and determining multiple target sample features from the multiple sample features according to the clustering results;

[0127] c3. Add multiple target sample features to the memory data set to update the memory data set.

[0128] Among them, in the embodiment of the present application, the specific process of updating the memory data set in real time during the training of the task model. The trained task model can be used to extract the training sample data in the training sample data set to obtain sample features, and then the kmeans clustering algorithm is used to cluster the multiple sample features to obtain multiple feature classes. Furthermore, a sample feature can be obtained in each feature class as a target sample feature, thereby obtaining multiple target sample features. Then, the multiple target sample features can be saved in the memory data set to achieve the update of the memory data set.

[0129] Step 103: Acquire associated memory data associated with the target reasoning task from the memory data set.

[0130] The data in the memory data set here are the data obtained by clustering the feature data, and the feature data are the data obtained by extracting features from the corresponding training sample data by the trained task model during the continuous learning process of the task model. Specifically, as mentioned above, in the process of continuously learning the task model using the training sample data sets corresponding to multiple reasoning tasks, after the task model is trained using the training sample data sets corresponding to any reasoning task, the trained current task model can be used to extract features from the training sample data corresponding to the current reasoning task to obtain multiple sample features. Then, these sample features can be clustered using the kmeans algorithm to obtain target sample features, and these target sample features are added to the memory data set. In the memory data set, the memory data can be stored separately according to the corresponding reasoning tasks.

[0131] In this way, when a model reasoning task is received, it can be determined which specific reasoning task among the multiple reasoning tasks for training the task model is the model reasoning task, which can be specifically a target reasoning task. For example, the target reasoning task here can be an image recognition task, an image segmentation task, an image classification task, or it can also be a text generation task, a text segmentation task, a text classification task, etc. Then, the memory data associated with the target reasoning task can be obtained from the memory data set, which can be referred to as associated memory data. It can be understood that the associated memory data is the feature data obtained by extracting features from the training sample data corresponding to the target reasoning task through the corresponding task model. Moreover, each associated memory data has corresponding label data. In this way, when a model reasoning task is received and model reasoning is performed, the corresponding target memory data can be determined by the similarity relationship between the model output data obtained by extracting the reasoning data using a neural network model and the associated memory data, and the reasoning result is determined according to the label of the target memory data.

[0132] Step 104, determining a plurality of target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data.

[0133] After obtaining multiple associated memory data associated with the target reasoning task in the memory data set, the association relationship between the model output data and the multiple associated memory data can be determined, and the association relationship here can specifically be a similarity relationship. Among them, the method of calculating the cosine similarity between the model output data and the multiple associated memory data can be used to calculate the association relationship between the associated memory data and the model output data. Then, multiple associated memory data with a similarity greater than a preset threshold can be determined as target memory data.

[0134] Specifically, according to the association relationship between the associated memory data and the model output data, a plurality of target memory data are determined in the associated memory data, including:

[0135] Calculate the similarity between each memory data in the associated memory data and the model output data;

[0136] A plurality of target memory data are determined in the associated memory data according to similarity.

[0137] That is, in an embodiment of the present application, the target memory data can be determined in the associated memory data by calculating the similarity between the associated memory data and the model output data. Specifically, in an embodiment of the present application, the K-Nearest Neighbor algorithm can be used to output the model reasoning results. The so-called K nearest neighbors means K nearest neighbors, which means that each sample can be represented by its closest K neighboring values. Specifically, K target memory data can be determined in the associated memory data according to the similarity, and then the reasoning results can be determined according to the labels corresponding to these K target memory data.

[0138] Step 105, determining an inference result based on the label data corresponding to the multiple target memory data.

[0139] Among them, after determining multiple target memory data, it is possible to further obtain label data corresponding to the multiple target memory data, and then determine the inference result based on the label data corresponding to the multiple target memory data.

[0140] In some embodiments, determining the inference result based on the label data corresponding to the plurality of target memory data includes:

[0141] Obtain label data corresponding to a plurality of target memory data to obtain a plurality of label data;

[0142] Clustering is performed on multiple labeled data, and the label corresponding to the category with the largest number of labels is determined as the inference result.

[0143] Among them, in the embodiment of the present application, after obtaining the label data corresponding to the multiple target memory data, the multiple label data obtained can be further clustered to determine the label data with the largest number as the final reasoning result. Alternatively, the labels corresponding to the multiple target memory data can be processed using a normalization function to obtain the probability corresponding to each label data, and then the label data with the highest probability can be determined as the final reasoning result.

[0144] Among them, Figure 3As shown, it is a schematic diagram of data flow in the continuous learning process of the task model corresponding to multiple reasoning tasks in this application. As shown in the figure, the encoder (i.e., the task model) can be trained using the training sample data in the acquired training sample data set and the memory data in the memory data set generated during the training process. During the training process, contrastive learning loss and IRD loss are used to adjust the parameters of the encoder to avoid the problems of insufficient generalization ability and instability of the model, as well as to avoid the catastrophic forgetting problem of the model, so that the model can maintain the processing ability of previous tasks while learning the processing ability of new tasks. Then, the currently trained task model can be further used to extract features from the training sample data to obtain sample feature data, and the kmeans clustering algorithm can be further used to cluster these sample feature data to obtain memory data, and these memory data are updated to the memory data set to repeat the above training operation.

[0145] In addition, if Figure 4 As shown, it is a schematic diagram of the data flow in the model reasoning process of the model reasoning method provided by the present application. As shown in the figure, after the task model is continuously learned to output the final trained task model and the final memory data set. The trained task model (i.e., encoder) and the memory data in the memory data set can be used to reason the reasoning data. Specifically, the reasoning data can be first feature extracted by the encoder to obtain the model output data. Then, the model data and the memory data in the memory data set are subjected to the KNN (K neighbor) algorithm to determine the final reasoning result. Specifically, the specific process of using the K neighbor algorithm to determine the reasoning result can be to determine several target memory data with a high similarity to the model output data in the associated memory data corresponding to the reasoning task in the memory data set, and then determine the final reasoning result based on the label data of the target memory data.

[0146] According to the above description, the model inference method based on continuous learning provided in the embodiment of the present application obtains the target reasoning task and the reasoning data corresponding to the target reasoning task; inputs the reasoning data into the trained neural network model to obtain model output data, and the neural network model is a neural network model obtained by continuously learning the task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; obtains associated memory data associated with the target reasoning task from the memory data set, and the data in the memory data set is the data obtained by clustering the feature data, and the feature data is the data obtained by extracting features of the corresponding training sample data by the trained task model during the continuous learning process of the task model; according to the association relationship between the associated memory data and the model output data, multiple target memory data are determined in the associated memory data; and the reasoning result is determined based on the label data corresponding to the multiple target memory data.

[0147] In this way, the model reasoning method based on continuous learning provided by the present application, when continuously learning the multi-task model, not only outputs the trained neural network model, but also outputs a memory data set for assisting model reasoning. When model task reasoning is required, the neural network model obtained by continuous learning can be used to extract features from the reasoning data to obtain model output data, and then the final reasoning result is determined based on the similarity relationship between the model output data and the memory data set corresponding to the model reasoning task. In this way, there is no need to construct a model output layer, which avoids the problem of increasing the storage burden due to the increase in model tasks, which in turn affects the efficiency of model reasoning. Thereby, the efficiency of model reasoning can be greatly improved.

[0148] The present application also provides a model reasoning method based on continuous learning, which can be used in a computer device, which can be a terminal or a server. Figure 5 As shown, it is another flow chart of the model reasoning method based on continuous learning provided by the present application, and the method specifically includes:

[0149] Step 201: A computer device obtains a training sample data set corresponding to a plurality of reasoning tasks, a pre-trained language model, and an initialized memory data set.

[0150] Among them, in the embodiments of the present application, the model reasoning method based on continuous learning provided by the present application will be introduced in detail by taking the continuous learning of a large-scale language model as an example.

[0151] Specifically, the language model in the present application can be a pre-trained language model, for example, a large amount of unlabeled corpus data can be used to train the language model so that the language model can learn to obtain a certain ability to extract features from text. The language model that needs to be continuously learned and trained in the present application can specifically be an encoder, which does not need to cooperate with the corresponding model output layer, such as the model structure corresponding to the decoder such as the classification layer and the recognition layer.

[0152] Before the language model is continuously learned, it is necessary to obtain the corresponding training sample data, and specifically, the training sample data sets corresponding to multiple reasoning tasks can be obtained. Each reasoning task can correspond to a training sample data set. The acquisition of multiple training sample data sets can be directly acquired at one time, or can be acquired one by one before learning the corresponding tasks. For example, the training sample data set corresponding to the A reasoning task can be obtained, and then the language model can learn the ability to process the A reasoning task based on the training sample data set. Then the training sample data set corresponding to the B reasoning task is further obtained, and then the language model can learn the ability to process the B reasoning task based on the training sample data set. Alternatively, multiple training sample data sets corresponding to multiple reasoning tasks can be obtained at the same time, and then the language model can be trained one by one. Among them, the language model can be trained one by one by first sorting the multiple reasoning tasks, and then the training sample data sets corresponding to each reasoning task can be obtained one by one according to the sorting order of the multiple reasoning tasks, and these training sample data sets can be used to train the language model one by one according to the sorting order.

[0153] In the embodiment of the present application, an initialized memory data set may also be obtained, and the initialized memory data set may specifically be an empty set, and then the memory data set may be continuously updated during the training of the language model.

[0154] Step 202: The computer device obtains a training sample data set and determines whether it is a training sample data set corresponding to the first reasoning task.

[0155] Among them, since there is a preset order relationship between multiple reasoning tasks, when the computer device obtains the training sample data set, it can determine the reasoning task corresponding to the training sample data, and then determine whether the reasoning task corresponding to the training sample data set is the first reasoning task.

[0156] Step 203: The computer device calculates the contrastive learning loss based on the training sample data set.

[0157] When the computer device determines that the acquired training sample data set is the training sample data set corresponding to the first reasoning task, the computer device can perform supervised contrastive learning training on the language model according to the training sample data set. Specifically, the contrastive learning loss can be calculated according to the training sample data set.

[0158] Specifically, for task T i , we will give the input Put it into the pre-trained language model to get the representation of the sentence:

[0159]

[0160] Among them, Norm(.) is the normalization operator, LM i Language model trained for the i-th reasoning task.

[0161] Then, for the data A within a batch, the following contrastive learning loss can be constructed:

[0162]

[0163] Among them, N(j) is the data in the batch data except the j-th data, P(j) is the data in N(j) with the same label as the j-th data, and k is the temperature.

[0164] In step 204, the computer device trains the language model according to the contrastive learning loss.

[0165] After constructing the contrastive learning loss for training the language model, the computer device can calculate the back propagation gradient according to the contrastive learning loss, and then adjust the parameters of the language model based on the back propagation gradient.

[0166] The process of training the language model based on the training sample data set includes obtaining batch sample data in multiple cycles, calculating the contrastive learning loss based on the batch sample data, and adjusting the parameters of the language model using the contrastive learning loss, until the number of training times reaches a preset number, or the change in the model parameters is less than a preset threshold.

[0167] Step 205: The computer device calculates the target loss based on the training sample data set or the memory data set.

[0168] When the computer device detects that the currently acquired training sample data set is not the training sample data set corresponding to the first inference task, the computer device can further calculate the instance relationship distillation loss in addition to calculating the contrastive learning loss based on the batch sample data obtained from the training sample data set. The instance relationship distillation (IRD) loss can be used as a regularization term of the contrastive learning loss, and together with the contrastive learning loss constitute the target loss.

[0169] In order to preserve the knowledge learned in the previous task, IRD can be used in this application to control the representation drift. In the learning of the task, the normalized instance similarity in the batch sample data is calculated as:

[0170]

[0171] Among them, τ is the temperature hyperparameter of IRD. Then the IRD regularization term (i.e. IRD loss) can be expressed as:

[0172]

[0173] In this way, the objective function can be expressed as the sum of contrastive learning loss and IRD loss. The specific expression is as follows:

[0174]

[0175] Among them, in an embodiment of the present application, in order to avoid the problem of catastrophic forgetting. During multiple rounds of training of the language model, the computer device can also continuously acquire the training rounds. When the number of training rounds for the language model is not an integer multiple of the preset number of times, the target loss calculated by the above-mentioned training sample data set can be used, and then the target loss is used to train the task model. When the number of training rounds for the language model is an integer multiple of the preset number of times, the data in the memory data set can be used to calculate the above-mentioned target loss, and then the target loss is used to train the task model. In this way, the task model is memorized and replayed at a certain frequency using the data in the memory data set, so that the task model maintains the learning effect of the old task.

[0176] In step 206, the computer device trains the language model according to the target loss.

[0177] After the target loss is calculated, the target loss can be used to train the language model. The training of the task model here is also a multi-round cycle training. In each cycle, the target loss can be calculated using the batch sample data collected in the training sample data set or the data in the memory data set, and then the language model is trained based on the target loss.

[0178] Step 207: The computer device calculates the memory data and updates the memory data set.

[0179] Among them, after each training of the language model based on the training sample data set corresponding to an inference task and the corresponding memory data set, the computer device can use the currently trained language model to extract features of the training sample data corresponding to the current inference task, and then calculate the memory data corresponding to the current inference task based on the extracted features and the corresponding label data.

[0180] Specifically, for each reasoning task T iAfter training, m samples can be selected from the corresponding training sample data set to maintain the representation distribution relative to the label. Specifically, the kmeans algorithm can be used to cluster the label data in the training sample data set, and then samples can be randomly selected according to the data density to maintain the distribution of the representation in space. Then, the language model obtained by the current training can be used to extract features from the selected samples, and these features and the selected samples can be stored in the memory data set as the memory data corresponding to the current reasoning task. Thereby, the memory data set is updated.

[0181] Step 208: The computer device determines whether the training sample data set is the training sample data set corresponding to the last reasoning task.

[0182] Among them, after updating the memory data set, the computer device can further determine whether the current reasoning task is the last reasoning task in the aforementioned reasoning task sequence.

[0183] Step 209: The computer device obtains a training sample data set corresponding to the next reasoning task.

[0184] When the computer device detects that the current reasoning task is not the last reasoning task, the training sample data set corresponding to the next reasoning task can be obtained according to the sorting order of the reasoning tasks. Then the process returns to step 205, and the language model is retrained based on the newly obtained training sample data set and the memory data set until the computer device detects that the current reasoning task is the last reasoning task in the order of the multiple reasoning tasks.

[0185] In step 210, the computer device outputs the trained language model and the memory data set.

[0186] When the computer device detects that the current reasoning task is the last reasoning task, it can terminate the training of the language model, output the trained language model, and output the current memory data set. Then, the trained language model and the output memory data set can be used to perform the corresponding reasoning task.

[0187] In the embodiment of the present application, there is no need to construct a corresponding output layer for the model, and only the encoder of the language model needs to be trained. When the trained encoder is used for reasoning, the encoder and the corresponding memory data set can be used for reasoning of the task.

[0188] Step 211: The computer device receives a target reasoning task and corresponding reasoning data.

[0189] Among them, after completing the training of the language model and the construction of the memory data set, the trained language model and the memory data set can be used to perform corresponding task reasoning. Specifically, the task to be reasoned can be obtained first, which can be a target reasoning task, and the target reasoning task is one of the multiple reasoning tasks for training the language model. Among them, it can be understood that the reasoning task also includes reasoning data that needs to be processed by the reasoning task. For example, when the reasoning task is a text classification task, the reasoning data can be the text data to be classified.

[0190] In step 212, the computer device uses the trained language model to extract features from the inference data, and determines an inference result based on the extracted features and the memory data in the memory data set.

[0191] Among them, in the embodiment of the present application, after learning T i After the task, you can get LM i Model. In any previous reasoning task T u In the reasoning process of (u<=i), the reasoning data can be Input to LM i In the model, the corresponding expression is obtained Then, the memory data corresponding to the reasoning task can be extracted from the memory data set, and k data can be retrieved from these memory data. These k data are related to The cosine similarity of is greater than that of other data The cosine similarity of .

[0192] Then, the retrieved k data can be converted into a probability distribution on the label by applying a softmax function to the similarity:

[0193]

[0194] Wherein, T is temperature, and in the embodiment of the present application, T>1 can be set to make the probability distribution flat and prevent overfitting.

[0195] In this way, the probability values ​​of multiple labels can be obtained, and then the label with the highest probability can be determined as the final inference result.

[0196] The model reasoning method based on continuous learning provided in the embodiment of the present application can not only avoid the problem of catastrophic forgetting, but also improve the stability of the model obtained by continuous learning. Moreover, the model trained by this method does not need to configure the corresponding model output layer during reasoning, so the size of the model can be reduced, thereby avoiding the increase in storage burden, thereby improving the reasoning efficiency of the model. Moreover, since there is no need to configure the corresponding model output layer for each reasoning task, the model reasoning result can be directly determined based on the encoder output result and the corresponding memory storage data, thereby greatly improving the scalability of the model. Improve the scope of application of downstream tasks. In addition, the embodiment of the present application also fine-tunes the parameters of the language model through a supervised contrast learning method, avoiding the problems of insufficient model generalization ability and poor robustness that will occur in the cross entropy training language model, thereby further improving the reasoning accuracy of the model.

[0197] Therefore, the model inference method based on continuous learning provided by the present application obtains the target reasoning task and the reasoning data corresponding to the target reasoning task; inputs the reasoning data into the trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning the task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; obtains associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features of corresponding training sample data by the trained task model during the continuous learning process of the task model; determines multiple target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data; and determines the reasoning result based on the label data corresponding to the multiple target memory data.

[0198] In this way, the model reasoning method based on continuous learning provided by the present application, when continuously learning the multi-task model, not only outputs the trained neural network model, but also outputs a memory data set for assisting model reasoning. When model task reasoning is required, the neural network model obtained by continuous learning can be used to extract features from the reasoning data to obtain model output data, and then the final reasoning result is determined based on the similarity relationship between the model output data and the memory data set corresponding to the model reasoning task. In this way, there is no need to construct a model output layer, which avoids the problem of increasing the storage burden due to the increase in model tasks, which in turn affects the efficiency of model reasoning. Thereby, the efficiency of model reasoning can be greatly improved.

[0199] In order to better implement the above model reasoning method based on continuous learning, an embodiment of the present application also provides a model reasoning device based on continuous learning, which can be integrated in a terminal or a server.

[0200] For example, Figure 6 As shown, it is a structural diagram of a model inference device based on continuous learning provided in an embodiment of the present application. The device may include a first acquisition unit 301, an input unit 302, a second acquisition unit 303, a first determination unit 304, and a second determination unit 305, as follows:

[0201] A first acquisition unit 301 is used to acquire a target reasoning task and reasoning data corresponding to the target reasoning task;

[0202] An input unit 302 is used to input the reasoning data into the trained neural network model to obtain model output data, where the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, where the multiple reasoning tasks include a target reasoning task;

[0203] The second acquisition unit 303 is used to acquire associated memory data associated with the target reasoning task from the memory data set, where the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features from corresponding training sample data by the trained task model during the continuous learning process of the task model;

[0204] A first determining unit 304 is used to determine a plurality of target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data;

[0205] The second determining unit 305 is used to determine the inference result based on the label data corresponding to the multiple target memory data.

[0206] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0207] A first acquisition subunit is used to acquire training sample data sets corresponding to multiple reasoning tasks to obtain multiple training sample data sets;

[0208] The training subunit is used to train the task models corresponding to multiple reasoning tasks in turn using the training sample data set corresponding to each reasoning task to obtain a trained neural network model.

[0209] Optionally, in some embodiments, a plurality of reasoning tasks are arranged in a preset order, and the training subunit includes:

[0210] A first acquisition module is used to acquire a target training sample data set for training a task model, where the target training sample data set is a training sample data set corresponding to a current reasoning task, and the current reasoning task is a first reasoning task among multiple reasoning tasks;

[0211] A training module, used to train the task model according to the target training sample data set;

[0212] An execution module, used for, when the current reasoning task is not the last reasoning task among the multiple reasoning tasks, obtaining the next second reasoning task and using the second reasoning task to update the current reasoning task, and returning to execute the steps of obtaining a target training sample data set for training the task model, and training the task model according to the target training sample data set;

[0213] The termination module is used to terminate the training of the task model when the current reasoning task is the last reasoning task among multiple reasoning tasks, and obtain the trained neural network model.

[0214] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0215] Constructing subunits for constructing memory data sets;

[0216] Training modules include:

[0217] A training submodule is used to train the task model based on the memory data set and the target training sample data set;

[0218] The updating submodule is used to extract features from the training sample data in the target training sample data set using the trained task model, and to update the memory data set based on the extracted features.

[0219] Optionally, in some embodiments, the training submodule is further used to:

[0220] Obtain the rounds for training the task model and obtain batch sample data from the target training sample data set;

[0221] When the round number is not an integer multiple of the preset number, the task model is trained based on the batch sample data;

[0222] When the round is an integer multiple of the preset number, the task model is trained according to the batch sample data and the memory data in the memory data set;

[0223] The task model is updated in a loop by obtaining batch sample data from a target training sample data set, and when the round is not an integer multiple of a preset number of times, the task model is trained according to the batch sample data; and when the round is an integer multiple of a preset number of times, the task model is trained according to the batch sample data and the memory data in the memory data set.

[0224] Optionally, in some embodiments, the training submodule is further used to:

[0225] Input the batch sample data into the task model, and calculate the contrastive learning loss based on the output of the task model and the label data in the batch sample data;

[0226] The parameters of the task model are updated based on contrastive learning loss.

[0227] Optionally, in some embodiments, the model reasoning device based on continuous learning provided by the present application further includes:

[0228] A first calculation subunit is used to calculate the instance relationship distillation loss when the current reasoning task is not the first reasoning task among the multiple reasoning tasks, and the instance relationship distillation loss is used to constrain the difference between the task models trained based on the training sample data sets corresponding to different reasoning tasks;

[0229] The training submodule is also used to:

[0230] Calculate the target loss based on contrastive learning loss and instance relation distillation loss;

[0231] The parameters of the task model are updated based on the target loss.

[0232] Optionally, in some embodiments, the first computing subunit includes:

[0233] A second acquisition module is used to acquire a sample feature set corresponding to each reasoning task when the current reasoning task is not the first reasoning task among multiple reasoning tasks, where the sample feature is a feature obtained by extracting features from corresponding training sample data using the trained task model after training the task model;

[0234] The calculation module is used to calculate the instance relationship distillation loss based on the similarity relationship between sample features corresponding to similar labels in different sample feature sets.

[0235] Optionally, in some embodiments, the updating submodule is further used to:

[0236] The trained task model is used to extract features from the target training sample data to obtain multiple sample features;

[0237] Performing feature clustering on the multiple sample features based on the label data corresponding to the multiple sample features, and determining multiple target sample features from the multiple sample features according to the clustering result;

[0238] A plurality of target sample features are added to a memory data set to update the memory data set.

[0239] Optionally, in some embodiments, the first determining unit includes:

[0240] A second calculation subunit is used to calculate the similarity between each memory data in the associated memory data and the model output data;

[0241] A determination subunit is used to determine a plurality of target memory data in the associated memory data according to similarity.

[0242] Optionally, in some embodiments, the second determining unit includes:

[0243] The second acquisition subunit is used to acquire label data corresponding to the plurality of target memory data to obtain a plurality of label data;

[0244] The processing subunit is used to perform clustering processing on multiple label data and determine the label corresponding to the category with the largest number of labels as the inference result.

[0245] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0246] According to the above description, the model inference device based on continuous learning provided in the embodiment of the present application obtains the target reasoning task and the reasoning data corresponding to the target reasoning task through the first acquisition unit 301; the input unit 302 inputs the reasoning data into the trained neural network model to obtain model output data, and the neural network model is a neural network model obtained by continuously learning the task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; the second acquisition unit 303 obtains the associated memory data associated with the target reasoning task from the memory data set, and the data in the memory data set is the data obtained by clustering the feature data, and the feature data is the data obtained by extracting the features of the corresponding training sample data by the trained task model during the continuous learning process of the task model; the first determination unit 304 determines multiple target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data; the second determination unit 305 determines the reasoning result based on the label data corresponding to the multiple target memory data.

[0247] In this way, the model reasoning device based on continuous learning provided by the present application, when continuously learning the multi-task model, not only outputs the trained neural network model, but also outputs a memory data set for assisting model reasoning. When model task reasoning is required, the neural network model obtained by continuous learning can be used to extract features from the reasoning data to obtain model output data, and then the final reasoning result is determined based on the similarity relationship between the model output data and the memory data set corresponding to the model reasoning task. In this way, there is no need to construct a model output layer, which avoids the problem of increasing the storage burden due to the increase in model tasks, which in turn affects the efficiency of model reasoning. Thereby, the efficiency of model reasoning can be greatly improved.

[0248] The present application also provides a computer device, which may be a terminal or a server. Figure 7 The figure is a schematic diagram of the structure of the computer device provided by this application. Specifically:

[0249] The computer device may include components such as a processing unit 401 of one or more processing cores, a storage unit 402 of one or more storage media, a power module 403, and an input module 404. Those skilled in the art will appreciate that Figure 7 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0250] The processing unit 401 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. It executes various functions of the computer device and processes data by running or executing software programs and / or modules stored in the storage unit 402, and calling data stored in the storage unit 402. Optionally, the processing unit 401 may include one or more processing cores; preferably, the processing unit 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, object interface and application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processing unit 401.

[0251] The storage unit 402 can be used to store software programs and modules. The processing unit 401 executes various functional applications and model reasoning based on continuous learning by running the software programs and modules stored in the storage unit 402. The storage unit 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, and web page access, etc.); the data storage area may store data created according to the use of the computer device, etc. In addition, the storage unit 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the storage unit 402 may also include a memory controller to provide the processing unit 401 with access to the storage unit 402.

[0252] The computer device also includes a power module 403 for supplying power to each component. Preferably, the power module 403 can be logically connected to the processing unit 401 through a power management system, so as to achieve functions such as management of charging, discharging, and power consumption management through the power management system. The power module 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0253] The computer device may further include an input module 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to object settings and function controls.

[0254] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically, in this embodiment, the processing unit 401 in the computer device will load the executable files corresponding to the processes of one or more application programs into the storage unit 402 according to the following instructions, and the processing unit 401 will run the application programs stored in the storage unit 402, thereby realizing various functions, as follows:

[0255] Obtain a target reasoning task and reasoning data corresponding to the target reasoning task; input the reasoning data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; obtain associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features from corresponding training sample data by the trained task model during the continuous learning process of the task model; determine multiple target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data; and determine the reasoning result based on the label data corresponding to the multiple target memory data.

[0256] It should be noted that the computer device provided in the embodiment of the present application and the method in the above embodiment belong to the same concept, and the specific implementation of the above operations can be referred to the previous embodiment, which will not be repeated here.

[0257] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0258] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:

[0259] Obtain a target reasoning task and reasoning data corresponding to the target reasoning task; input the reasoning data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, and the multiple reasoning tasks include the target reasoning task; obtain associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features from corresponding training sample data by the trained task model during the continuous learning process of the task model; determine multiple target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data; and determine the reasoning result based on the label data corresponding to the multiple target memory data.

[0260] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0261] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0262] Since the instructions stored in the computer-readable storage medium can execute the steps in any method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0263] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional implementations of the above-mentioned model reasoning method based on continuous learning.

[0264] The above is a detailed introduction to the model inference method, device and storage medium based on continuous learning provided in the embodiments of the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A model reasoning method based on continuous learning, characterized in that: The method comprises: Obtaining a target reasoning task and reasoning data corresponding to the target reasoning task; Inputting the inference data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple inference tasks, wherein the multiple inference tasks include the target inference task; Acquire associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features of corresponding training sample data by a trained task model during continuous learning of the task model; Determining a plurality of target memory data in the associated memory data according to an association relationship between the associated memory data and the model output data; An inference result is determined based on the label data corresponding to the multiple target memory data.

2. The method according to claim 1, characterized in that: Before acquiring the target reasoning task and the reasoning data corresponding to the target reasoning task, the method further includes: Acquire training sample data sets corresponding to multiple reasoning tasks to obtain multiple training sample data sets; The task models corresponding to the multiple reasoning tasks are trained in turn using the training sample data set corresponding to each reasoning task to obtain a trained neural network model.

3. The method according to claim 2, characterized in that The multiple reasoning tasks are arranged in a preset order, and the training sample data set corresponding to each reasoning task is used in turn to train the task models corresponding to the multiple reasoning tasks to obtain the trained neural network model, including: Acquire a target training sample data set for training the task model, wherein the target training sample data set is a training sample data set corresponding to a current reasoning task, and the current reasoning task is a first reasoning task among the multiple reasoning tasks; Training the task model according to the target training sample data set; When the current reasoning task is not the last reasoning task among the multiple reasoning tasks, obtaining a next second reasoning task and using the second reasoning task to update the current reasoning task, and returning to execute the step of obtaining a target training sample data set for training the task model, and training the task model according to the target training sample data set; When the current reasoning task is the last reasoning task among the multiple reasoning tasks, the training of the task model is terminated to obtain a trained neural network model.

4. The method according to claim 3, characterized in that The method further comprises: Construct memory data set; The training of the task model according to the target training sample data set includes: Training the task model according to the memory data set and the target training sample data set; The trained task model is used to extract features from the training sample data in the target training sample data set, and the memory data set is updated based on the extracted features.

5. The method according to claim 4, characterized in that The training of the task model according to the memory data set and the target training sample data set includes: Obtaining a round of training for the task model, and obtaining batch sample data from the target training sample data set; When the round is not an integer multiple of the preset number of times, training the task model according to the batch sample data; When the round is an integer multiple of the preset number of times, training the task model according to the batch sample data and the memory data in the memory data set; The task model is updated in a loop by obtaining batch sample data from the target training sample data set, and when the round is not an integer multiple of a preset number of times, the task model is trained according to the batch sample data; and when the round is an integer multiple of the preset number of times, the task model is trained according to the batch sample data and the memory data in the memory data set.

6. The method according to claim 5, characterized in that The training of the task model according to the batch sample data includes: Inputting the batch sample data into the task model, and calculating a contrastive learning loss based on an output of the task model and label data in the batch sample data; The parameters of the task model are updated based on the contrastive learning loss.

7. The method according to claim 6, characterized in that The method further comprises: When the current reasoning task is not the first reasoning task among the multiple reasoning tasks, calculating the instance relationship distillation loss, where the instance relationship distillation loss is used to constrain the difference between task models trained based on training sample data sets corresponding to different reasoning tasks; The updating of the parameters of the task model based on the contrastive learning loss includes: Calculating a target loss based on the contrastive learning loss and the instance relation distillation loss; Parameters of the task model are updated based on the target loss.

8. The method according to claim 7, characterized in that When the current reasoning task is not the first reasoning task among the multiple reasoning tasks, calculating the instance relationship distillation loss, the instance relationship distillation loss is used to constrain the difference between task models trained based on training sample data sets corresponding to different reasoning tasks, including: When the current reasoning task is not the first reasoning task among the multiple reasoning tasks, a sample feature set corresponding to each reasoning task is obtained, wherein the sample feature is a feature obtained by extracting features from corresponding training sample data using the trained task model after training the task model; Based on the similarity between sample features corresponding to similar labels in different sample feature sets, the instance relation distillation loss is calculated.

9. The method according to claim 4, characterized in that The step of extracting features from the training sample data in the target training sample data set using the trained task model, and updating the memory data set based on the extracted features, includes: The trained task model is used to extract features from the target training sample data to obtain multiple sample features; Performing feature clustering on the multiple sample features based on the label data corresponding to the multiple sample features, and determining multiple target sample features from the multiple sample features according to the clustering result; The multiple target sample features are added to the memory data set to update the memory data set.

10. The method according to claim 1, characterized in that The determining of a plurality of target memory data in the associated memory data according to the association relationship between the associated memory data and the model output data comprises: Calculating the similarity between each memory data in the associated memory data and the model output data; A plurality of target memory data are determined in the associated memory data according to the similarity.

11. The method according to claim 1, characterized in that: The determining of the inference result based on the label data corresponding to the plurality of target memory data includes: Acquire label data corresponding to the plurality of target memory data to obtain a plurality of label data; Clustering is performed on the multiple label data, and the label corresponding to the category with the largest number of labels is determined as the inference result.

12. A model reasoning device based on continuous learning, characterized in that: The device comprises: A first acquisition unit, used to acquire a target reasoning task and reasoning data corresponding to the target reasoning task; An input unit, used to input the reasoning data into a trained neural network model to obtain model output data, wherein the neural network model is a neural network model obtained by continuously learning task models corresponding to multiple reasoning tasks, wherein the multiple reasoning tasks include the target reasoning task; A second acquisition unit is used to acquire associated memory data associated with the target reasoning task from a memory data set, wherein the data in the memory data set is data obtained by clustering feature data, and the feature data is data obtained by extracting features of corresponding training sample data by a trained task model during continuous learning of the task model; A first determining unit, configured to determine a plurality of target memory data in the associated memory data according to an association relationship between the associated memory data and the model output data; The second determining unit is used to determine the inference result based on the label data corresponding to the multiple target memory data.

13. A storage medium, characterized in that: The storage medium stores a plurality of instructions, which are suitable for loading by a processor to execute the steps in the model inference method based on continuous learning as described in any one of claims 1 to 11.

14. A computer device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the model inference method based on continuous learning described in any one of claims 1 to 11 when executing the computer program.

15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps in the model inference method based on continuous learning described in any one of claims 1 to 11 are implemented.

Citation Information

Cited By

  • Fine-grained visual identification method based on multi-modal large model

    CN121053481A

  • A fine-grained visual recognition method based on a multi-modal large model

    CN121053481B