Visual language model training method, device, medium and computer program product
By integrating external knowledge and high-frequency features into the visual language model, the problem of poor generalization performance of the visual language model is solved, the processing capabilities and adaptability to complex data are improved, and better adaptability to new environments and overall performance are achieved. .
Patent Information
- Application Number
- CN202411001891.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-25
AI Technical Summary
Existing visual language models have poor generalization performance in downstream tasks, especially for categories not involved in training, and have difficulty capturing high-level detailed information.
By integrating external knowledge into the learnable prompter, the preset prompt words of the image are obtained and encoded, combined with the visual extractor to extract high-frequency features and color features, and the attention mechanism is used to calculate the loss value, training the learnable prompter and vision extractor to improve the generalization ability of the model.
It improves the visual language model's processing capabilities and adaptability to complex data, enhances its performance in new environments, and optimizes overall performance.
Smart Images

Figure CN118520932B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and more specifically, to a visual language model training method, device, medium and computer program product. Background Art
[0002] The Visual Language Model (VLM) demonstrates excellent performance in a variety of visual and language tasks by learning the relationship between images and text, such as image classification, image generation, image retrieval, and natural language description of images. In related technologies, a large number of labeled image-text pairs are used to train the visual language model, but in downstream tasks, the generalization performance of categories that are not involved in the training is poor.
[0003] Therefore, how to improve the generalization ability of the visual language model is a technical problem that technicians in this field need to solve. Summary of the invention
[0004] The purpose of the present invention is to provide a visual language model training method, device, medium and computer program product, which improve the generalization ability of the visual language model.
[0005] To achieve the above object, the present invention provides a visual language model training method, comprising:
[0006] Using a learnable prompter in a visual language model to obtain learnable prompt words of different categories of images, encoding the learnable prompt words of different categories to obtain a first text encoding;
[0007] Obtaining a second text encoding after integrating external knowledge with preset prompt words of different categories of images;
[0008] Calculate a first loss value based on a first text encoding and a second text encoding corresponding to the same category;
[0009] Using the visual extractor in the visual language model to extract visual codes of images of different categories at the visual level, and calculating a second loss value based on the first text code and the visual code corresponding to the same category;
[0010] An overall loss value is calculated based on the first loss value and the second loss value, and the learnable prompter and the visual extractor are trained based on the overall loss value to obtain a trained visual language model.
[0011] The second text encoding after the preset prompt words of different categories of images are obtained by integrating external knowledge includes:
[0012] Acquire preset prompt words for images of different categories, and encode the preset prompt words to obtain a first intermediate text code;
[0013] Encoding the external knowledge base to obtain a second intermediate text encoding;
[0014] Determining a feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text code and the second intermediate text code;
[0015] The first intermediate text encoding and feature representation corresponding to the same category are fused to obtain the second text encoding of the corresponding category.
[0016] Wherein, determining the feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text code and the second intermediate text code includes:
[0017] An attention mechanism is used to obtain feature representation by taking the first intermediate text encoding as a query and the second intermediate text encoding as a key and a value.
[0018] The first intermediate text code and feature representation corresponding to the same category are fused to obtain the second text code of the corresponding category, including:
[0019] The sum of the first intermediate text code and feature representation corresponding to the same category is used as the second text code of the corresponding category.
[0020] The preset prompt word of the image is the category of the image.
[0021] The visual extractor in the visual language model is used to extract visual codes of images of different categories at the visual level, including:
[0022] Extracting high-frequency features of images of different categories using a visual extractor in the visual language model, and determining edge information in the high-frequency features;
[0023] Using the high-frequency adapter in the visual language model to enhance the edge information to obtain enhanced edge information;
[0024] Extracting color features of images of different categories using the color adapter in the visual language model;
[0025] The enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category;
[0026] A deep learning model using an attention mechanism model is used to process the fused features to obtain visual encoding.
[0027] The high-frequency features of images of different categories are extracted using the visual extractor in the visual language model, including:
[0028] The visual extractor in the visual language model is used to perform wavelet transform on images of different categories to extract high-frequency features of images of different categories.
[0029] The step of enhancing the edge information by using the high-frequency adapter in the visual language model to obtain enhanced edge information includes:
[0030] The high-frequency adapter in the visual language model is used to perform convolution operation and normalization processing on the edge information to obtain enhanced edge information.
[0031] The enhanced edge information has the same dimension as the color feature.
[0032] Among them, the enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category, including:
[0033] The sum of the enhanced edge information and color features corresponding to the same category is used as the fusion feature of the corresponding category.
[0034] The second loss value is calculated based on the first text encoding and the visual encoding corresponding to the same category, including:
[0035] The distance between the first text code and the visual code corresponding to the same category is calculated, and the second loss value is calculated based on the distance between the first text code and the visual code corresponding to all categories.
[0036] To achieve the above object, the present invention provides a visual language model training method, comprising:
[0037] Using a learnable prompter in a visual language model to obtain learnable prompt words of different categories of images, encoding the learnable prompt words of different categories to obtain a first text encoding;
[0038] Obtaining a second text encoding after integrating external knowledge with preset prompt words of different categories of images;
[0039] Calculate a first loss value based on a first text encoding and a second text encoding corresponding to the same category;
[0040] Using the visual extractor in the visual language model to extract visual codes of images of different categories at the visual level, and calculating a second loss value based on the first text code and the visual code corresponding to the same category;
[0041] Calculating an overall loss value based on the first loss value and the second loss value, and training the learnable prompter and the visual extractor based on the overall loss value to obtain a pre-trained visual language pre-training model;
[0042] Determine a downstream task, retrain the visual language pre-training model according to the downstream training data corresponding to the downstream task to obtain a trained visual language model, and use the trained visual language model to execute the downstream task and output the execution result of the downstream task; wherein the downstream task includes any one or a combination of any one of an image classification task, an image generation task, an image retrieval task, and a natural language description image task.
[0043] To achieve the above object, the present invention provides a visual language model training device, comprising:
[0044] An encoding module, used for obtaining learnable prompt words of different categories of images by using a learnable prompter in a visual language model, and encoding the learnable prompt words of different categories to obtain a first text encoding;
[0045] An acquisition module, used for acquiring a second text encoding of preset prompt words of different categories of images after integrating external knowledge;
[0046] A first calculation module, used for calculating a first loss value based on a first text code and a second text code corresponding to the same category;
[0047] A second calculation module is used to extract visual codes of images of different categories at a visual level by using a visual extractor in the visual language model, and calculate a second loss value based on the first text code and the visual code corresponding to the same category;
[0048] A training module is used to calculate an overall loss value based on the first loss value and the second loss value, and to train the learnable prompter and the visual extractor based on the overall loss value to obtain a trained visual language model.
[0049] To achieve the above object, the present invention provides an electronic device, comprising:
[0050] Memory for storing computer programs;
[0051] A processor is used to implement the steps of the visual language model training method as described above when executing the computer program.
[0052] To achieve the above-mentioned purpose, the present invention provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the visual language model training method as described above are implemented.
[0053] To achieve the above objectives, the present invention provides a computer program product, including a computer program, which implements the steps of the above-mentioned visual language model training method when executed by a processor.
[0054] It can be seen from the above scheme that a visual language model training method provided by the present invention includes: using a learnable prompter in a visual language model to obtain learnable prompt words for images of different categories, encoding the learnable prompt words of different categories to obtain a first text code; obtaining a second text code after the preset prompt words of different categories of images are integrated with external knowledge; calculating a first loss value based on the first text code and the second text code corresponding to the same category; using a visual extractor in the visual language model to extract visual codes of images of different categories at the visual level, and calculating a second loss value based on the first text code and the visual code corresponding to the same category; calculating an overall loss value based on the first loss value and the second loss value, and training the learnable prompter and the visual extractor based on the overall loss value to obtain a trained visual language model.
[0055] The beneficial effects of the present invention are as follows: the visual language model training method provided by the present invention enriches the knowledge base of the visual language model based on a learnable prompt guided by external knowledge, improves the visual language model's ability to process complex data, and adapts to a changing environment through continuous learning, thereby optimizing the overall performance of the model at multiple levels. By integrating external knowledge, the visual language model not only performs well in scenes that have been seen during training, but can also better adapt and generalize to new, unseen environments, thereby improving the generalization ability of the visual language model. The present invention also discloses a visual language model training device, an electronic device, a non-volatile storage medium, and a computer program product, which can also achieve the above-mentioned technical effects.
[0056] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the present disclosure, but do not constitute a limitation to the present disclosure. In the drawings:
[0058] Figure 1 is a flowchart of a visual language model training method according to an exemplary embodiment;
[0059] Figure 2 The present invention is a flowchart of a method for extracting visual coding of an image according to an exemplary embodiment;
[0060] Figure 3 is a flowchart of another visual language model training method according to an exemplary embodiment;
[0061] Figure 4 is a structural diagram of a visual language model training device according to an exemplary embodiment;
[0062] Figure 5 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0063] 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 a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0064] Prompting in vision-language models is a relatively new research direction, which focuses on how to improve the task adaptability and performance of the model by designing effective prompts. This method draws on the prompt learning method in the field of natural language processing and attempts to extend it to the vision-language model. Its core is to enhance the adaptability of the model to specific tasks or data by guiding the model's attention. The application of this technology not only improves the performance of the model on specific tasks, such as image captioning, visual question answering, and image classification, but also enhances the model's ability to process multimodal data, enabling it to more accurately interpret and generate language information related to images.
[0065] In related technologies, a large number of labeled image-text pairs are used for training. However, in downstream tasks, the generalization performance of categories that are not involved in training is poor. Although learnable prompt words are added, the final result is strongly associated with the task, further weakening the generalization ability of the original model. In addition, the insufficient resolution of the input image makes it difficult for the model to capture and utilize high-level detail information, such as subtle textures, small objects, objects in complex backgrounds, etc. Although the image-text comparison learning strategy can effectively map to text and images, it is difficult to capture more complex and fine-grained visual and language relationships.
[0066] Therefore, without modifying the visual language model, the present invention effectively integrates local and global visual information by integrating general knowledge and specific domain knowledge into learnable prompt words and combining high-frequency local details into visual encoding, thereby improving the performance and applicability of the visual language model.
[0067] The embodiment of the present invention discloses a visual language model training method, which improves the generalization ability of the visual language model.
[0068] See also Figure 1 , according to a flowchart of a visual language model training method shown in an exemplary embodiment, as shown in Figure 1 As shown, including:
[0069] S11: using a learnable prompter in a visual language model to obtain learnable prompt words of different categories of images, and encoding the learnable prompt words of different categories to obtain a first text encoding;
[0070] The purpose of this embodiment is to train a visual language model. The visual language model is an artificial intelligence model that combines computer vision (Computer Vision) and natural language processing (NLP). The training of the visual language model includes two stages, namely the pre-training stage and the fine-tuning stage. In the pre-training stage, it is generally based on an image library, and for a specific model training task, a large-scale neural network algorithm structure is trained to learn and implement it. The final large-scale neural network algorithm structure and parameters are the visual language pre-training model. In the fine-tuning stage, small-scale training is performed for specific task objectives (downstream tasks) and task data (downstream data) to achieve slight adjustments to the parameters of the pre-training model, and finally obtain a model adapted to specific tasks and data. The neural network algorithm structure for visual language model training can be CNN (Convolutional Neural Network), RNN (Recurrent Neural Network), LSTM (Long Short-Term Memory), etc., or it can be a model built with attention network, such as transformer, BERT (Bidirectional Encoder Representations from Transformers), etc., which is not limited in the present invention. Attention network refers to a network model that uses attention mechanism for training. The model extracts more important feature information from the input sequence by assigning different weights to each part of the input sequence, so that the model finally obtains more accurate output.
[0071] In this step, a learnable prompter is used to generate learnable prompt words with categories. , is the i-th variable in the learnable prompt word vector, 1≤i≤m, C is the category, and the learnable prompt word is encoded to obtain the first text encoding.
[0072] S12: obtaining a second text encoding after the preset prompt words of different categories of images are integrated with external knowledge;
[0073] In a specific implementation, preset prompt words for images of different categories, that is, manually designed prompt words, are obtained. The preset prompt words may be specific categories, such as cats, dogs, etc. External knowledge is fused into the preset prompt words, and the preset prompt words after fusion of the external knowledge are encoded to obtain a second text encoding.
[0074] As a feasible implementation method, obtaining a second text code after fusing external knowledge with preset prompt words for images of different categories includes: obtaining preset prompt words for images of different categories, and encoding the preset prompt words to obtain a first intermediate text code; encoding an external knowledge base to obtain a second intermediate text code; determining a feature representation related to the preset prompt words in the external knowledge base based on the first intermediate text code and the second intermediate text code; and fusing the first intermediate text code and feature representation corresponding to the same category to obtain a second text code for the corresponding category.
[0075] In the specific implementation, the preset prompt words text of different categories of images are obtained, and they are encoded to obtain the first intermediate text encoding T. Collect and organize external knowledge, and build an external knowledge base based on the specific object or subject to be identified, which can be obtained through the following ways: online encyclopedia, professional books, professional papers, online courses and databases, expert interviews and technical reports, industry standards and guidelines. Online encyclopedias provide a wide range of information covering almost all fields, professional books delve into detailed knowledge of specific disciplines or industries, professional papers provide the latest research results and scientific discoveries, online courses and databases provide educational resources and a large number of professional data sets, which are suitable for in-depth learning of specific topics, expert interviews and technical reports provide insights and experience from industry leaders and experts, and industry standards and guidelines ensure that the collected information meets current professional and technical standards. Encode the acquired external knowledge ex_text to obtain the second intermediate text encoding Ex.
[0076] Furthermore, the semantic association between the preset prompt word and the external knowledge is learned to determine the feature representation related to the preset prompt word in the external knowledge base. As a feasible implementation, the feature representation related to the preset prompt word in the external knowledge base is determined based on the first intermediate text encoding and the second intermediate text encoding, including: using an attention mechanism to obtain the feature representation with the first intermediate text encoding as a query and the second intermediate text encoding as a key and value.
[0077] In the specific implementation, the cross-attention mechanism can be used to associate external knowledge with preset prompt words to enhance the model's understanding ability, that is, , MultiHeaderAttention is the cross attention mechanism, and attn_out is the calculated feature representation.
[0078] Furthermore, the fusion of the first intermediate text encoding and feature representation not only ensures that the visual language model can extract information from the preset prompt words, but also can dynamically adjust the output according to the needs. As a feasible implementation method, the sum of the first intermediate text encoding and feature representation corresponding to the same category is used as the second text encoding of the corresponding category. That is, the second text encoding Z=T+attn_out.
[0079] It can be seen that the manually set preset prompt words are usually based on general knowledge, which provides a basic semantic framework for the visual language model. External knowledge, especially knowledge in specific fields, introduces depth and context to the visual language model, enabling it to interpret and process data more accurately in specific situations. By integrating extensive general knowledge and deep domain expertise, the visual language model not only performs well in the scenes it has been trained on, but also better adapts and generalizes to new and unseen environments. This fusion is achieved through the cross-attention mechanism, which can effectively integrate information from different sources and optimize the comprehensive utilization of knowledge. When integrating manual prompt words and external knowledge, the cross-attention mechanism can accurately identify and focus on the most critical information, which not only improves processing efficiency, but also reduces the interference of irrelevant information, and further clarifies the decision path of the visual language model.
[0080] S13: Calculating a first loss value based on a first text code and a second text code corresponding to the same category;
[0081] In a specific implementation, a loss value is created between the first text encoding corresponding to the learnable prompt word and the second text encoding corresponding to the preset prompt word that integrates external knowledge. The preset prompt word that integrates external knowledge not only carries additional contextual information in a specific field, but also has more general knowledge than the original manual prompt word. In order to enable the learnable prompt word to have this ability, the distance between the first text encoding and the second text encoding is measured to force the information that the learnable prompt word finally learns to be closer to the preset prompt word that integrates external knowledge.
[0082] As a feasible implementation, calculating the first loss value based on the first text encoding and the second text encoding corresponding to the same category includes:
[0083] The first loss value is calculated based on the first loss function; wherein the first loss function is:
[0084] ;
[0085] in, is the calculated first loss value, is the number of categories, For the i-th category The corresponding first text encoding, is the second text code corresponding to the i-th category. The knowledge contained in manually set prompt words with external knowledge can be learned into constrained and learnable prompt words.
[0086] S14: extracting visual codes of images of different categories at the visual level using the visual extractor in the visual language model, and calculating a second loss value based on the first text code and the visual code corresponding to the same category;
[0087] In a specific implementation, a visual extractor is used to extract the visual encoding V of the image at the visual level, and a contrastive learning method of the encoding is used to calculate the loss between the first text encoding and the visual encoding.
[0088] As a feasible implementation method, the second loss value is calculated based on the first text code and visual code corresponding to the same category, including: calculating the distance between the first text code and visual code corresponding to the same category, and calculating the second loss value based on the distance between the first text code and visual code corresponding to all categories.
[0089] In a specific implementation, the second loss value may be calculated based on a second loss function; wherein the second loss function is:
[0090] ;
[0091] in, is the calculated second loss value, V is the visual encoding, is the number of categories, For the i-th category The corresponding first text encoding, is the label corresponding to the visual encoding, V and The distance between V and The distance between them can be cosine similarity or Euclidean distance. The knowledge contained in the learnable cue words can be combined with visual information to further improve the discriminability of features, thereby improving the generalization ability of the visual language model.
[0092] It can be seen that by jointly using learnable prompt words and the comparative learning mechanism of text and visual information, the understanding ability and feature extraction efficiency of the visual language model when dealing with unknown categories are significantly improved, thereby enhancing the adaptability and overall performance of the visual language model.
[0093] S15: Calculate an overall loss value based on the first loss value and the second loss value, and train the learnable prompter and the visual extractor based on the overall loss value to obtain a trained visual language model.
[0094] In a specific implementation, the overall loss value of the visual language model is constructed based on the first loss value and the second loss value calculated in the above steps, and the learnable prompter and the visual extractor are trained based on the overall loss value. As a feasible implementation, the sum of the first loss value and the second loss value can be used as the overall loss value, that is, , Loss is the overall loss value.
[0095] As another feasible implementation method, a dynamic weight adjustment mechanism is designed for the first loss value and the second loss value, that is, corresponding weights are set for the first loss value and the second loss value respectively, and the weight ratio of the two is automatically adjusted according to the performance during training to optimize the overall loss value and improve the performance of the trained visual language model.
[0096] It should be noted that this embodiment pre-trains the visual language model. Through the scheme of this embodiment, a pre-trained visual language pre-trained model can be obtained, and then the downstream task is determined. The visual language pre-trained model is re-trained according to the downstream training data corresponding to the downstream task to obtain a trained visual language model. The trained visual language model is used to execute downstream tasks and output the execution results of the downstream tasks; wherein the downstream tasks include any one or a combination of image classification tasks, image generation tasks, image retrieval tasks, and natural language description image tasks.
[0097] The visual language model training method provided by the embodiment of the present invention enriches the knowledge base of the visual language model based on the learnable prompter guided by external knowledge, improves the visual language model's ability to process complex data, and adapts to the changing environment through continuous learning, thereby optimizing the overall performance of the model at multiple levels. By integrating external knowledge, the visual language model not only performs well in the scenes seen during training, but can also better adapt and generalize to new and unseen environments, thereby improving the generalization ability of the visual language model.
[0098] The embodiment of the present invention discloses a method for extracting visual coding of an image, which is a further explanation and optimization of step S14 in the previous embodiment. Specifically:
[0099] See also Figure 2 , according to an exemplary embodiment, a flowchart of a method for extracting image visual coding is shown, as shown in Figure 2 As shown, including:
[0100] S141: extracting high-frequency features of images of different categories using a visual extractor in the visual language model, and determining edge information in the high-frequency features;
[0101] In the specific implementation, the visual extractor is used to extract the high-frequency features of the image, including edge, texture and other information, which are important features in image analysis. Extracting these features and enhancing them through high-frequency adapters helps the visual language model learn the detailed features of the image.
[0102] As a feasible implementation, the high-frequency features of images of different categories are extracted using the visual extractor in the visual language model, including: using the visual extractor in the visual language model to perform wavelet transform on images of different categories to extract the high-frequency features of images of different categories. In a specific implementation, the image is subjected to wavelet transform to extract high-frequency information, and the horizontal, vertical, and diagonal portions of the high-frequency information are combined to form edge information E.
[0103] High-frequency information is rich in edge and texture details of images, which are crucial for identifying small objects in images and understanding the structure of complex scenes and their dynamic changes. By integrating these high-frequency details into the global visual information, the visual language model can capture and interpret the visual content more accurately.
[0104] S142: enhancing the edge information by using the high-frequency adapter in the visual language model to obtain enhanced edge information;
[0105] In the specific implementation, a high-frequency adapter is used to enhance and refine the high-frequency information E. The information E after wavelet transformation contains the edge and detail information of the image. The high-frequency adapter is used to further capture these local features, such as corners and edges. These areas can be used as attention areas in the later stage to further improve the model's ability to understand the image.
[0106] As a feasible implementation method, the high-frequency adapter in the visual language model is used to enhance the edge information to obtain the enhanced edge information, including: using the high-frequency adapter in the visual language model to perform convolution operation and normalization processing on the edge information to obtain the enhanced edge information. , For the enhanced edge information, It is Conv2d+LayerNorm, Conv2d is the convolution operation, and LayerNorm is the layer normalization.
[0107] S143: extracting color features of images of different categories using the color adapter in the visual language model;
[0108] In a specific implementation, a color adapter is used to extract the color features of an image, for example, an RGB (red, green, and blue) adapter is used to extract the RGB features of an image, that is, , img is the image, is the extracted color feature. Enhanced edge information With color characteristics have the same dimensions.
[0109] S144: fusing the enhanced edge information and color features corresponding to the same category to obtain a fusion feature of the corresponding category;
[0110] In a specific implementation, the enhanced edge information and color features are fused to form a fusion feature, so that the visual language model can understand the global content while also paying attention to local information. As a feasible implementation method, the enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category, including: taking the sum of the enhanced edge information and color features corresponding to the same category as the fusion features of the corresponding category. That is, , Visual is the fusion feature.
[0111] S145: Using a deep learning model of an attention mechanism model to process the fused features to obtain visual encoding.
[0112] In the specific implementation, the Transformer Block with an attention structure is used to further process the Visual, which not only enhances the dependency between features, but also dynamically adjusts the key points according to the current task, that is, V=Transformer(Visual), where the Transformer has an attention structure and V is the visual encoding obtained by processing.
[0113] It can be seen that through the structure of the attention module, the model can not only strengthen the understanding of the relationship between different areas in the image, but also identify how these areas interact with each other. This understanding ability is more conducive to complex visual tasks, such as scene parsing and multi-object tracking. The Attention mechanism can dynamically adjust its focus according to task requirements, and prioritize and retain the most critical information for completing the current task. This dynamic adjustment capability makes the model more flexible and effective in handling different visual tasks.
[0114] It can be seen that this embodiment improves the performance of the visual language model by superimposing local visual details containing rich high-frequency information on the original global visual representation, thereby integrating local and global visual information without modifying the original VLP architecture.
[0115] Accordingly, the overall training process of the visual language model includes the following steps:
[0116] Using a learnable prompter in a visual language model to obtain learnable prompt words for images of different categories, and using a text encoder to encode the learnable prompt words of different categories to obtain a first text encoding;
[0117] Acquire preset prompt words for images of different categories, and use a text encoder to encode the preset prompt words to obtain a first intermediate text code;
[0118] Encoding the external knowledge base using a text encoder to obtain a second intermediate text encoding;
[0119] Determine, by using an attention mechanism, a feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text encoding and the second intermediate text encoding;
[0120] The first intermediate text encoding and feature representation corresponding to the same category are fused to obtain the second text encoding of the corresponding category;
[0121] Calculate a first loss value based on a first text encoding and a second text encoding corresponding to the same category;
[0122] Using the visual extractor in the visual language model to perform wavelet transform on images of different categories to extract high-frequency features of the images of different categories, and determining edge information in the high-frequency features;
[0123] Using the high-frequency adapter in the visual language model to enhance the edge information to obtain enhanced edge information;
[0124] Extracting color features of images of different categories using the color adapter in the visual language model;
[0125] The enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category;
[0126] A deep learning model of an attention mechanism model is used to process the fused features to obtain a visual encoding;
[0127] Calculate a second loss value based on the first text encoding and the visual encoding corresponding to the same category;
[0128] An overall loss value is calculated based on the first loss value and the second loss value, and the learnable prompter and the visual extractor are trained based on the overall loss value to obtain a trained visual language model.
[0129] The following describes an application embodiment provided by the present invention. Figure 3 ,First, the learnable prompter is guided based on external knowledge, e.g. Figure 3 In the upper part, the manually set prompt words have general knowledge generalization ability, while the external knowledge has specific domain knowledge. The information of the two is fused through the cross-attention mechanism, and the learnable prompt words are used to learn this knowledge, which improves the model's understanding ability and enhances the model's generalization performance. The specific steps are as follows:
[0130] Step 1: Encode the hand-crafted template, i.e. the preset prompt word. Use a transformer structure with multiple self-attention layers to encode the text, i.e. T=TextEncoder(text), where text is the preset prompt word, i.e. a photo of a [class], class is a specific category, such as cat, dog, and T is the result after encoding;
[0131] Step 2: Encode external knowledge. The large visual language model uses a large number of image-text pairs for training, but lacks in-depth understanding of certain and specific contexts. By integrating external knowledge, the model's specific domain knowledge is enhanced and the model's understanding and reasoning capabilities are improved. The specific steps are as follows:
[0132] 2.1. Collect and organize external knowledge and build an external knowledge base. Based on the specific object or subject to be identified, it can be obtained through the following methods:
[0133] Online encyclopedia: provides a wide range of information covering almost all areas;
[0134] Specialized books: These provide in-depth, detailed knowledge on a specific subject or industry.
[0135] Professional papers: provide the latest research results and scientific discoveries.
[0136] Online courses and databases: Provide educational resources and large professional data sets suitable for in-depth learning of specific topics.
[0137] Expert Interviews and Technical Reports: Provide insights and experiences from industry leaders and experts.
[0138] Industry standards and guidelines: Ensure that the information collected complies with current professional and technical standards.
[0139] 2.2. Encode the external knowledge using a method similar to step 1, that is, Ex=TextEncoder(ex_text), ex_text is the collected external knowledge base, and Ex is the result after encoding the external knowledge base.
[0140] Step 3: Encode learnable prompt words. Dynamically adjust and optimize these learnable prompt information to enhance the adaptability of the model for different tasks. , is the i-th variable in the learnable prompt word vector, 1≤i≤m, the learnable prompt word with category , C is the category, and the encoding is performed using a similar method as above, that is, , For learnable prompt words The result after encoding.
[0141] Step 4: Use the cross-attention mechanism to learn the semantic association between the manually set prompt words and external knowledge. Encode the manual prompt words as query, and encode the external knowledge as key and value. Use the cross-attention mechanism to associate external knowledge with the query to enhance the model's understanding ability, that is, , attn_out is the information about the final output of external knowledge Ex by T, and MultiHeaderAttention is the multi-head attention mechanism.
[0142] Step 5: Fuse the manually set prompt word T and attn_out information. This not only ensures that the model can extract information from the manual prompt word, but also dynamically adjust the output according to needs. Here, the simplest way of fusion is used, that is, Z=T+attn_out.
[0143] Step 6: Construct a learnable cue word encoding The loss between the manual prompt word Z with external knowledge and context. The manual prompt word Z with external knowledge not only carries additional context information in a specific field, but also has more general knowledge of the original manual prompt word. In order to enable the learnable prompt word to have this ability, the measurement is used here. The distance between Z forces The information finally learned is closer to Z, that is:
[0144] ;
[0145] in, is the calculated first loss value, is the number of categories, For the i-th category The corresponding first text encoding, is the second text code corresponding to the i-th category.
[0146] It can be seen that the learnable prompts guided by external knowledge greatly enrich the model's knowledge base, improve the model's ability to handle complex data, and adapt to the changing environment through continuous learning, thereby optimizing the overall performance of the model at multiple levels. Learnable prompts guided by external knowledge can enhance understanding ability: Manually set prompts are usually based on general knowledge, providing a basic semantic framework for the model. External knowledge, especially knowledge in specific fields, introduces depth and context to the model, enabling it to interpret and process data more accurately in specific situations. Learnable prompts guided by external knowledge can improve generalization ability: By integrating broad general knowledge and deep domain expertise, the model not only performs well in the scenes it has seen during training, but also better adapts and generalizes to new and unseen environments. This fusion is achieved through the cross-attention mechanism, which can effectively integrate information from different sources and optimize the comprehensive utilization of knowledge. Learnable prompts guided by external knowledge can accurately locate information: The cross-attention mechanism can accurately identify and focus on the most critical information when integrating manual prompts and external knowledge. This not only improves processing efficiency, but also reduces the interference of irrelevant information, further clarifying the decision path of the model.
[0147] Second, visual cues based on high-frequency information, such as Figure 3 As shown in the lower part of , high-frequency information contains a lot of detail information such as edges and textures. By integrating this information into the global visual information and using the attention module, the model can not only enhance its understanding of the relationship and interaction between different regions, but also the attention mechanism can dynamically adjust key points according to the task, focus on and retain these key information, and improve model performance. The specific steps are as follows:
[0148] Step 1: High-frequency adapter. The high-frequency information of the image contains information such as edges and textures, which are important features in image analysis. Extracting these features and strengthening them through high-frequency adapters will help the model learn the detailed features of the image. The specific operations are as follows:
[0149] 1.1. Perform wavelet transform on the input image to extract high-frequency information, and combine the horizontal, vertical and diagonal high-frequency information to form edge information, denoted as E;
[0150] 1.2. Use high-frequency adapters to enhance and refine high-frequency information E. After wavelet transformation, information E contains edge and detail information of the image. High-frequency adapters are used to further capture these local features, such as corners and edges. These areas can be used as attention areas in the later stage to further enhance the model's ability to understand the image, that is, , is the result after processing the high-frequency information E, It is a high-frequency adapter, that is, Conv2d+LayerNorm, Conv2d is the convolution operation, and LayerNorm is the layer normalization.
[0151] Step 2: RGB adapter (visual adapter). The original input image is subjected to similar operations as the high-frequency adapter, namely , is the result after processing the input image img, and and have the same dimensions.
[0152] Step 3: Fusion and , so that the model can understand the global content while also paying attention to the local information, that is, .
[0153] Step 4: Use the Transformer Block with an attention structure to further process the Visual, which not only enhances the dependency between features, but also dynamically adjusts the key points according to the current task, that is, V=Transformer(Visual), where Transformer has an attention structure and V is the result of Visual processed by Transformer. Transformer can use Visual Encoder.
[0154] It can be seen that the visual cue based on high-frequency information provides a powerful visual understanding and processing framework for the model by deeply fusing detail features with global information and using a dynamic attention mechanism, which greatly enhances the performance of the model and its ability to cope with complex visual tasks. Visual cues based on high-frequency information can enhance the ability to perceive details: high-frequency information is rich in edge and texture details of the image, which are crucial for identifying small objects in the image and understanding the structure and dynamic changes of complex scenes. By fusing these high-frequency details into the global visual information, the model can capture and interpret the visual content more accurately. Visual cues based on high-frequency information can improve the understanding of regional relationships: with the support of the attention module, the model can not only strengthen the understanding of the relationship between different regions in the image, but also identify how these regions interact with each other. This understanding ability is very valuable for complex visual tasks such as scene parsing and multi-object tracking. Visual cues based on high-frequency information can dynamically focus on features: the attention mechanism can dynamically adjust its focus according to task requirements, prioritize and retain the most critical information for completing the current task. This dynamic adjustment ability makes the model more flexible and effective in handling different visual tasks.
[0155] This embodiment proposes an adapter device based on a visual language pre-training model, which effectively solves the problem of insufficient generalization ability of the visual language pre-training model when dealing with unseen categories and insufficient attention to local visual information. This strategy integrates general knowledge and specific domain knowledge into learnable cues and adds local details containing high-frequency information in the visual encoding, thereby achieving an effective fusion of local and global visual information without modifying the original VLP architecture. At the model training level, by adopting learnable cues and contrastive learning mechanisms, the feature representation and extraction process is optimized, thereby enhancing the model's ability to handle complex multimodal data and improving the model's adaptability and performance in new domains and unknown categories.
[0156] The model training process is as follows:
[0157] Step 1: Use Text Encoder to encode the learnable prompt words to obtain .
[0158] Step 2: Calculate the loss between the manually set prompt words with external knowledge and the learnable prompt words, that is, guide the learnable prompter to obtain based on external knowledge .
[0159] Step 3: Encode the input image at the visual level to obtain the result V. The specific steps are as follows:
[0160] 3.1. Use wavelet transform to extract high-frequency information of the input image, and then Further enhancing these features, the result is ;
[0161] 3.2 Adoption Extract the features of the input image, the result is ;
[0162] 3.3. The results of the above two steps are integrated and the result V is obtained through a transformer with an attention structure. This not only further enhances the feature relevance, but also improves the applicability and flexibility of the model.
[0163] Step 4: Compute using the encoded contrastive learning method And the loss of V, that is:
[0164] ;
[0165] in, is the calculated second loss value, is the number of categories, For the i-th category The corresponding first text encoding, is the label corresponding to the visual encoding V, V and The distance between V and The distance between them can be cosine similarity or Euclidean distance.
[0166] Step 5: Construct the overall loss of the model, i.e. , The knowledge contained in the manually set prompt words with external knowledge can be learned into the constrained and learnable prompt words, and Combining the knowledge contained in the learnable prompt words with visual information can further improve the feature discrimination ability, thereby improving the generalization ability of the model.
[0167] It can be seen that this embodiment, without modifying the visual language pre-training model, integrates general knowledge and specific domain knowledge into learnable prompt words, and combines high-frequency local details into visual encoding, thereby effectively integrating local and global visual information and improving model performance and applicability.
[0168] A visual language model training device provided by an embodiment of the present invention is introduced below. The visual language model training device described below and the visual language model training method described above can be referenced to each other.
[0169] See also Figure 4 , according to a structural diagram of a visual language model training device shown in an exemplary embodiment, such as Figure 4 As shown, including:
[0170] The encoding module 401 is used to obtain learnable prompt words of different categories of images by using the learnable prompter in the visual language model, and encode the learnable prompt words of different categories to obtain a first text code;
[0171] An acquisition module 402 is used to acquire a second text code after the preset prompt words of different categories of images are integrated with external knowledge;
[0172] A first calculation module 403, configured to calculate a first loss value based on a first text code and a second text code corresponding to the same category;
[0173] A second calculation module 404 is used to extract visual codes of images of different categories at the visual level by using the visual extractor in the visual language model, and calculate a second loss value based on the first text code and the visual code corresponding to the same category;
[0174] The training module 405 is used to calculate the overall loss value based on the first loss value and the second loss value, and train the learnable prompter and the visual extractor based on the overall loss value to obtain a trained visual language model.
[0175] The visual language model training device provided by the embodiment of the present invention enriches the knowledge base of the visual language model based on the learnable prompter guided by external knowledge, improves the visual language model's ability to process complex data, and adapts to the ever-changing environment through continuous learning, thereby optimizing the overall performance of the model at multiple levels. By integrating external knowledge, the visual language model not only performs well in the scenes seen during training, but also can better adapt and generalize to new and unseen environments, thereby improving the generalization ability of the visual language model.
[0176] On the basis of the above embodiments, as a preferred implementation mode, the acquisition module 402 is specifically used to: acquire preset prompt words for images of different categories, and encode the preset prompt words to obtain a first intermediate text code; encode an external knowledge base to obtain a second intermediate text code; determine the feature representation related to the preset prompt words in the external knowledge base based on the first intermediate text code and the second intermediate text code; and fuse the first intermediate text code and feature representation corresponding to the same category to obtain the second text code of the corresponding category.
[0177] Based on the above embodiment, as a preferred implementation mode, the acquisition module 402 is specifically used to: adopt an attention mechanism to obtain feature representation with the first intermediate text encoding as a query and the second intermediate text encoding as a key and a value.
[0178] Based on the above embodiment, as a preferred implementation, the acquisition module 402 is specifically used to: use the sum of the first intermediate text encoding and feature representation corresponding to the same category as the second text encoding of the corresponding category.
[0179] Based on the above embodiment, as a preferred implementation manner, the preset prompt word of the image is the category of the image.
[0180] Based on the above embodiments, as a preferred implementation mode, the second computing module 404 is specifically used to: utilize the visual extractor in the visual language model to extract high-frequency features of images of different categories, and determine edge information in the high-frequency features; utilize the high-frequency adapter in the visual language model to enhance the edge information to obtain enhanced edge information; utilize the color adapter in the visual language model to extract color features of images of different categories; fuse the enhanced edge information and color features corresponding to the same category to obtain fused features of the corresponding category; and utilize the deep learning model of the attention mechanism model to process the fused features to obtain visual coding.
[0181] Based on the above embodiment, as a preferred implementation, the second calculation module 404 is specifically used to: utilize the visual extractor in the visual language model to perform wavelet transform on images of different categories to extract high-frequency features of images of different categories.
[0182] Based on the above embodiment, as a preferred implementation, the second calculation module 404 is specifically used to: use the high-frequency adapter in the visual language model to perform convolution operation and normalization processing on the edge information to obtain enhanced edge information.
[0183] Based on the above embodiment, as a preferred implementation manner, the dimension of the enhanced edge information is the same as that of the color feature.
[0184] Based on the above embodiment, as a preferred implementation, the second calculation module 404 is specifically used to: use the sum of the enhanced edge information and color features corresponding to the same category as the fusion feature of the corresponding category.
[0185] Based on the above embodiments, as a preferred implementation, the second calculation module 404 is specifically used to: calculate the distance between the first text code and the visual code corresponding to the same category, and calculate the second loss value based on the distance between the first text code and the visual code corresponding to all categories.
[0186] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0187] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present invention, the embodiment of the present invention further provides an electronic device, Figure 5 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 5 As shown, the electronic equipment includes:
[0188] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0189] The processor 2 is connected to the communication interface 1 to realize information interaction with other devices, and is used to execute the visual language model training method provided by one or more technical solutions when running a computer program. The computer program is stored in the memory 3.
[0190] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 4.
[0191] The memory 3 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0192] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 3 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.
[0193] The method disclosed in the above embodiment of the present invention can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.
[0194] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present invention are implemented, which will not be described here for the sake of brevity.
[0195] In an exemplary embodiment, the embodiment of the present invention further provides a non-volatile storage medium storing a computer program, which can be executed by the processor 2 to complete the steps of the aforementioned method.
[0196] In an exemplary embodiment, the present invention further provides a computer program product, including a computer program, which is executed by the processor 2 to complete the steps of the aforementioned method.
[0197] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to computer program instructions, and the aforementioned computer program can be stored in a non-volatile storage medium. When the computer program is executed, it executes the steps of the above method embodiments. Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the embodiment of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a non-volatile storage medium and includes a number of instructions for an electronic device (which can be a personal computer, a server, a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention.
[0198] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A visual language model training method, It is characterized in that include: Using a learnable prompter in a visual language model to obtain learnable prompt words of different categories of images, encoding the learnable prompt words of different categories to obtain a first text encoding; Obtaining a second text encoding after integrating external knowledge with preset prompt words of different categories of images; Calculating a first loss value based on a first text encoding and a second text encoding corresponding to the same category; Using the visual extractor in the visual language model to extract visual codes of images of different categories at the visual level, and calculating a second loss value based on the first text code and the visual code corresponding to the same category; Calculating an overall loss value based on the first loss value and the second loss value, and training the learnable prompter and the visual extractor based on the overall loss value to obtain a trained visual language model; The second text encoding after the preset prompt words of different categories of images are obtained by integrating external knowledge includes: Acquire preset prompt words for images of different categories, and encode the preset prompt words to obtain a first intermediate text code; Encoding the external knowledge base to obtain a second intermediate text encoding; Determining a feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text code and the second intermediate text code; The first intermediate text encoding and feature representation corresponding to the same category are fused to obtain the second text encoding of the corresponding category.
2. According to the visual language model training method of claim 1, It is characterized in that Determining a feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text code and the second intermediate text code includes: An attention mechanism is adopted to obtain feature representation by taking the first intermediate text encoding as a query and the second intermediate text encoding as a key and a value.
3. According to the visual language model training method of claim 1, It is characterized in that The first intermediate text encoding and feature representation corresponding to the same category are fused to obtain the second text encoding of the corresponding category, including: The sum of the first intermediate text code and feature representation corresponding to the same category is used as the second text code of the corresponding category.
4. According to the visual language model training method of claim 1, It is characterized in that The preset prompt word of the image is the category of the image.
5. According to the visual language model training method of claim 1, It is characterized in that The visual extractor in the visual language model is used to extract the visual encoding of different categories of images at the visual level, including: Extracting high-frequency features of images of different categories using a visual extractor in the visual language model, and determining edge information in the high-frequency features; Using the high-frequency adapter in the visual language model to enhance the edge information to obtain enhanced edge information; Extracting color features of images of different categories using the color adapter in the visual language model; The enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category; A deep learning model using an attention mechanism model is used to process the fused features to obtain visual encoding.
6. According to the visual language model training method of claim 5, It is characterized in that The visual extractor in the visual language model is used to extract high-frequency features of images of different categories, including: The visual extractor in the visual language model is used to perform wavelet transform on images of different categories to extract high-frequency features of images of different categories.
7. The visual language model training method according to claim 5, It is characterized in that The edge information is enhanced by using a high-frequency adapter in the visual language model to obtain enhanced edge information, including: The high-frequency adapter in the visual language model is used to perform convolution operation and normalization processing on the edge information to obtain enhanced edge information.
8. According to the visual language model training method of claim 7, It is characterized in that The enhanced edge information has the same dimension as the color feature.
9. The visual language model training method according to claim 5, It is characterized in that The enhanced edge information and color features corresponding to the same category are fused to obtain the fusion features of the corresponding category, including: The sum of the enhanced edge information and color features corresponding to the same category is used as the fusion feature of the corresponding category.
10. The visual language model training method according to claim 1, It is characterized in that Calculating a second loss value based on the first text encoding and the visual encoding corresponding to the same category includes: The distance between the first text code and the visual code corresponding to the same category is calculated, and the second loss value is calculated based on the distance between the first text code and the visual code corresponding to all categories.
11. A visual language model training method, It is characterized in that include: Using a learnable prompter in a visual language model to obtain learnable prompt words of different categories of images, encoding the learnable prompt words of different categories to obtain a first text encoding; Obtaining a second text encoding after integrating external knowledge with preset prompt words of different categories of images; Calculate a first loss value based on a first text encoding and a second text encoding corresponding to the same category; Using the visual extractor in the visual language model to extract visual codes of images of different categories at the visual level, and calculating a second loss value based on the first text code and the visual code corresponding to the same category; Calculating an overall loss value based on the first loss value and the second loss value, and training the learnable prompter and the visual extractor based on the overall loss value to obtain a pre-trained visual language pre-training model; Determine a downstream task, retrain the visual language pre-training model according to the downstream training data corresponding to the downstream task to obtain a trained visual language model, and use the trained visual language model to execute the downstream task and output the execution result of the downstream task; wherein the downstream task includes any one or a combination of any one of an image classification task, an image generation task, an image retrieval task, and a natural language description image task; The second text encoding after the preset prompt words of different categories of images are obtained by integrating external knowledge includes: Acquire preset prompt words for images of different categories, and encode the preset prompt words to obtain a first intermediate text code; Encoding the external knowledge base to obtain a second intermediate text encoding; Determining a feature representation related to the preset prompt word in the external knowledge base based on the first intermediate text code and the second intermediate text code; The first intermediate text encoding and feature representation corresponding to the same category are fused to obtain the second text encoding of the corresponding category.
12. An electronic device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the visual language model training method as described in any one of claims 1 to 11 when executing the computer program.
13. A non-volatile storage medium, It is characterized in that The non-volatile storage medium stores a computer program, and when the computer program is executed, the steps of the visual language model training method according to any one of claims 1 to 11 are implemented.
14. A computer program product, It is characterized in that It comprises a computer program, which, when executed, implements the steps of the visual language model training method as claimed in any one of claims 1 to 11.
