Visual language model parameter alignment method, device, storage medium and electronic device

By aligning the parameters of the three-stage training method of the visual encoder and the large language model, the problem of low performance of the visual language model in cross-modal interaction is solved, and more efficient multi-modal task processing capabilities are achieved.

CN118379749BActive Publication Date: 2024-08-27TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410802819.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-08-27
Estimated Expiration
2044-06-20

AI Technical Summary

Technical Problem

Existing visual language models and large language models suffer from low model performance due to misaligned parameter quantities, inconsistent representation, and low connection efficiency during cross-modal interaction.

Method used

Through the three-stage training method of comparative pre-training, generative pre-training and fine-tuning, the parameters of the visual encoder and the large language model are aligned to ensure their efficient performance in cross-modal interaction.

Benefits of technology

The performance of the visual language model in cross-modal interaction is improved, allowing it to be flexibly combined to achieve a wide range of multi-modal task processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118379749B
    Figure CN118379749B
Patent Text Reader

Abstract

The present disclosure relates to the field of large language models, and in particular to a method, device, storage medium and electronic device for aligning parameters of a visual language model, and determines a large language model and a visual encoder after parameter expansion and a training set. The visual encoder and the large language model are connected in parallel to obtain a first training structure, and the first training structure is subjected to comparative pre-training according to the training set. The visual encoder and the large language model after comparative pre-training are connected in series to obtain a second training structure, and the second training structure is subjected to generative pre-training according to the training set. The visual encoder and the large language model after generative pre-training are connected in series with a decoder with fixed parameters to obtain a third training structure, and the visual encoder and the large language model therein are fine-tuned according to the training set. The present disclosure realizes preliminary model parameter alignment by expanding the parameters of the visual encoder, and further performs model training through a three-stage training method, thereby improving the training efficiency and the accuracy of the training results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of large language models, and in particular to a method, device, storage medium and electronic device for aligning parameters of a visual language model. Background Art

[0002] With the rapid development of artificial intelligence, large language models (LLMs) and visual large language models (VLLMs) have become key technologies to promote the development of artificial intelligence, especially artificial general intelligence (AGI) systems. LLMs have led the progress in this field by demonstrating excellent capabilities in open-world language tasks, and their model size and performance are still growing rapidly. VLLMs use the foundation of LLMs to achieve significant breakthroughs in visual-language dialogue and interaction, including tasks such as image classification, video classification, image-text retrieval, image description generation, and multimodal dialogue. However, compared with the rapid progress of LLMs, the development of vision and vision-language foundation models has lagged behind. At present, in order to bridge the visual model with LLMs, existing VLLMs usually use a lightweight "glue" layer, such as QFormer or linear projection, to align the features of the visual and language models, but the related technologies have problems such as misaligned parameters of the visual model and the language model, inconsistent representation, and inefficient connection, which leads to poor performance of the model during cross-modal interaction. Summary of the invention

[0003] In view of this, the present disclosure proposes a visual language model parameter alignment method, device, storage medium and electronic device, aiming to align the parameters of the visual model and the semantic model and improve the model performance in the cross-modal interaction process.

[0004] According to a first aspect of the present disclosure, a method for aligning parameters of a visual language model is provided, the method comprising:

[0005] Determine the large language model and the visual encoder after parameter enlargement;

[0006] Determine a training set including sample images and sample texts corresponding to the sample images;

[0007] The visual encoder and the large language model are connected in parallel to obtain a first training structure, and the visual encoder and the large language model in the first training structure are subjected to comparative pre-training according to the training set;

[0008] Connecting the contrastively pre-trained visual encoder and the large language model in series to obtain a second training structure, and performing generative pre-training on the visual encoder and the large language model in the second training structure according to the training set;

[0009] The generative pre-trained visual encoder and large language model are connected in series with a decoder with fixed parameters to obtain a third training structure, and the visual encoder and large language model in the third training structure are fine-tuned according to the training set to complete parameter alignment of the visual encoder and the large language model.

[0010] In a possible implementation, the large language model is an LLaMA-7B model, and the visual encoder after parameter expansion is an InternViT-6B encoder.

[0011] In a possible implementation, performing comparative pre-training on the visual encoder and the large language model in the first training structure according to the training set includes:

[0012] Inputting sample images in the training set into the visual encoder to obtain image feature vectors, and inputting corresponding sample texts into the large language model to obtain text feature vectors;

[0013] Calculate a first loss of the first training structure according to an image feature vector corresponding to each of the sample images and a text feature vector corresponding to each of the sample texts;

[0014] The parameters of the visual encoder and the large language model are adjusted according to the first loss to complete contrastive pre-training.

[0015] In a possible implementation, the generative pre-training of the visual encoder and the large language model in the second training structure according to the training set includes:

[0016] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0017] The image feature encoding is input into the large language model together with the corresponding sample text after a cross attention mechanism to obtain a text feature vector and a secondary encoded image feature vector;

[0018] Calculate a second loss of the second training structure according to the image feature vector and the text feature vector;

[0019] The parameters of the visual encoder and the large language model are adjusted according to the second loss to complete generative pre-training.

[0020] In a possible implementation, the second loss includes image-text comparison loss, image-text matching loss, and image-guided text generation loss.

[0021] In a possible implementation, fine-tuning the visual encoder and the large language model in the third training structure according to the training set includes:

[0022] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0023] The image feature encoding is input into the large language model after passing through a cross attention mechanism to obtain an image feature vector;

[0024] Inputting the sample image, the image feature vector and the corresponding sample text into the decoder with fixed parameters to obtain corresponding predicted text information;

[0025] Calculating a third loss of the third training structure according to the image feature vector and the predicted text information;

[0026] Parameters of the visual encoder and the large language model are fine-tuned according to the third loss.

[0027] In a possible implementation, the first loss is a cross entropy loss.

[0028] According to a second aspect of the present disclosure, a visual language model parameter alignment device is provided, the device comprising:

[0029] A model determination module, used to determine a large language model and a visual encoder after parameter enlargement processing;

[0030] A training set determination module, used to determine a training set including a sample image and a sample text corresponding to the sample image;

[0031] A first training module, configured to connect the visual encoder and the large language model in parallel to obtain a first training structure, and perform comparative pre-training on the visual encoder and the large language model in the first training structure according to the training set;

[0032] A second training module is used to connect the visual encoder and the large language model after contrastive pre-training in series to obtain a second training structure, and perform generative pre-training on the visual encoder and the large language model in the second training structure according to the training set;

[0033] The third training module is used to connect the generative pre-trained visual encoder and the large language model in series with a decoder with fixed parameters to obtain a third training structure, and fine-tune the visual encoder and the large language model in the third training structure according to the training set to complete parameter alignment of the visual encoder and the large language model.

[0034] In a possible implementation, the large language model is an LLaMA-7B model, and the visual encoder after parameter expansion is an InternViT-6B encoder.

[0035] In a possible implementation, the first training module is further used to:

[0036] Inputting sample images in the training set into the visual encoder to obtain image feature vectors, and inputting corresponding sample texts into the large language model to obtain text feature vectors;

[0037] Calculate a first loss of the first training structure according to an image feature vector corresponding to each of the sample images and a text feature vector corresponding to each of the sample texts;

[0038] The parameters of the visual encoder and the large language model are adjusted according to the first loss to complete contrastive pre-training.

[0039] In a possible implementation, the second training module is further used to:

[0040] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0041] The image feature encoding is input into the large language model together with the corresponding sample text after a cross attention mechanism to obtain a text feature vector and a secondary encoded image feature vector;

[0042] Calculate a second loss of the second training structure according to the image feature vector and the text feature vector;

[0043] The parameters of the visual encoder and the large language model are adjusted according to the second loss to complete generative pre-training.

[0044] In a possible implementation, the second loss includes image-text comparison loss, image-text matching loss, and image-guided text generation loss.

[0045] In a possible implementation, the third training module is further used to:

[0046] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0047] The image feature encoding is input into the large language model after passing through a cross attention mechanism to obtain an image feature vector;

[0048] Inputting the sample image, the image feature vector and the corresponding sample text into the decoder with fixed parameters to obtain corresponding predicted text information;

[0049] Calculating a third loss of the third training structure according to the image feature vector and the predicted text information;

[0050] Parameters of the visual encoder and the large language model are fine-tuned according to the third loss.

[0051] In a possible implementation, the first loss is a cross entropy loss.

[0052] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0053] According to a fourth aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.

[0054] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0055] In an embodiment of the present disclosure, a large language model and a visual encoder after parameter expansion processing, as well as a training set are determined. The visual encoder and the large language model are connected in parallel to obtain a first training structure, and the first training structure is subjected to comparative pre-training according to the training set. The visual encoder and the large language model after comparative pre-training are connected in series to obtain a second training structure, and the second training structure is subjected to generative pre-training according to the training set. The visual encoder and the large language model after generative pre-training are then connected in series with a decoder with fixed parameters to obtain a third training structure, and the visual encoder and the large language model in the third training structure are fine-tuned according to the training set. The present disclosure achieves preliminary model parameter alignment by expanding the parameters of the visual encoder, and further performs model training through a three-stage training method to improve the training efficiency and the accuracy of the training results, thereby achieving parameter alignment of the visual encoder and the large language model, thereby improving the performance of the model during cross-modal interaction, and enabling flexible combination to achieve a wide range of multimodal tasks.

[0056] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0058] Figure 1 A flowchart of a method for aligning visual language model parameters according to an embodiment of the present disclosure is shown.

[0059] Figure 2 A schematic diagram showing a three-step training process according to an embodiment of the present disclosure.

[0060] Figure 3 A schematic diagram of a visual language model parameter alignment device according to an embodiment of the present disclosure is shown.

[0061] Figure 4 A schematic diagram of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0062] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0063] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0064] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0065] The visual language model parameter alignment method of the embodiment of the present disclosure can be performed by an electronic device such as a terminal device or a server. The terminal device can be any fixed or mobile terminal such as a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server can be a single server or a server cluster composed of multiple servers. Any electronic device can implement the visual language model parameter alignment method of the embodiment of the present disclosure by calling a computer-readable instruction stored in a memory by a processor.

[0066] Figure 1 FIG. 5 is a flowchart of a method for aligning visual language model parameters according to an embodiment of the present disclosure. Figure 1 As shown, the visual language model parameter alignment method of the embodiment of the present disclosure may include the following steps S10-S50.

[0067] Step S10: determine the large language model and the visual encoder after parameter enlargement processing.

[0068] In one possible implementation, the electronic device determines the large language model and visual encoder that need to be parameter aligned, and the electronic device can preliminarily align the large language model and the visual encoder at the model parameter scale level by pre-enlarging the parameters of the visual encoder. Parameter expansion refers to increasing the number of parameters so that the number of parameters of the large language model and the visual encoder are the same. Optionally, the visual encoder obtained after parameter expansion in the present disclosure can be an InternViT-6B encoder, which is a Transformer-based visual encoder with 600 million parameters. It can be specially designed to achieve a good balance between performance and efficiency and is suitable for various visual perception tasks. The model structure parameters of the visual encoder can be shown in the following table, where name in the header is the name of the visual encoder, width is the width of the visual encoder, depth is the depth of the visual encoder, MLP is a multi-layer perceptron, #heads is the head network in the visual encoder, and #param (M) is the parameter in the visual encoder:

[0069]

[0070] Optionally, the large language model determined by the electronic device in the embodiment of the present disclosure can be a language middleware QLLaMA, which is a language middleware with 800 million parameters and can be initialized by a pre-trained multi-language LLaMA-7B model. The language middleware can not only provide powerful multi-language representation capabilities, but also serve as a bridge connecting the visual encoder and the ready-made LLM decoder.

[0071] Step S20: Determine a training set including sample images and sample texts corresponding to the sample images.

[0072] In a possible implementation, a training set for training a large language model and a visual encoder for parameter alignment is determined by an electronic device. The training set may include sample images for inputting the visual encoder and sample texts for inputting the large language model, and there is a corresponding relationship between the sample images and the sample texts. Optionally, each sample text may also have a corresponding query vector for information introduction.

[0073] Step S30: The visual encoder and the large language model are connected in parallel to obtain a first training structure, and the visual encoder and the large language model in the first training structure are subjected to comparative pre-training according to the training set.

[0074] In a possible implementation, the visual encoder and the large language model may be trained in steps by an electronic device, wherein the first training process may be a comparative pre-training. In the comparative pre-training process, the electronic device determines that the parallel structure of the visual encoder and the large language model is a first training structure, and trains the visual encoder and the large language model in the first training structure according to the training set.

[0075] Optionally, the process of comparative pre-training may include inputting sample images in the training set into a visual encoder to obtain an image feature vector, and inputting the corresponding sample text into the large language model to obtain a text feature vector. Then, the first loss of the first training structure is calculated based on the image feature vector corresponding to each sample image and the text feature vector corresponding to each sample text, and then the parameters of the visual encoder and the large language model are adjusted according to the first loss to complete the comparative pre-training. Exemplarily, the disclosed embodiment may use large-scale noisy sample images and corresponding sample text pairs for comparative learning to align InternViT-6B (visual encoder) and the pre-trained multilingual LLaMA-7B. Specifically, during the training process, the image is input into InternViT-6B to obtain the corresponding image feature encoding, and then the image feature vector is obtained through the attention pooling mechanism. At the same time, the sample text corresponding to the sample image is input into LLaMA, and the EOS corresponding vector in the text feature encoding is selected to obtain the text feature vector .

[0076] Furthermore, the electronic device determines the image feature vectors corresponding to the plurality of sample images and sample texts. and text feature vector After that, the first loss of the first training structure can be obtained by calculating the cross entropy loss, and the similarity between the image and the text can be maximized by minimizing the first loss. The cross entropy loss can be calculated by the loss function Calculated. is the image feature vector, is the text feature vector, is the cosine similarity between the image feature vector and the text feature vector, P is a set of positive sample pairs, each of which consists of a sample image and a corresponding sample text, and τ is a preset temperature parameter. This loss function encourages the model to assign higher similarity scores to correct (positive sample) image-text pairs (i.e., sample images and sample texts with corresponding relationships), and lower similarity scores to incorrect (negative sample) image-text pairs (i.e., sample images and sample texts without corresponding relationships). By performing contrastive pre-training by minimizing the first loss, the first training structure can learn to effectively distinguish between matching and mismatching image-text sample pairs.

[0077] Step S40: Connect the visual encoder and the large language model after contrastive pre-training in series to obtain a second training structure, and perform generative pre-training on the visual encoder and the large language model in the second training structure according to the training set.

[0078] In a possible implementation, after performing the first step of contrastive pre-training, the electronic device performs the second step of generative pre-training. In this pre-training process, the visual encoder and the large language model after contrastive pre-training are connected in series to obtain a second training structure, and then the visual encoder and the large language model in the second training structure are generatively pre-trained according to the training set.

[0079] Optionally, the generative pre-training process may include inputting a sample image into a visual encoder to obtain a corresponding image feature encoding. The image feature encoding is input into a large language model with the corresponding sample text after a cross-attention mechanism to obtain a text feature vector and an image feature vector after secondary encoding. The second loss of the second training structure is calculated based on the image feature vector and the text feature vector. Then the parameters of the visual encoder and the large language model are adjusted according to the second loss to complete the generative pre-training. Among them, the second loss may include image-text contrast loss, image-text matching loss, and image-guided text generation loss. That is, the visual encoder and the large language model in the embodiment of the present disclosure inherit the weights of the contrastive pre-training, and the visual encoder and the text encoder are changed from the original parallel placement to serial connection to obtain the second training structure. Then generative pre-training is performed. Optionally, the generative pre-training process connects InternViT-6B and QLLaMA and adopts a generative training strategy. QLLaMA adds additional parameters based on LLaMA in the contrastive pre-training stage. This includes newly added trainable query vectors and cross-attention layers. These additional layers are randomly initialized and trained during the generative pre-training phase.

[0080] In the generative pre-training process, the electronic device can input the sample image into InternViT-6B to obtain the image feature code as the image feature code, and then input the query vector corresponding to the sample text input into QLLaMA into QLLaMA, and use the query vector as the query (Query) and the image feature code as the key / value pair (Key / Value) to calculate the cross-attention mechanism, thereby introducing the visual information in the image feature code into the query vector. Different from the comparative pre-training stage, the image feature vector finally output in this stage is and text feature vector All are generated by QLLaMA. The second loss generated in this stage is the sum of the image-text comparison (ITC) loss, image-text matching (ITM) loss, and image-guided text generation (ITG) loss.

[0081] Optionally, the image-text contrast loss can be calculated according to the formula for calculating the first loss in the contrastive pre-training process. Calculated. is the image feature vector, is the text feature vector of the sample text corresponding to (matching) the sample image, is the cosine similarity between the image feature vector and the text feature vector, P is a set of positive sample pairs, each positive sample pair consists of a sample image and a corresponding sample text, and τ is a preset temperature parameter. The image-text matching loss can be used to predict whether the image and text pair match for the binary classification task, which can be calculated according to the formula Calculated. is the image feature vector, is the text feature vector of the sample text corresponding to (matching) the sample image. M is the set of matched image-text pairs, is the sigmoid function, is the text feature vector of the negative sample (i.e., the sample text that does not match).

[0082] Furthermore, in the process of image-guided text generation, the sample image obtains its corresponding image feature encoding through the InternViT-6B model. Subsequently, these image feature encodings interact with the query vector (Query) under the QLLaMA model. In this interaction process, the query vector serves as a query, and the image feature encoding participates in the calculation of the cross-attention mechanism as a key-value pair (Key / Value). The purpose of this step is to effectively introduce the visual information in the sample image into the query vector, providing rich contextual information for subsequent text generation. In this process, the image-guided text generation loss can be defined as the loss based on the next prediction, which can be calculated according to the formula Calculated. Among them, represents the next word generated, represents all word sequences before this. It is the model given the previous sequence Predict the next word under the condition By minimizing , so that the generative pre-trained model can generate text that is more relevant and accurate to the image content.

[0083] Step S50: Connect the generative pre-trained visual encoder and the large language model in series with a decoder with fixed parameters to obtain a third training structure, and fine-tune the visual encoder and the large language model in the third training structure according to the training set.

[0084] In one possible implementation, after further generative pre-training, the electronic device can connect the visual encoder and the large language model after generative pre-training in series with a decoder with fixed parameters to obtain a third training structure, and perform final fine-tuning on the visual encoder and the large language model in the third training structure according to the training set. The fine-tuning process may include inputting a sample image into the visual encoder to obtain a corresponding image feature encoding. The image feature encoding is input into the large language model after a cross-attention mechanism to obtain an image feature vector. The sample image, the image feature vector and the corresponding sample text are then input into a decoder with fixed parameters to obtain the corresponding predicted text information. The third loss of the third training structure is calculated based on the image feature vector and the predicted text information, and the parameters of the visual encoder and the large language model are fine-tuned based on the third loss.

[0085] Optionally, in the supervised fine-tuning stage, the generative pre-trained visual encoder and the large language model are connected to the LLM decoder (such as Vicuna or InternLM) with fixed parameters obtained after pre-training through an MLP layer and supervised fine-tuning is performed. The purpose of the fine-tuning stage in the disclosed embodiment is to use high-quality instruction data to further optimize the performance of the model on specific visual language tasks. The fine-tuning strategy is similar to the training of the plain text model, that is, the model is trained to predict the next token by minimizing the cross entropy loss. In other words, the third loss can be a cross entropy loss. Optionally, the formula for calculating the third loss can be Calculated. Among them, represents the next word generated, represents all word sequences before this. It is the model given the previous sequence Predict the next word under the condition By minimizing , so that the generative pre-trained model can generate text that is more relevant and accurate to the image content.

[0086] Furthermore, in the process of fine-tuning the visual encoder and the large language model, the disclosed embodiments may choose to train only the MLP layer, or train the MLP layer and the QLLaMA simultaneously, depending on whether the original language capability of the LLM is desired to be maintained.

[0087] Figure 2 A schematic diagram of a three-step training process according to an embodiment of the present disclosure is shown. Figure 2 As shown, in the process of aligning parameters of the visual encoder and the large language model, the disclosed embodiment may go through three training processes of contrastive pre-training, generative pre-training, and parameter fine-tuning. Among them, the structure of contrastive pre-training may be a parallel structure of the visual encoder and the large language model, and the training process may determine the first loss by cross-entropy loss, and adjust the parameters according to the first loss. The structure of generative pre-training may be a series structure of the visual encoder and the large language model, and the training process may determine the second loss by image-text contrast loss, image-text matching loss, and image-guided text generation loss, and adjust the parameters according to the second loss. The structure of supervised fine-tuning may be a series structure of the visual encoder, the large language model, and the decoder, and the training process may determine the third loss by cross-entropy loss, and adjust the parameters according to the third loss.

[0088] Based on the above technical features, the disclosed embodiment first realizes preliminary model parameter alignment by expanding the parameters of the visual encoder, and then further improves the training efficiency and the accuracy of the training results through three training stages, so that the trained visual encoder and the large language model can effectively combine visual and language features to process various visual language tasks, such as image classification, image-text retrieval, image subtitle generation, visual question answering, and multimodal dialogue.

[0089] Figure 3 A schematic diagram of a visual language model parameter alignment device according to an embodiment of the present disclosure is shown. Figure 3 As shown, the visual language model parameter alignment device of the embodiment of the present disclosure may include:

[0090] A model determination module 30, for determining a large language model and a visual encoder after parameter enlargement processing;

[0091] A training set determination module 31, used to determine a training set including a sample image and a sample text corresponding to the sample image;

[0092] A first training module 32 is used to connect the visual encoder and the large language model in parallel to obtain a first training structure, and perform comparative pre-training on the visual encoder and the large language model in the first training structure according to the training set;

[0093] A second training module 33 is used to connect the visual encoder and the large language model after contrastive pre-training in series to obtain a second training structure, and perform generative pre-training on the visual encoder and the large language model in the second training structure according to the training set;

[0094] The third training module 34 is used to connect the generative pre-trained visual encoder and the large language model in series with a decoder with fixed parameters to obtain a third training structure, and fine-tune the visual encoder and the large language model in the third training structure according to the training set to complete parameter alignment of the visual encoder and the large language model.

[0095] In a possible implementation, the large language model is an LLaMA-7B model, and the visual encoder after parameter expansion is an InternViT-6B encoder.

[0096] In a possible implementation, the first training module 32 is further configured to:

[0097] Inputting sample images in the training set into the visual encoder to obtain image feature vectors, and inputting corresponding sample texts into the large language model to obtain text feature vectors;

[0098] Calculate a first loss of the first training structure according to an image feature vector corresponding to each of the sample images and a text feature vector corresponding to each of the sample texts;

[0099] The parameters of the visual encoder and the large language model are adjusted according to the first loss to complete contrastive pre-training.

[0100] In a possible implementation, the second training module 33 is further configured to:

[0101] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0102] The image feature encoding is input into the large language model together with the corresponding sample text after a cross attention mechanism to obtain a text feature vector and a secondary encoded image feature vector;

[0103] Calculate a second loss of the second training structure according to the image feature vector and the text feature vector;

[0104] The parameters of the visual encoder and the large language model are adjusted according to the second loss to complete generative pre-training.

[0105] In a possible implementation, the second loss includes image-text comparison loss, image-text matching loss, and image-guided text generation loss.

[0106] In a possible implementation, the third training module 34 is further configured to:

[0107] Inputting the sample image into the visual encoder to obtain a corresponding image feature code;

[0108] The image feature encoding is input into the large language model after passing through a cross attention mechanism to obtain an image feature vector;

[0109] Inputting the sample image, the image feature vector and the corresponding sample text into the decoder with fixed parameters to obtain corresponding predicted text information;

[0110] Calculating a third loss of the third training structure according to the image feature vector and the predicted text information;

[0111] Parameters of the visual encoder and the large language model are fine-tuned according to the third loss.

[0112] In a possible implementation, the first loss is a cross entropy loss.

[0113] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0114] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.

[0115] An embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.

[0116] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.

[0117] Figure 4 1 is a schematic diagram showing an electronic device 1900 according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal device. Figure 4 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0118] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2000. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM or similar.

[0119] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.

[0120] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0121] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the above. The computer-readable storage medium used herein is not to be interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0122] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0123] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect through the Internet). In some embodiments, by using the state information of the computer-readable program instructions to personalize an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.

[0124] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0125] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0126] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0127] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0128] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A method for aligning parameters of a visual language model, characterized in that: The method comprises: Determine the large language model and the visual encoder after parameter enlargement; Determine a training set including sample images and sample texts corresponding to the sample images; The visual encoder and the large language model are connected in parallel to obtain a first training structure, and the visual encoder and the large language model in the first training structure are subjected to comparative pre-training according to the training set; Connecting the contrastively pre-trained visual encoder and the large language model in series to obtain a second training structure, and performing generative pre-training on the visual encoder and the large language model in the second training structure according to the training set; Connecting the generative pre-trained visual encoder and the large language model in series with a decoder with fixed parameters to obtain a third training structure, and fine-tuning the visual encoder and the large language model in the third training structure according to the training set to complete parameter alignment of the visual encoder and the large language model; The step of performing comparative pre-training on the visual encoder and the large language model in the first training structure according to the training set includes: Inputting sample images in the training set into the visual encoder to obtain image feature vectors, and inputting sample texts corresponding to the sample images into the large language model to obtain text feature vectors; Calculate a first loss of the first training structure according to an image feature vector corresponding to each of the sample images and a text feature vector corresponding to each of the sample texts; Adjusting parameters of the visual encoder and the large language model according to the first loss to complete contrastive pre-training; The generative pre-training of the visual encoder and the large language model in the second training structure according to the training set includes: Inputting the sample image into the visual encoder to obtain a corresponding image feature code; The image feature encoding is input into the large language model together with the corresponding sample text after a cross attention mechanism to obtain a text feature vector and a secondary encoded image feature vector; Calculate a second loss of the second training structure according to the image feature vector and the text feature vector; Adjusting parameters of the visual encoder and the large language model according to the second loss to complete generative pre-training; The fine-tuning of the visual encoder and the large language model in the third training structure according to the training set comprises: Inputting the sample image into the visual encoder to obtain a corresponding image feature code; The image feature encoding is input into the large language model after passing through a cross attention mechanism to obtain an image feature vector; Inputting the sample image, the image feature vector and the corresponding sample text into the decoder with fixed parameters to obtain corresponding predicted text information; Calculating a third loss of the third training structure according to the image feature vector and the predicted text information; Parameters of the visual encoder and the large language model are fine-tuned according to the third loss.

2. The method according to claim 1, characterized in that The large language model is the LLaMA-7B model, and the visual encoder after parameter expansion is the InternViT-6B encoder.

3. The method according to claim 1, characterized in that The second loss includes image-text contrast loss, image-text matching loss and image-guided text generation loss.

4. The method according to claim 1, characterized in that: The first loss is the cross entropy loss.

5. A visual language model parameter alignment device, characterized in that: The device comprises: A model determination module, used to determine a large language model and a visual encoder after parameter enlargement processing; A training set determination module, used to determine a training set including a sample image and a sample text corresponding to the sample image; A first training module, configured to connect the visual encoder and the large language model in parallel to obtain a first training structure, and perform comparative pre-training on the visual encoder and the large language model in the first training structure according to the training set; A second training module is used to connect the visual encoder and the large language model after contrastive pre-training in series to obtain a second training structure, and perform generative pre-training on the visual encoder and the large language model in the second training structure according to the training set; A third training module is used to connect the generative pre-trained visual encoder and the large language model in series with a decoder with fixed parameters to obtain a third training structure, and fine-tune the visual encoder and the large language model in the third training structure according to the training set to complete parameter alignment of the visual encoder and the large language model; Wherein, the first training module is further used for: Inputting sample images in the training set into the visual encoder to obtain image feature vectors, and inputting sample texts corresponding to the sample images into the large language model to obtain text feature vectors; Calculate a first loss of the first training structure according to an image feature vector corresponding to each of the sample images and a text feature vector corresponding to each of the sample texts; Adjusting parameters of the visual encoder and the large language model according to the first loss to complete contrastive pre-training; The second training module is further used to: Inputting the sample image into the visual encoder to obtain a corresponding image feature code; The image feature encoding is input into the large language model together with the corresponding sample text after a cross attention mechanism to obtain a text feature vector and a secondary encoded image feature vector; Calculate a second loss of the second training structure according to the image feature vector and the text feature vector; Adjusting parameters of the visual encoder and the large language model according to the second loss to complete generative pre-training; The third training module is further used for: Inputting the sample image into the visual encoder to obtain a corresponding image feature code; The image feature encoding is input into the large language model after passing through a cross attention mechanism to obtain an image feature vector; Inputting the sample image, the image feature vector and the corresponding sample text into the decoder with fixed parameters to obtain corresponding predicted text information; Calculating a third loss of the third training structure according to the image feature vector and the predicted text information; Parameters of the visual encoder and the large language model are fine-tuned according to the third loss.

6. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method described in any one of claims 1 to 4 when executing the instructions stored in the memory.

7. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.