Model training method and device, electronic equipment and storage medium
By updating the first encoder and basic sub -models of the neural network model, the problem of lower accuracy and reliability of neural network models in existing technologies in existing technologies has achieved higher task execution accuracy and accuracy and reliability.
Patent Information
- Application Number
- CN202411273588.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-01-28
AI Technical Summary
In the prior art, neural network models have problems with low accuracy and reliability when processing data for specific tasks, especially when there is less training data.
Through a model training method, this method includes updating the first encoder in the first model based on the first training dataset to get the second model; then, based on the second training dataset The basic sub -model is updated to get the third model. This method can improve the model's ability to extract and contextual understanding of local details information.
This method can improve the performance of the neural network model in performing target tasks, improve accuracy and reliability, especially when training data is less.
Smart Images

Figure CN119378645A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of neural network models, and in particular, relates to a model training method, device, electronic device and storage medium. Background Art
[0002] In the field of artificial intelligence, the application of models has involved many aspects. At present, when training neural network models to implement various tasks, the training data corresponding to the task is usually used for model training. Usually, a large amount of training data is required in the process of training neural network models. In actual scenarios, there is less training data corresponding to a certain task. In this case, the neural network model generated based on less training data has low generalization.
[0003] Based on this, in the prior art, training data is usually used to train a mature neural network model in the field corresponding to the task, and a neural network model applied to the task in a vertical field is generated to improve the accuracy of the neural network model when performing the task.
[0004] However, in practice, the mature neural network model still has certain limitations when processing the data corresponding to this task, resulting in poor performance of the trained neural network model for this task. In other words, the accuracy and reliability of the task execution are low. Summary of the invention
[0005] The embodiments of the present application provide a model training method, device, electronic device and storage medium, which can solve the problem of low accuracy and reliability of neural network models trained in existing methods.
[0006] In a first aspect, an embodiment of the present application provides a model training method, the method comprising:
[0007] The first encoder in the first model is updated based on the first training data set to obtain a second model; the first training data set includes data corresponding to the target task; the first model includes a first encoder and a first basic sub-model for processing the data of the target task; the second model includes the updated second encoder and the first basic sub-model;
[0008] The first basic sub-model in the second model is updated according to the second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
[0009] In a second aspect, an embodiment of the present application provides a model training device, the device comprising:
[0010] A first updating module is used to update the first encoder in the first model based on the first training data set to obtain a second model; the first training data set includes data corresponding to the target task; the first model includes the first encoder and the first basic sub-model for processing the data of the target task; the second model includes the updated second encoder and the first basic sub-model;
[0011] The second updating module is used to update the first basic sub-model in the second model according to the second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect described above when executing the computer program.
[0013] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method of the first aspect described above is implemented.
[0014] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the method of the first aspect.
[0015] Compared with the prior art, the beneficial effect of the embodiment of the present application is that the first basic sub-model in the first model has the ability to process the data corresponding to the target task. Therefore, even if the first encoder in the first model is updated based on a small amount of the first training data set, the updated second encoder can be focused on capturing the detail information required to perform the target task. Then, based on the second encoder that focuses on capturing the detail information required to perform the target task, the third training data set is processed and the first basic sub-model is updated, so that the first basic sub-model can understand the contextual information in the second training data set during the training process. Furthermore, the ability to extract local detail information and understand context of the final third model can be improved, thereby improving the performance of the third model in performing the target task. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1It is a flow chart of an implementation of a model training method provided in one embodiment of the present application;
[0018] Figure 2 It is a schematic diagram of an application scenario in a model training method provided in an embodiment of the present application;
[0019] Figure 3 It is a structural schematic diagram of a model training device provided in one embodiment of the present application;
[0020] Figure 4 It is a structural schematic diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0022] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0023] It should be noted that the information collection process (such as face image collection process, fingerprint information collection process, etc.) / feature extraction process involved in this application is performed with the user's knowledge and permission, that is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not constitute an act that harms the public interest.
[0024] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0025] In the field of artificial intelligence, the application of models has involved many aspects. At present, when training neural network models to implement various tasks, the training data corresponding to the task is usually used for model training. For example, for language models for language interaction tasks, the conversation text or speech is usually used as training data to train the neural network model.
[0026] However, a large amount of training data is usually required during the training of a neural network model. In actual scenarios, there is less training data corresponding to a certain task. In this case, the neural network model generated based on less training data has lower generalization ability, that is, lower accuracy.
[0027] Based on this, in the prior art, training data is usually used to train a mature neural network model in the field corresponding to the task, and a neural network model applied to the task in a vertical field is generated to improve the accuracy of the neural network model when performing the task.
[0028] However, in actual practice, mature neural network models still have certain limitations when processing the data corresponding to this task, resulting in low accuracy and reliability of the trained neural network model for this task.
[0029] For example, for a visual language navigation model, its task is to output corresponding navigation instructions through the acquired video. However, the training data corresponding to this task is relatively small. Therefore, in the prior art, a small amount of training data is usually used to train a visual language model in the visual language field.
[0030] Specifically, due to insufficient training data for visual-language pairing, the generalization of visual-language navigation models is low. Therefore, it is necessary to use existing visual-language models to generate navigation instructions for visual-language navigation in vertical fields. However, general visual-language models have certain limitations, such as the lack of accuracy and context understanding of the content generated for the navigation field.
[0031] Based on this, in order to make full use of the knowledge contained in the existing general language model to improve the accuracy of the generated visual language model, it is particularly important to optimize the existing visual language model for the generation of navigation instructions.
[0032] At present, Synthetic data (synthetic data technology) makes up for the lack of actual data by generating a large amount of high-quality training data, thereby improving the training effect and generalization ability of the model. However, Synthetic data may bring some inconsistency and bias problems, affecting the performance and reliability of the model. The Speaker model is a type of model that generates visual navigation instructions and can provide efficient language generation and understanding capabilities in visual language navigation. Although the existing Speaker model performs well in language generation, it still has certain limitations in handling complex contexts and extracting detailed information.
[0033] Based on the above description, it can be considered that although the visual language model has achieved remarkable results in natural language processing and generation tasks, when it is used in the navigation instruction generation of the visual language navigation task, the accuracy of the navigation instruction generation and the processing of complex context and detailed information extraction are still insufficient. As a result, the navigation instructions generated by the trained visual language navigation model are of low accuracy.
[0034] Based on this, in order to improve the accuracy of the trained model, an embodiment of the present application provides a model training method, which can be applied to electronic devices such as tablet computers, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, etc. The embodiment of the present application does not impose any restrictions on the specific types of electronic devices.
[0035] See also Figure 1 , Figure 1 A flow chart of an implementation of a model training method provided in an embodiment of the present application is shown, and the method comprises the following steps:
[0036] S101. Update a first encoder in a first model based on a first training data set to obtain a second model.
[0037] In one embodiment, the first training data set includes data under the target task. The target task includes, but is not limited to, a navigation instruction generation task, a medical consultation task, a legal consultation task, and a text clustering task, etc. This embodiment does not limit the category of the target task. For ease of explanation, in this embodiment, the target task is a navigation instruction generation task based on visual language navigation, and the third model finally generated is a visual language navigation model that generates navigation instructions based on video data and language text as an example for the following description.
[0038] The neural network structure of the model includes but is not limited to a feedforward neural network structure, a recurrent neural network structure, etc., and is not limited thereto. Also, the video data is a plurality of continuous frames of images input, and the language text is a navigation problem input. For example, a navigation problem from a starting point "A" to a destination "B".
[0039] It is understandable that when the target task is different, the corresponding first training data set is usually different. Exemplarily, the navigation instruction generation task is to output the corresponding navigation instruction through the acquired video and navigation question. Therefore, the first training data set is usually composed of text, video and text corresponding to the annotated navigation instruction. And the medical consultation task is usually to output the corresponding reply through the acquired interactive text to communicate with the user. Therefore, the first training data set is usually composed of text and annotated replies.
[0040] It should be noted that the first model in this embodiment includes the first encoder and the first basic sub-model for processing data for the target task. Step S101 is only a step for updating the first encoder, so the second model includes the updated second encoder and the first basic sub-model.
[0041] Among them, the first basic sub-model can be a model that is pre-updated based on a small amount of training data, or it can be a basic sub-model with the ability to process data of the target task, or it can be a model obtained by training a basic sub-model with the ability to process data of the target task based on a small amount of training data. There is no limitation on this.
[0042] As an example, it can be considered that when the target task is a navigation instruction generation task, the corresponding first basic sub-model can be a visual language model that can process images and texts. Also, when the target task is a medical consultation task, a legal consultation task, and a text clustering task, the corresponding first basic sub-model can be a model that can process texts. That is, in this embodiment, when the target tasks are different, the corresponding first basic sub-models are also different.
[0043] In this embodiment, in order to improve the ability of the trained first encoder to understand the data of the target task, the above-mentioned first basic sub-model can be a model obtained by re-training a model that has been pre-trained with large-scale data in a vertical field based on a third training data set corresponding to the target task.
[0044] For example, when the target task is a navigation instruction generation task, the model that has been pre-trained with large-scale data in the vertical field can be a mature visual language model. At this time, the first basic sub-model can be a model obtained by training the mature visual language model using the third training data set corresponding to the navigation instruction generation task.
[0045] Among them, since the mature visual language model has certain task prediction capabilities and language understanding capabilities, using the third training data set to train it can transform the general visual language model into the first basic sub-model for generating navigation instructions. In turn, it can provide a basis for the subsequent generation of a third model with higher accuracy.
[0046] It is understandable that since the first basic sub-model is pre-trained based on the third training data set corresponding to the target task, it can be considered that the first basic sub-model has the ability to perform the target task. For example, it has the basic ability to generate navigation instructions. At this time, only updating the first encoder can make the updated first encoder more focused on the generation of encoding vectors for the target task (for example, the navigation instruction generation task), so that it can be more focused on capturing the detailed information required in the navigation field. In turn, the training effect of the third model in the subsequent steps is improved.
[0047] The first encoder includes but is not limited to a text encoder, a graphic encoder, and a visual encoder, and is not limited thereto. The first encoder can be used to encode the first input data in the first training data set that needs to be input into the first basic sub-model. The first basic sub-model can make predictions based on the encoded vectors, and calculate the training loss of the prediction results and the first labeled data in the first training data set to iteratively update the first encoder.
[0048] It should be noted that, on the basis that the first basic sub-model has the ability to process the data of the target task, the first encoder is still added, and only the first encoder is updated when executing step S101 (that is, the first basic sub-model is frozen) for the following purposes:
[0049] 1) In the initial stage, the output of the first basic sub-model after processing the data corresponding to the target task may be relatively simple, lacking complexity and diversity. Simple and repetitive patterns may cause the mature first basic sub-model to collapse during training. In other words, it is unable to effectively learn new complex patterns. Freezing the first basic sub-model can prevent it from being disturbed by the simple first training data set, ensuring its stability and consistency.
[0050] 2) Maintain the stability of the first basic sub-model. The first basic sub-model is usually a model that has been pre-trained with large-scale data in a vertical field and has certain task prediction and language understanding capabilities. Freezing the first basic sub-model can maintain its existing knowledge and capabilities and avoid losing the original performance due to over-adjustment during the fine-tuning process. In other words, the stability of the first basic sub-model can be effectively maintained.
[0051] 3) Focus more on optimizing the first encoder. During the fine-tuning process, keeping the first basic sub-model frozen allows more computing resources and training steps to be focused on optimizing the first encoder. This can accelerate the convergence of the first encoder, improve its ability to understand the data corresponding to the target task, and ultimately improve the performance of the entire model in the target task.
[0052] As an example, the electronic device may update the second basic sub-model in the fourth model based on the third training data set to obtain the first basic sub-model. Then, the first encoder and the first basic sub-model are determined as the first model. Finally, the first encoder in the first model is updated based on the first training data set to obtain the second model.
[0053] In one embodiment, the fourth model includes a second basic sub-model and a first encoder, and the third training data set includes data corresponding to the target task.
[0054] The data structure of the third training data set may be similar to that of the first training data set. For example, the first training data set includes first input data and first labeled data, and the third training data set includes third input data and third labeled data, which will not be described in detail. It should be noted that the data in the third training data set may be the same as or different from the data in the first training data set.
[0055] It should be noted that the second basic sub-model can be considered as a general model, which has not yet been trained with the third training data set corresponding to the target task. That is, the second basic sub-model is only a general model capable of processing the data corresponding to the target task, and does not have the ability to perform the target task. For example, it does not have the ability to generate basic navigation instructions.
[0056] Based on this, in order to enable the first model to have the basic ability to perform the target task, it needs to be trained based on the above-mentioned third training data set.
[0057] The step of updating the second basic sub-model in the fourth model based on the third training data set to obtain the first basic sub-model may specifically be:
[0058] The electronic device encodes the third input data in the third training data set according to the first encoder to generate a third encoding vector. Then, the third encoding vector and the third labeled data in the third training data set are input into the second basic sub-model for model processing to obtain a third prediction loss. Finally, the second basic sub-model is updated based on the third prediction loss to obtain the first basic sub-model.
[0059] The third encoding vector and the third labeled data in the third training data set are input into the second basic sub-model for model processing to obtain the third prediction loss: the second basic sub-model performs model processing on the third encoding vector and outputs a corresponding prediction result. Then, based on the prediction result and the pre-labeled third labeled data, the second prediction loss is calculated.
[0060] Exemplarily, for the navigation instruction generation task, the corresponding third annotation data may be a reply corresponding to the actual navigation instruction. At this time, the prediction result of the second basic sub-model may also be a predicted text corresponding to the predicted navigation instruction. Finally, the third prediction loss may be calculated based on the reply and the predicted text.
[0061] Among them, the loss function for calculating the third prediction loss includes but is not limited to the text distance measurement formula and the image similarity calculation formula, which are not limited to this.
[0062] It is understandable that when the data categories of the prediction results and the third annotated data are different, the loss functions used are usually different. For example, for the third annotated data and the prediction results of the text type, the above text distance measurement formula can be used for calculation; for the third annotated data and the prediction results of the image type, the above image similarity calculation formula can be used for calculation, without limitation.
[0063] Among them, the method of updating the second basic sub-model based on the third training loss includes but is not limited to: gradient descent method, momentum method, adaptive learning rate method, and is not limited to this.
[0064] It is understandable that when the first encoder is an image encoder, the third encoding vector is an image encoding vector; when the first encoder is a visual encoder, the third encoding vector is a video encoding vector, which is not described in detail. Also, in this embodiment, the method of using different first encoders to encode the third input data to generate the third encoding vector is not limited.
[0065] Based on the above description, as an example, the electronic device can update the first encoder in the first model according to the following steps to obtain the second model. The details are as follows:
[0066] The electronic device can encode the first input data in the first training data set according to the first encoder to generate a first encoding vector. Then, the first encoding vector and the first labeled data in the first training data set are input into the first basic sub-model for model processing to obtain a first prediction loss. Finally, the first encoder is updated based on the first prediction loss to generate a second encoder, and the second encoder and the first basic sub-model are determined as the second model.
[0067] Among them, the method of using the first encoder to encode the first input data to generate the first encoding vector is similar to the method of using the first encoder to generate the third encoding vector mentioned above; and the method of the first basic sub-model generating the first prediction loss based on the first encoding vector and the first labeled data is similar to the method of the second basic sub-model generating the third prediction loss; and the method of updating the first encoder based on the first prediction loss is similar to the method of updating the second basic sub-model based on the third prediction loss. The only difference is that one updates the parameters of the first encoder and the other updates the parameters of the second basic sub-model, which will not be described in detail.
[0068] It should be noted that since the video coding vector is a vector obtained by encoding a video composed of multiple frames of images, it can be considered that when the first encoder is a visual encoder, the generated video coding vector can capture the dynamic change information of the scene in more detail than the image coding vector generated by the image encoder from a single-frame static image. In other words, the visual encoder can capture more information.
[0069] Based on this, for the first input data of video type, when the visual encoder is directly used as the first encoder to encode the third input data to obtain a video encoding vector, and the general second basic sub-model is updated based on the video encoding vector and the third annotation data, the generated video encoding vector may be more complex due to the direct encoding of the complex third input data (video data). At this time, since the general second basic sub-model itself does not have the ability to perform the target task. Therefore, in the face of the input of complex video encoding vectors, and because the visual encoder has not yet strengthened the ability to extract detailed information for the target task, it can be considered that the first basic sub-model is obtained by directly using the visual encoder and the third training data set to train the second basic sub-model, and the first basic sub-model training process cannot fully learn and understand the information corresponding to the video encoding vector output by the visual encoder. In turn, the ability of the first basic sub-model to perform the target task is weak and cannot meet the needs of the actual scene.
[0070] Exemplarily, taking the target task of generating navigation instructions as an example, when the visual encoder is directly used to encode the third input data in the third training data set to obtain a video encoding vector, after the second basic sub-model (visual language model) is trained based on the video encoding vector and the third annotation data, the first basic sub-model encoding obtained is usually not used to generate navigation instructions. That is, although the prediction result output by the first basic sub-model is text, it may not be a navigation instruction for navigation. Furthermore, when the S101 step is subsequently executed, the visual encoder is updated based on the first basic sub-model that cannot generate navigation instructions, and the updated visual encoder cannot enhance the ability to extract detailed information in the navigation field. As a result, although the third model generated in the subsequent S102 step can also generate navigation instructions, the accuracy may not be high.
[0071] Based on this, in order to generate a first basic sub-model that can output and execute a target task (e.g., a navigation instruction generation task), when the second basic sub-model is updated based on the third training data set to obtain the first basic sub-model, the third input data in the third training data set can be encoded according to the image encoder to generate an image encoding vector. Then, the image encoding vector and the third labeled data are input into the second basic sub-model for model processing to obtain a third prediction loss, and the second basic sub-model is updated based on the third prediction loss to obtain the first basic sub-model.
[0072] Based on the above description, it can be considered that in the third training data set at this time, the third input data is a single frame image in the video data.
[0073] Among them, since the information captured by the image coding vector generated by the image encoder is less than the information captured by the video coding vector generated by the visual encoder. Therefore, the general second basic sub-model can understand and learn the information of the image coding vector more accurately. Furthermore, training the second basic sub-model based on the image coding vector with less information and the third annotated data can enable the trained first basic sub-model to basically complete the simple target task. That is, the trained first basic sub-model has the ability to perform the target task.
[0074] Exemplarily, the trained first basic sub-model can basically output simple navigation instructions, such as “go down the stairs”, “go straight” and other simple navigation instructions.
[0075] And, after generating the first basic sub-model, since it has been described above that the first input data is video type data, in order to make the finally generated third model more in line with the actual scene (i.e., performing the target task based on the input video type data), before executing the above step S101, it is necessary to determine the visual encoder and the first basic sub-model as the first model to update the visual encoder.
[0076] Specifically, the electronic device can encode the first input data in the first training data set according to the visual encoder to generate a video encoding vector. Then, the video encoding vector and the first labeled data in the first training data set are input into the first basic sub-model for model processing to obtain a first prediction loss. Finally, the visual encoder is updated based on the first prediction loss to generate a second encoder, and the second encoder and the first basic sub-model are determined as the second model.
[0077] Among them, the purpose of updating the visual encoder can refer to the purpose of updating the first encoder described above, which will not be explained again. And, the method of encoding the first input data according to the visual encoder to generate a video encoding vector is similar to the method of using the first encoder to generate the third encoding vector; and, the method of the first basic sub-model generating the first prediction loss based on the video encoding vector and the first annotation data is similar to the method of the second basic sub-model generating the third prediction loss; and, the method of updating the visual encoder based on the first prediction loss is similar to the method of updating the second basic sub-model based on the third prediction loss, the only difference being that one updates the parameters of the visual encoder and the other updates the parameters of the second basic sub-model, which will not be explained in detail.
[0078] It should be added that the above-mentioned method of first using the image encoder to update the second basic sub-model to obtain the first basic sub-model, and then using the visual encoder and the first basic sub-model as the first model is only applicable to the case where the input data when performing the target task contains video-type data. When the input data when performing the target task does not contain video-type data (that is, the input data is only image-type data, or only text-type data), the corresponding first encoder does not need to be replaced.
[0079] Furthermore, after generating the first model including the first basic sub-model, instead of directly using the first training data set, all the model parameters of the first encoder and the first basic sub-model are updated at the same time. The purpose is that since the first encoder is not focused on capturing the detail information required to perform the target task at this time, the encoding vector extracted by the first encoder at this time usually cannot better understand the object motion trajectory and the overall layout of the environment in the video type data. Furthermore, when the first encoder and the first basic sub-model are updated at the same time based on the encoding vector output by the first encoder, the obtained third model cannot improve the ability to extract local detail information and understand the context. In other words, the performance of the third model in performing the target task cannot be improved in the end.
[0080] S102. Update the first basic sub-model in the second model according to the second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
[0081] In one embodiment, the data in the second training data set may be the same as or different from the data in the first training data set, which is not limited.
[0082] In one embodiment, the electronic device may encode the second input data in the second training data set according to the second encoder to generate a target encoding vector. Then, the target encoding vector and the second labeled data in the second training data set are input into the first basic sub-model for model processing to obtain a second prediction loss. Finally, the first basic sub-model is updated based on the second prediction loss to generate a third model.
[0083] Among them, the electronic device can update the first basic sub-model based on the second prediction loss to obtain the target basic sub-model, and then use the target basic sub-model and the second encoder as the third model.
[0084] In one embodiment, the above-mentioned method of updating the first basic sub-model is similar to the above-mentioned method of updating the second basic sub-model, and no further explanation is given.
[0085] It should be noted that encoding the second labeled data based on the second encoder that focuses on capturing the detailed information required to perform the target task can enable the first basic sub-model to better understand and interpret the contextual information in the input data during the training process based on the target encoding vector and the second labeled data. In turn, the performance of the third model in performing the target task is improved.
[0086] It can be understood that, based on the above explanation of the first encoder and the second encoder, when the updated second encoder is a visual encoder, the generated target coding vector is a video coding vector; and when the updated second encoder is an image encoder, the generated target coding vector is an image coding vector. In this embodiment, the type of the second encoder and the corresponding target coding vector is not limited.
[0087] In this embodiment, since the first basic sub-model in the first model has the ability to process data corresponding to the target task. Therefore, even if the first encoder in the first model is updated based on a small amount of the first training data set, the updated second encoder can be able to focus on capturing the detail information required to perform the target task. Then, based on the second encoder that focuses on capturing the detail information required to perform the target task, the third training data set is processed and the first basic sub-model is updated, so that the first basic sub-model can understand the contextual information in the second training data set during the training process. Furthermore, the ability of the final third model to extract local detail information and understand context can be improved, thereby improving the performance of the third model in performing the target task.
[0088] In another embodiment, referring to Figure 2 , Figure 2 This is a schematic diagram of an application scenario in a model training method provided in an embodiment of the present application. The model training method is illustrated by taking an example in which the target task at least includes a navigation instruction generation task for navigation based on visual language, and the third model is used to generate navigation instructions based on video data and language text.
[0089] Specifically, the above model training method can be divided into three stages, namely, a simple instruction generation stage, a visual adaptation stage, and a model adaptation stage.
[0090] In the simple instruction generation stage, the electronic device can update the second basic sub-model (universal visual language model) in the fourth model based on the third training data set to obtain the first basic sub-model.
[0091] It should be noted that, in the simple instruction generation stage, the first encoder included in the fourth model is an image encoder, and includes a second basic sub-model. During the training process, the third training data set may include images, third language text (ie, generating navigation instructions) and corresponding third replies.
[0092] The image is the third input data to be input into the image encoder, and the third language text is the third input data to be input into the second basic sub-model. The third language text and the image encoding vector after the image encoder encodes the third input data are both required to be input into the second basic sub-model, and the second basic sub-model outputs the corresponding third prediction result. Exemplarily, the third prediction result can be Figure 2 The text of "Going down the stairs" in .
[0093] It should be noted that in the entire training stage (the above three stages), the language text (including the above third language text and the language text in other subsequent training stages) can be a text that is pre-set and input into the corresponding basic sub-model (for example, the above second basic sub-model). Therefore, it is not specifically explained in the above example.
[0094] Then, the electronic device needs to calculate the third prediction loss based on the third prediction result and the third reply, and update the second basic sub-model to obtain the first basic sub-model. At this time, the third reply can be considered as the third labeled data.
[0095] It should be noted that, in the simple instruction generation stage, the image encoder is used to analyze and process the input image, and then the general visual language model (second basic sub-model) generates the corresponding replacement text (prediction result) to obtain relatively simple navigation instructions according to the image encoding vector output by the image encoder. In addition, the general second basic sub-model can be initially transformed into the first basic sub-model capable of performing the target task (navigation instruction generation).
[0096] Afterwards, in order to enable the second basic sub-model to recognize contextual information in complex videos and generate more accurate navigation instructions that are more in line with actual scene requirements, the electronic device can use the first basic sub-model and the visual encoder as the first model to perform the above S101 step.
[0097] Specifically, in the visual adaptation stage, the electronic device may, according to the visual encoder, process the first input data ( Figure 2 Then, the first basic sub-model can encode the video encoding vector and the first language text (i.e., Figure 2 The first prediction result corresponding to the navigation instruction generated in the example may be: Figure 2 'Go down the stairs and turn left at the bottom'.
[0098] Among them, the first language text is similar to the third language text mentioned above and will not be explained again.
[0099] Then, the electronic device can calculate the first prediction loss based on the first prediction result and the first labeled data (first answer) in the first training data set, and update the visual encoder to obtain the second encoder. At this time, the first answer can be considered as the first labeled data. Finally, the second encoder and the first basic sub-model are determined as the second model.
[0100] As an example, the formula for calculating the prediction loss can be as follows:
[0101]
[0102] Wherein, Yloss represents the prediction loss (for example, the first prediction loss mentioned above); L represents the preset length of the output sequence z' (that is, the text length when the first prediction result is text); Z ξ Represents the ξth token in the output sequence; z' <ξ represents the token sequence generated before the ξth token (for example, the first prediction result mentioned above); x', y' represent the visual token sequence and text token sequence, respectively.
[0103] In this embodiment, the first training data set and the second training data set may be represented by: {(x, c)}. Wherein, x represents video data in the training data set. For example, first input data of the first training data set and second input data of the second training data set. c represents labeled data in the training data set. For example, first labeled data of the first training data set and second labeled data of the second training data set.
[0104] It should be noted that, in the visual adaptation stage, the purpose of freezing the first basic sub-model to update the visual encoder can be referred to the above explanation, which will not be explained again.
[0105] In the model adaptation stage, in order to obtain the third model that can generate accurate navigation instructions, the visual encoder that can focus on capturing the detailed information required to perform the target task can be frozen, and only the first basic sub-model is updated to obtain the target basic sub-model. Then, the target basic sub-model and the visual encoder are used as the third model.
[0106] Specifically, the visual encoder may process the second input data ( Figure 2 The first basic sub-model can then encode the target encoding vector and the second language text (i.e., Figure 2 In the question: how to get from the departure point to the destination), a second prediction result is generated. For example, the second prediction result can be Figure 2 'Go down the stairs and turn slightly left at the bottom'.
[0107] Among them, the second language text is similar to the third language text mentioned above and will not be explained again.
[0108] Then, the electronic device needs to calculate the second prediction loss based on the second prediction result and the second labeled data (second reply) in the second training data set, and update the first basic sub-model to obtain the target basic sub-model. At this time, the second reply can be considered as the second labeled data. Finally, the target basic sub-model and the visual encoder are determined as the third model.
[0109] In another embodiment, the first annotation data and the second annotation data may be generated by an existing large language model (LLM). Exemplarily, the first training data set and the second training data set may include text descriptions of the video data (first input data and second input data). The large language model may process the text description, infer the answer corresponding to the text description, and determine the answer as the first annotation data and the second annotation data. Alternatively, the first annotation data and the second annotation data may be directly pre-set manually, without limitation.
[0110] It should be noted that based on the visual adaptation stage and the model adaptation stage, the trained third model can better understand the contextual information in the input video, and improve the final third model's ability to extract local detail information and understand the context. In turn, the performance of the third model in performing the target task is improved. For example, the third model can distinguish the slight difference between "go down the stairs, then turn left at the bottom of the stairs" and "go down the stairs, then turn slightly left at the bottom of the stairs."
[0111] See also Figure 3 , Figure 3 is a structural block diagram of a model training device provided in an embodiment of the present application. The modules included in the model training device in this embodiment are used to execute Figure 1 and Figure 2 For details, please refer to the steps in the corresponding embodiment. Figure 1 and Figure 2 as well as Figure 1 and Figure 2 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 3 , the model training device 300 may include: a first updating module 310 and a second updating module 320, wherein:
[0112] The first updating module 310 is used to update the first encoder in the first model based on the first training data set to obtain a second model; the first training data set includes data corresponding to the target task; the first model includes a first encoder and a first basic sub-model for processing the data of the target task; the second model includes the updated second encoder and the first basic sub-model.
[0113] The second updating module 320 is used to update the first basic sub-model in the second model according to the second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
[0114] In one embodiment, the first encoder includes an image encoder and a visual encoder; the model training device 300 also includes:
[0115] The third updating module is used to update the second basic sub-model in the fourth model based on the third training data set to obtain the first basic sub-model; the fourth model includes the second basic sub-model and the image encoder; the third training data set includes data composed of images under the target task.
[0116] The first determination module is used to determine the visual encoder and the first basic sub-model as a first model.
[0117] In one embodiment, the third update module is further used for:
[0118] The third input data in the third training data set is encoded according to the image encoder to generate an image coding vector; the image coding vector and the third labeled data in the third training data set are input into the second basic sub-model for model processing to obtain a third prediction loss; the second basic sub-model is updated based on the third prediction loss to obtain the first basic sub-model.
[0119] In one embodiment, the first training data set includes data composed of videos under the target task; the first updating module 310 is further used to:
[0120] The first input data in the first training data set is encoded according to the visual encoder to generate a video encoding vector; the video encoding vector and the first labeled data in the first training data set are input into the first basic sub-model for model processing to obtain a first prediction loss; the visual encoder is updated based on the first prediction loss to generate a second encoder; the second encoder and the first basic sub-model are determined as a second model.
[0121] In one embodiment, the second updating module 320 is further configured to:
[0122] The second input data in the second training data set is encoded according to the second encoder to generate a target encoding vector; the target encoding vector and the second labeled data in the second training data set are input into the first basic sub-model for model processing to obtain a second prediction loss; the first basic sub-model is updated based on the second prediction loss to generate a third model.
[0123] In one embodiment, the second updating module 320 is further configured to:
[0124] The first basic sub-model is updated based on the second prediction loss to obtain a target basic sub-model; the target basic sub-model and the second encoder are used as the third model.
[0125] In one embodiment, the target task includes at least a navigation instruction generation task for navigation based on visual language, and the third model is used to generate navigation instructions according to video data and language text.
[0126] When it is understood that Figure 3 In the structural block diagram of the model training device shown, each module is used to execute Figure 1 and Figure 2 The steps in the corresponding embodiments, and for Figure 1 and Figure 2 Each step in the corresponding embodiment has been explained in detail in the above embodiment. Figure 1 and Figure 2 as well as Figure 1 and Figure 2 The relevant descriptions in the corresponding embodiments are not repeated here.
[0127] Figure 4 1 is a structural block diagram of an electronic device provided by an embodiment of the present application. Figure 4 As shown, the electronic device 400 of this embodiment includes: a processor 410, a memory 420, and a computer program 430 stored in the memory 420 and executable on the processor 410, such as a program of the model training method. When the processor 410 executes the computer program 430, the steps in each embodiment of the above-mentioned model training method are implemented, such as Figure 1 Alternatively, the processor 410 implements the above when executing the computer program 430 Figure 3 The functions of each module in the corresponding embodiment are, for example, Figure 3 For details on the functions of each module shown, please refer to Figure 3 Related description in the corresponding embodiment.
[0128] Exemplarily, the computer program 430 may be divided into one or more modules, one or more modules are stored in the memory 420, and are executed by the processor 410 to implement the model training method provided in the embodiment of the present application. One or more modules may be a series of computer program instruction segments capable of completing a specific function, and the instruction segment is used to describe the execution process of the computer program 430 in the electronic device 400. For example, the computer program 430 may implement the model training method provided in the embodiment of the present application.
[0129] The electronic device 400 may include, but is not limited to, a processor 410 and a memory 420. Those skilled in the art will appreciate that Figure 4 It is only an example of the electronic device 400 and does not constitute a limitation of the electronic device 400. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0130] The processor 410 may be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0131] The memory 420 may be an internal storage unit of the electronic device 400, such as a hard disk or memory of the electronic device 400. The memory 420 may also be an external storage device of the electronic device 400, such as a plug-in hard disk, a smart memory card, a flash memory card, etc. equipped on the electronic device 400. Furthermore, the memory 420 may also include both an internal storage unit of the electronic device 400 and an external storage device.
[0132] An embodiment of the present application provides a computer-readable storage medium, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the model training method described in the above embodiments is implemented.
[0133] An embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the model training method in each of the above embodiments.
[0134] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A model training method, characterized in that: The method comprises: The first encoder in the first model is updated based on the first training data set to obtain a second model; the first training data set includes data corresponding to the target task; the first model includes the first encoder and a first basic sub-model for processing the data of the target task; the second model includes the updated second encoder and the first basic sub-model; The first basic sub-model in the second model is updated according to a second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
2. The method according to claim 1, characterized in that The first encoder includes an image encoder and a visual encoder; Before the first encoder in the first model is updated based on the first training data set to obtain the second model, the method further includes: The second basic sub-model in the fourth model is updated based on the third training data set to obtain the first basic sub-model; the fourth model includes the second basic sub-model and the image encoder; the third training data set includes data composed of images under the target task; The visual encoder and the first basic sub-model are determined as the first model.
3. The method according to claim 2, characterized in that The updating of the second basic sub-model in the fourth model based on the third training data set to obtain the first basic sub-model includes: Performing encoding processing on the third input data in the third training data set according to the image encoder to generate an image encoding vector; Inputting the image coding vector and the third labeled data in the third training data set into the second basic sub-model for model processing to obtain a third prediction loss; The second basic sub-model is updated based on the third prediction loss to obtain the first basic sub-model.
4. The method according to claim 2, characterized in that: The first training data set includes data composed of videos under the target task; and the updating of the first encoder in the first model based on the first training data set to obtain the second model includes: Encoding the first input data in the first training data set according to the visual encoder to generate a video encoding vector; Inputting the video coding vector and the first labeled data in the first training data set into the first basic sub-model for model processing to obtain a first prediction loss; Update the visual encoder based on the first prediction loss to generate the second encoder; The second encoder and the first base sub-model are determined as the second model.
5. The method according to claim 1, characterized in that The updating of the first basic sub-model in the second model according to the second training data set to obtain the third model includes: Performing encoding processing on the second input data in the second training data set according to the second encoder to generate a target encoding vector; Inputting the target encoding vector and the second labeled data in the second training data set into the first basic sub-model for model processing to obtain a second prediction loss; The first basic sub-model is updated based on the second prediction loss to generate the third model.
6. The method according to claim 5, characterized in that The updating the first basic sub-model based on the second prediction loss to generate the third model comprises: Update the first basic sub-model based on the second prediction loss to obtain a target basic sub-model; The target base sub-model and the second encoder are used as the third model.
7. The method according to any one of claims 1 to 6, characterized in that: The target task at least includes a task of generating navigation instructions for navigation based on visual language, and the third model is used to generate navigation instructions based on video data and language text.
8. A model training device, characterized in that: The device comprises: A first updating module is used to update the first encoder in the first model based on a first training data set to obtain a second model; the first training data set includes data corresponding to the target task; the first model includes the first encoder and a first basic sub-model for processing the data of the target task; the second model includes the updated second encoder and the first basic sub-model; The second updating module is used to update the first basic sub-model in the second model according to a second training data set to obtain a third model; the second training data set includes data corresponding to the target task.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.