Data processing method, device and equipment and readable storage medium
By dividing media data into unit data and performing causal transformation processing, global compression vectors are generated, which solves the problems of high computational cost and feature loss caused by context window limitations in large visual-language models, achieving more efficient model performance and computational efficiency. .
Patent Information
- Application Number
- CN202410782364.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Due to the limitation of the context window, existing large-scale visual-language models cannot effectively process high-resolution images or videos, resulting in high computational costs and loss of features, and the inability to understand complete contextual information.
By dividing media data into unit media data, performing vector mapping, combining visual and text mapping vectors, and inserting compression mark vectors into the mapping vector sequence, performing causal transformation processing, and generating global compression vectors to characterize the global semantics of the visual mapping vectors, Reduce computational costs and improve model performance.
It effectively reduces computational costs, avoids context loss, improves model performance, enables the model to better understand global context relationships, and reduces computational costs in the inference phase.
Smart Images

Figure CN118644683A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, device, equipment and readable storage medium. Background Art
[0002] Existing large vision-language models (LVLMs) are often limited by a limited context window, which is the length of the longest token sequence input that the model can accept. As the number of input images increases and the resolution improves, the context length of the model becomes the main factor limiting the model's performance.
[0003] In the process of image encoding, a picture is divided into multiple smaller regions, each region is encoded separately, and then the tokens output from each region are concatenated to obtain a token sequence. The token sequence mapped by high-resolution image or video input occupies a huge context length and often needs to be processed in segments, which has high computational cost. If the token sequence is processed in segments, each segment may only contain part of the context, resulting in the model being unable to understand the complete context information. The key information between the two ends of the connection will also be lost during segmentation, which can easily cause feature loss or inability to understand the context, resulting in poor model performance. Summary of the invention
[0004] The embodiments of the present application provide a data processing method, apparatus, device and readable storage medium, which can compress visual mapping vectors, thereby improving model performance while reducing computing costs.
[0005] On the one hand, an embodiment of the present application provides a data processing method, including:
[0006] Divide the business media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the business media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0007] The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0008] Based on the compressed tag vector, the visual compression sequence is causally transformed to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0009] A service result for the business media data is generated based on the global compression vector and the N text mapping vectors.
[0010] Among them, the text information is vector mapped to obtain N text mapping vectors, including:
[0011] Inputting the text information into the target visual compression model, performing text segmentation on the text information in the target visual compression model to obtain a word unit sequence corresponding to the text information; the word unit sequence includes N word units, and a word unit in the word unit sequence refers to the smallest basic unit obtained after the text information is segmented;
[0012] Each word in the word sequence is mapped separately to obtain N text mapping vectors.
[0013] Among them, based on the compressed mark vector, the visual compression sequence is causally transformed to obtain a global compression vector, including:
[0014] inputting the visual compression sequence into a target visual compression model; the target visual compression model includes an attention mask layer;
[0015] Perform a dot multiplication operation on the visual compression sequence and the query parameter matrix to obtain a query matrix, perform a dot multiplication operation on the visual compression sequence and the key parameter matrix to obtain a key matrix, and perform a dot multiplication operation on the visual compression sequence and the value parameter matrix to obtain a value matrix;
[0016] A mask matrix is obtained based on the compressed tag vector. Based on the mask matrix, attention calculation is performed on the query matrix, key matrix and value matrix to obtain a global compressed vector.
[0017] Among them, a mask matrix is obtained based on the compressed tag vector, and attention calculation is performed on the query matrix, key matrix and value matrix based on the mask matrix to obtain a global compressed vector, including:
[0018] Perform a dot multiplication operation on the query matrix and the transposed result of the key matrix to obtain an attention score matrix, generate a mask matrix based on the square root of the dimension value of the key matrix and the attention score matrix, and obtain a mask matrix based on the compressed tag vector and the mask matrix;
[0019] The matrix to be masked is multiplied by the mask matrix to obtain a mask score matrix, the mask score matrix is normalized to obtain a normalized matrix, and the normalized matrix is multiplied by the value matrix to obtain a global compression vector; the mask matrix is used to shield the elements associated with the N text mapping vectors in the matrix to be masked.
[0020] The step of obtaining a mask matrix based on the compressed marker vector and the matrix to be masked includes:
[0021] Generate an initial matrix of M+N+1 rows by M+N+1 columns based on the compressed tag vector, and in the i-th row and j-th column of the initial matrix, if i belongs to the number of rows corresponding to the N text mapping vectors in the matrix to be masked, and j belongs to the number of columns corresponding to the M visual mapping vectors in the matrix to be masked, then set the element in the i-th row and j-th column of the initial matrix to the first mask value;
[0022] The elements in the initial matrix except the elements having the first mask value are set to the second mask value to obtain a mask matrix.
[0023] Among them, based on the compressed mark vector, the visual compression sequence is causally transformed to obtain a global compression vector, including:
[0024] A mask matrix is obtained based on the compressed marker vector, and a causal transformation is performed on the visual compression sequence according to the mask matrix to obtain a global compression vector; the mask matrix is used to shield N text mapping vectors in the visual compression sequence during the causal transformation processing, and the M visual mapping vectors are isolated from the shielded N text mapping vectors.
[0025] The service result for the business media data is generated based on the global compression vector and the N text mapping vectors, including:
[0026] Inputting the global compression vector and the N text mapping vectors into a target visual compression model; the target visual compression model includes a feature understanding layer;
[0027] Based on the feature understanding layer, feature extraction is performed on N text mapping vectors to obtain a text feature sequence, and feature extraction is performed on the global compression vector to obtain a visual feature sequence;
[0028] The prediction probability for the business media data is generated through the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the business media data.
[0029] The arrangement positions of the M visual mapping sequences in the mapping vector sequence are before the arrangement positions of the N text mapping vectors; and the compression mark vector is inserted into the mapping vector sequence to obtain a visual compression sequence, including:
[0030] If the resolution of the business media data is greater than the compression threshold, a compression vector value S is generated based on the resolution of the business media data, and S compression marker vectors are inserted after the arrangement position of the M visual mapping vectors in the mapping vector sequence to obtain a visual compression sequence; S is a positive integer; the S compression marker vectors in the visual compression sequence are located before the N text mapping vectors;
[0031] Based on the compressed tag vector, the visual compression sequence is causally transformed to obtain a global compression vector, including:
[0032] Based on the S compressed marker vectors, the visual compression sequence is causally transformed to obtain the global compression vectors corresponding to the S compressed marker vectors.
[0033] The service media data includes T video frames, T is a positive integer, and the global compression vector includes global compression vectors corresponding to the T video frames respectively; and a service result for the service media data is generated based on the global compression vector and the N text mapping vectors, including:
[0034] Based on the display order of T video frames in the business media data, T global compression vectors are arranged to obtain a global compression sequence, and a service result for the business media data is generated based on the global compression sequence and N text mapping vectors.
[0035] On the one hand, an embodiment of the present application provides another data processing method, including:
[0036] Inputting the media data sample, the question text and the answer label for the media data sample into the initial visual compression model;
[0037] The media data sample is divided into at least two units of media data through the initial visual compression model, each unit of media data is vector-mapped to obtain M visual mapping vectors, and the question text corresponding to the media data sample is vector-mapped to obtain N text mapping vectors; M and N are both positive integers;
[0038] The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0039] Based on the compressed tag vector, the visual compression sequence is causally transformed to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0040] Based on the global compression vector and N text mapping vectors, prediction results corresponding to the media data samples are generated. Based on the prediction results and the answer labels, model parameters of the initial visual compression model are adjusted until the initial visual compression model meets the model convergence conditions, thereby obtaining the target visual compression model; the target visual compression model is used to generate service results for business media data.
[0041] Among them, it also includes:
[0042] Based on the data distribution information corresponding to the media data samples, multimodal public data with data characteristics similar to the data distribution information is obtained, and the visual language model is trained based on the multimodal public data to obtain an initial visual compression model that converges on multiple modalities.
[0043] The prediction result is a label probability distribution; the model parameters of the initial visual compression model are adjusted based on the prediction result and the answer label until the initial visual compression model meets the model convergence condition, and the target visual compression model is obtained, including:
[0044] A label probability distribution is generated based on the answer label, and the relative entropy between the label probability distribution and the predicted probability distribution is determined as the model loss value. The model parameters of the initial visual compression model are adjusted according to the model loss value until the initial visual compression model meets the model training conditions, thereby obtaining the target visual compression model.
[0045] An embodiment of the present application provides a data processing device, including:
[0046] The target encoding module is used to divide the business media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the business media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0047] A target insertion module is used to combine the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, and insert a compressed marker vector into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0048] The target compression module is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0049] The target output module is used to generate a service result for the business media data based on the global compression vector and the N text mapping vectors.
[0050] In a possible implementation, the target encoding module is used to perform vector mapping on the text information, and when N text mapping vectors are obtained, it is specifically used to perform the following operations:
[0051] Inputting the text information into the target visual compression model, performing text segmentation on the text information in the target visual compression model to obtain a word unit sequence corresponding to the text information; the word unit sequence includes N word units, and a word unit in the word unit sequence refers to the smallest basic unit obtained after the text information is segmented;
[0052] Each word in the word sequence is mapped separately to obtain N text mapping vectors.
[0053] In a possible implementation, the target compression module is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector, and when the global compression vector is obtained, it is specifically used to perform the following operations:
[0054] inputting the visual compression sequence into a target visual compression model; the target visual compression model includes an attention mask layer;
[0055] Perform a dot multiplication operation on the visual compression sequence and the query parameter matrix to obtain a query matrix, perform a dot multiplication operation on the visual compression sequence and the key parameter matrix to obtain a key matrix, and perform a dot multiplication operation on the visual compression sequence and the value parameter matrix to obtain a value matrix;
[0056] A mask matrix is obtained based on the compressed tag vector. Based on the mask matrix, attention calculation is performed on the query matrix, key matrix and value matrix to obtain a global compressed vector.
[0057] In a possible implementation, the target compression module is used to obtain a mask matrix based on the compressed tag vector, and based on the mask matrix, perform attention calculation on the query matrix, the key matrix, and the value matrix. When the global compression vector is obtained, it is specifically used to perform the following operations:
[0058] Perform a dot multiplication operation on the query matrix and the transposed result of the key matrix to obtain an attention score matrix, generate a mask matrix based on the square root of the dimension value of the key matrix and the attention score matrix, and obtain a mask matrix based on the compressed tag vector and the mask matrix;
[0059] The matrix to be masked is multiplied by the mask matrix to obtain a mask score matrix, the mask score matrix is normalized to obtain a normalized matrix, and the normalized matrix is multiplied by the value matrix to obtain a global compression vector; the mask matrix is used to shield the elements associated with the N text mapping vectors in the matrix to be masked.
[0060] In a possible implementation, when the target compression module is used to obtain the mask matrix based on the compressed tag vector and the matrix to be masked, it is specifically used to perform the following operations:
[0061] Generate an initial matrix of M+N+1 rows by M+N+1 columns based on the compressed tag vector, and in the i-th row and j-th column of the initial matrix, if i belongs to the number of rows corresponding to the N text mapping vectors in the matrix to be masked, and j belongs to the number of columns corresponding to the M visual mapping vectors in the matrix to be masked, then set the element in the i-th row and j-th column of the initial matrix to the first mask value;
[0062] The elements in the initial matrix except the elements having the first mask value are set to the second mask value to obtain a mask matrix.
[0063] In a possible implementation, the target compression module is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector, and when the global compression vector is obtained, it is specifically used to perform the following operations:
[0064] A mask matrix is obtained based on the compressed marker vector, and a causal transformation is performed on the visual compression sequence according to the mask matrix to obtain a global compression vector; the mask matrix is used to shield N text mapping vectors in the visual compression sequence during the causal transformation processing, and the M visual mapping vectors are isolated from the shielded N text mapping vectors.
[0065] In a possible implementation, when the target output module is used to generate a service result for the business media data based on the global compression vector and the N text mapping vectors, it is specifically used to perform the following operations:
[0066] Inputting the global compression vector and the N text mapping vectors into a target visual compression model; the target visual compression model includes a feature understanding layer;
[0067] Based on the feature understanding layer, feature extraction is performed on N text mapping vectors to obtain a text feature sequence, and feature extraction is performed on the global compression vector to obtain a visual feature sequence;
[0068] The prediction probability for the business media data is generated through the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the business media data.
[0069] In a possible implementation, the arrangement positions of the M visual mapping sequences in the mapping vector sequence are before the arrangement positions of the N text mapping vectors; the target insertion module is used to insert the compressed marker vector into the mapping vector sequence, and when the visual compression sequence is obtained, it is specifically used to perform the following operations:
[0070] If the resolution of the business media data is greater than the compression threshold, a compression vector value S is generated based on the resolution of the business media data, and S compression marker vectors are inserted after the arrangement position of the M visual mapping vectors in the mapping vector sequence to obtain a visual compression sequence; S is a positive integer; the S compression marker vectors in the visual compression sequence are located before the N text mapping vectors;
[0071] The target compression module is used to perform causal transformation on the visual compression sequence based on the compression mark vector. When the global compression vector is obtained, it is specifically used to perform the following operations:
[0072] Based on the S compressed marker vectors, the visual compression sequence is causally transformed to obtain the global compression vectors corresponding to the S compressed marker vectors.
[0073] In a possible implementation, the service media data includes T video frames, where T is a positive integer, and the global compression vector includes global compression vectors corresponding to the T video frames respectively; when the target output module is used to generate a service result for the service media data based on the global compression vector and the N text mapping vectors, it is specifically used to perform the following operations:
[0074] Based on the display order of T video frames in the business media data, T global compression vectors are arranged to obtain a global compression sequence, and a service result for the business media data is generated based on the global compression sequence and N text mapping vectors.
[0075] On the one hand, an embodiment of the present application provides another data processing device, including:
[0076] A sample input module, used for inputting a media data sample, a question text and an answer label for the media data sample into an initial visual compression model;
[0077] An initial encoding module is used to divide the media data sample into at least two units of media data through an initial visual compression model, perform vector mapping on each unit of media data to obtain M visual mapping vectors, and perform vector mapping on the question text corresponding to the media data sample to obtain N text mapping vectors; M and N are both positive integers;
[0078] An initial insertion module is used to combine the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, and insert a compressed marker vector into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0079] An initial compression module is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0080] The model adjustment module is used to generate prediction results corresponding to media data samples based on the global compression vector and N text mapping vectors, and adjust the model parameters of the initial visual compression model based on the prediction results and the answer labels until the initial visual compression model meets the model convergence conditions, thereby obtaining the target visual compression model; the target visual compression model is used to generate service results for business media data.
[0081] In a possible implementation, the sample input module is further configured to perform the following operations:
[0082] Based on the data distribution information corresponding to the media data samples, multimodal public data with data characteristics similar to the data distribution information is obtained, and the visual language model is trained based on the multimodal public data to obtain an initial visual compression model that converges on multiple modalities.
[0083] In a possible implementation, the prediction result is a label probability distribution; the model adjustment module is used to adjust the model parameters of the initial visual compression model based on the prediction result and the answer label until the initial visual compression model meets the model convergence condition and the target visual compression model is obtained, and is specifically used to perform the following operations:
[0084] A label probability distribution is generated based on the answer label, and the relative entropy between the label probability distribution and the predicted probability distribution is determined as the model loss value. The model parameters of the initial visual compression model are adjusted according to the model loss value until the initial visual compression model meets the model training conditions, thereby obtaining the target visual compression model.
[0085] On the one hand, an embodiment of the present application provides a computer device, including: a processor, a memory, and a network interface;
[0086] The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, and the memory is used to store a computer program. When the computer program is executed by the processor, the computer device executes the method provided in the embodiment of the present application.
[0087] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program is suitable for being loaded and executed by a processor so that a computer device having the processor executes the method provided by the embodiment of the present application.
[0088] In one aspect, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in the embodiment of the present application.
[0089] The embodiment of the present application divides the business media data into at least two units of media data, performs vector mapping on each unit of media data, obtains M visual mapping vectors, obtains text information for the business media data, performs vector mapping on the text information, and obtains N text mapping vectors; the M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, a compression mark vector is inserted into the mapping vector sequence, and a visual compression sequence is obtained. The compression mark vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors, and based on the compression mark vector, the visual compression sequence is causally transformed to obtain a global compression vector. A service result for the business media data is generated based on the global compression vector and the N text mapping vectors. By compressing the huge visual mapping vector into a global compressed vector, the vector length of the global compressed vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost. Moreover, the context window occupied by the vector length of the global compressed vector is much smaller than the M visual mapping vectors, and does not need to be limited by the context window of the model. The global compressed vector can represent the global semantics of the M visual mapping vectors, which can enable the model to better understand the global contextual relationship, avoid the problem of context loss or forgetting, and improve the model performance. Moreover, by calculating the global compressed vector with a shorter vector length and the N text mapping vectors in the inference stage, the computing cost can be reduced and the computing efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0091] Figure 1 This is a schematic diagram of a network architecture provided by an embodiment of the present application;
[0092] Figure 2 This is a data processing scenario provided by the embodiment of the present application. Figure 1 ;
[0093] Figure 3 This is a data processing scenario provided by the embodiment of the present application. Figure 2 ;
[0094] Figure 4 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 1 ;
[0095] Figure 5 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 2 ;
[0096] Figure 6 It is a schematic diagram of a model structure provided in an embodiment of the present application;
[0097] Figure 7 This is a data processing scenario provided by the embodiment of the present application. Figure 3 ;
[0098] Figure 8 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 3 ;
[0099] Fig. 9 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 1 ;
[0100] Fig.10 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 2 ;
[0101] Fig.11 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0102] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0103] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0104] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0105] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0106] The solution provided in the embodiments of the present application involves machine learning of artificial intelligence, which is specifically illustrated by the following embodiments.
[0107] See also Figure 1 , Figure 1 Schematic diagram of a network architecture provided by an embodiment of the present application. Figure 1 As shown, the network architecture may include a business server 100 and a terminal device 200, wherein there is a communication connection between the terminal device 200 and the business server 100, and the above communication connection does not limit the connection method, and can be directly or indirectly connected through a wired communication method, or directly or indirectly connected through a wireless communication method, or through other methods, which are not limited in this application.
[0108] like Figure 1 As shown, the terminal device 200 can send the business media data and text information to the business server 100. The business server 200 can build a target visual compression model. The business server 200 can divide the business media data through the target visual compression model to obtain a number of unit media data (Patch), perform vector mapping (Tokenization) on each unit media data to obtain M visual mapping vectors, and perform vector mapping on the text information to obtain N text mapping vectors. For example, the business media data can be a picture, and the text information can be a question text for the picture.
[0109] The business server 100 can combine M visual mapping vectors and N text mapping vectors into a mapping vector sequence, and insert a compression marker vector into the mapping vector sequence to obtain a visual compression sequence. The compression marker vector is a special token in the vocabulary of the target visual compression model used to indicate the causal transformation process (Causal Transformer). The compression marker vector in the visual compression sequence can be located between the M visual mapping vectors and the N text mapping vectors.
[0110] The business server 100 can perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector. The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors. It can be understood that the M visual mapping vectors are compressed into a global compression vector.
[0111] The service server 100 can generate a service result for the service media data based on the global compression vector and the N text mapping vectors, and send the service result to the terminal device 200. Taking the visual question answering field as an example, the text information can be a question text for the service media data, and the service result can be an answer result of the text information.
[0112] It can be understood that in the specific implementation of the present application, the user (object or player) data involved, when the above and following embodiments of the present application are applied to specific products or technologies, needs to obtain user permission or consent, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of the relevant regions.
[0113] Among them, if it is necessary to collect object (such as user, etc.) data in this application, a prompt interface or pop-up window will be displayed before or during the collection. The prompt interface or pop-up window is used to prompt the user that certain data is currently being collected. Only after the user confirms the prompt interface or pop-up window, the relevant steps of data acquisition will be started, otherwise the process will end. Moreover, the acquired user data will be used in reasonable and legal scenarios or purposes. Optionally, in some scenarios where user data needs to be used but has not been authorized by the user, authorization can be requested from the user, and the user data can be used when the authorization is passed.
[0114] The embodiment of the present application can greatly reduce the cache cost by compressing the huge visual mapping vector into a global compression vector, the vector length of the global compression vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, and the context window occupied by the vector length of the global compression vector is much smaller than the M visual mapping vectors, and there is no need to be limited by the context window of the model, and the global compression vector can represent the global semantics of the M visual mapping vectors, which can enable the model to better understand the global contextual relationship, avoid the problem of context loss or forgetting, and improve the model performance. Moreover, by calculating the global compression vector with a shorter vector length and the N text mapping vectors in the reasoning stage, the computing cost can be reduced and the computing efficiency can be improved.
[0115] See also Figure 2 , Figure 2 This is a data processing scenario provided by an embodiment of the present application. Figure 1 .like Figure 2 As shown, the service media data is video data, and the service media data may include video frame data X 0 , ..., video frame data X i , ..., video frame data X n The terminal device 200 may send the service media data and text information to the service server 100 , and the service server 200 may be equipped with a target visual compression model.
[0116] The service server 200 can divide each video frame data in the service media data by using the target visual compression model to obtain a plurality of unit media data (Patch). Figure 3 , Figure 3 This is a data processing scenario provided by an embodiment of the present application. Figure 2 .like Figure 3 As shown, the video frame data X i For example, video frame data X i can be divided into M units of media data, the M units of media data including unit media data P 0 , Unit Media Data P 1 , ..., unit media data P m The service server 100 can perform vector mapping on the M units of media data to obtain the video frame data X i The corresponding M visual mapping vectors, video frame data X i The corresponding M visual mapping vectors may include the visual mapping vector V 0 , visual mapping vector V 1 , ..., visual mapping vector V mThe service server 200 may perform vector mapping on the text information to obtain N text mapping vectors. The N text mapping vectors may include a text mapping vector T 0 , text mapping vector T 1 , ..., text mapping vector T n .
[0117] The service server 100 can process the video frame data X i The corresponding M visual mapping vectors and N text mapping vectors are combined into a mapping vector sequence, which can be expressed as {V 0 ,V 1 ,…,V m ,T 0 ,T 1 ,…,T n}, the service server 100 can insert the compression mark vector [VoCo] into the mapping vector sequence to obtain a visual compression sequence, which can be expressed as {V 0 ,V 0 ,…,V m ,[VoCo],T 0 ,T 1 ,…,T n}. The compressed marker vector [VoCo] is a special token in the vocabulary of the target visual compression model used to indicate causal transformation processing. The compressed marker vector in the visual compression sequence can be located between M visual mapping vectors and N text mapping vectors. The number of compressed marker vectors [VoCo] can be pre-set based on the resolution of the video frame data, for example, it can be 2, and the embodiments of the present application are not limited here.
[0118] like Figure 2 As shown, the service server 100 can compress the video frame data X based on the compression mark vector [VoCo]. i The corresponding visual compression sequence is processed by causal transformation to obtain the video frame data X i The corresponding global compression vector VoCo i,1 and the global compression vector VoCo i,2 The visual mapping vector corresponding to each video frame data can be compressed into two global compression vectors through causal transformation processing. The video frame data in the business media data can be represented as {X 0 ,…,X i ,…,X n}, the global compression vector corresponding to each video frame data can be expressed as {[VoCo 0,1 ,VoCo 0,2 ],…,[VoCo i,1 ,VoCo i,2 ]…,[VoCon,1 ,VoCo n,2 ]}. The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors.
[0119] The service server 100 can generate a service result for the service media data based on the global compression vector of each video frame data and the N text mapping vectors, and send the service result to the terminal device 200. Taking the field of visual content recognition as an example, the text information can be a set of video tags corresponding to the service media data, and the service result can be a video tag to which the service media data belongs.
[0120] The embodiments of the present application can be applied to multiple fields and scenarios. In the field of image description, the service result can be a descriptive text for business image data, providing a natural language description for the image. In the field of visual question answering (VisionQuestion-Answer), the service result can answer questions about text information. In document understanding, the service result can process document images in business image data, perform text recognition (OCR, Optical Character Recognition) and understand the document content.
[0121] When processing video data, the embodiment of the present application obtains a global compression vector by compressing the visual mapping vector corresponding to each video frame data. The global compression vector can form a global compression sequence based on the display order of the video frame data. The global compression sequence contains the temporal relationship between video frames, so that the time dependency and event development relationship between the visual mapping vectors can be captured through the global compression sequence to adapt to the time input and compress the visual mapping vector. Therefore, the temporal relationship between each video frame can be better understood through feature interaction with the text mapping vector, which simplifies the process of understanding video data, improves the accuracy of video understanding, and reduces computational costs.
[0122] See also Figure 4 , Figure 4 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 1 The data processing method can be executed by a computer device, which can be Figure 1 The business server 100 shown in FIG. 1 is a diagram showing a data processing method executed by a computer device. The data processing method may include at least the following steps S101 to S104:
[0123] Step S101, dividing the business media data into at least two unit media data, performing vector mapping on each unit media data to obtain M visual mapping vectors, obtaining text information for the business media data, performing vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0124] Specifically, the computer device may divide the service media data into several units of media data, and perform vector mapping (mapping processing) on each unit of media data to obtain M visual mapping vectors. The M visual mapping vectors may be expressed as V = {V 0 ,V 1 ,…,V m}, the computer device can perform vector mapping on the text information to obtain N text mapping vectors. The N text mapping vectors can be expressed as T = {T 0 ,T 1 ,…,T n For example, the business media data may be a picture, and the text information may be a question text regarding the picture.
[0125] Step S102, combining the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, inserting a compressed marker vector into the mapping vector sequence, and obtaining a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0126] Specifically, the computer device may combine M visual mapping vectors and N text mapping vectors into a mapping vector sequence, and the mapping vector sequence may be represented as {V 0 ,V 1 ,…,V m ,T 0 ,T 1 ,…,T n}, the computer device inserts the compressed marker vector into the mapping vector sequence to obtain a visual compression sequence. The visual compression sequence X can be expressed as X = {V 0 ,V 0 ,…,V m ,[VoCo],T 0 ,T 1 ,…,T n}. [VoCo] is a compression token vector, which is a special token in the vocabulary of the target visual compression model used to indicate causal transformation processing. The compression token vector in the visual compression sequence can be located between the M visual mapping vectors and the N text mapping vectors.
[0127] Step S103, based on the compression mark vector, causal transformation processing is performed on the visual compression sequence to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0128] Specifically, the computer device can obtain a mask matrix based on the compressed marker vector, and perform causal transformation processing on the visual compression sequence through the mask matrix to obtain a global compression vector. The global compression vector is used to represent the global semantics of M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors. The mask matrix is used to shield the N text mapping vectors in the visual compression sequence during the causal transformation processing. The M visual mapping vectors are isolated from the shielded N text mapping vectors, so that the visual mapping vector receives continuous attention from the compressed marker vector, thereby realizing compression of the visual mapping vector to the global compression vector.
[0129] Step S104: Generate a service result for the business media data based on the global compression vector and the N text mapping vectors.
[0130] Specifically, the computer device can input the global compression vector and N text mapping vectors into the feature understanding layer, perform feature extraction on the N text mapping vectors through the feature understanding layer to obtain a text feature sequence, and perform feature extraction on the global compression vector to obtain a visual feature sequence. The prediction probability for the business media data is generated through the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the business media data. The process of generating the service result for the business media data based on the global compression vector and the N text mapping vectors can be the same as the process of understanding the tokon of the image and the token of the text by the visual language model (LVLMs) or the large language model (LLM, Large Language Model), and the embodiments of the present application will not be repeated here.
[0131] The embodiment of the present application divides the business media data into at least two units of media data, performs vector mapping on each unit of media data, obtains M visual mapping vectors, obtains text information for the business media data, performs vector mapping on the text information, and obtains N text mapping vectors; the M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, a compression mark vector is inserted into the mapping vector sequence, and a visual compression sequence is obtained. The compression mark vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors, and based on the compression mark vector, the visual compression sequence is causally transformed to obtain a global compression vector. A service result for the business media data is generated based on the global compression vector and the N text mapping vectors. By compressing the huge visual mapping vector into a global compressed vector, the vector length of the global compressed vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost. Moreover, the context window occupied by the vector length of the global compressed vector is much smaller than the M visual mapping vectors, and does not need to be limited by the context window of the model. The global compressed vector can represent the global semantics of the M visual mapping vectors, which can enable the model to better understand the global contextual relationship, avoid the problem of context loss or forgetting, and improve the model performance. Moreover, by calculating the global compressed vector with a shorter vector length and the N text mapping vectors in the inference stage, the computing cost can be reduced and the computing efficiency can be improved.
[0132] See also Figure 5 , Figure 5 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 2 The data processing method can be executed by a computer device, which can be Figure 1 The business server 100 shown. The following will take the data processing method executed by a computer device as an example for description. The data processing method may at least include the following steps S201-S205:
[0133] Step S201, dividing the business media data into at least two unit media data, performing vector mapping on each unit media data to obtain M visual mapping vectors, obtaining text information for the business media data, performing vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0134] Specifically, the computer device can divide the business media data to obtain a number of unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, and perform vector mapping on the text information to obtain N text mapping vectors. Taking the vector mapping of text information as an example, the process of performing vector mapping on the text information to obtain N text mapping vectors may include: inputting the text information into the target visual compression model, performing text splitting on the text information in the target visual compression model to obtain a word unit sequence corresponding to the text information; the word unit sequence includes N words, and a word unit in the word unit sequence refers to the smallest basic unit obtained after the text information is split; each word unit in the word unit sequence is mapped to obtain N text mapping vectors.
[0135] For more details, please join us. Figure 6 , Figure 6 is a schematic diagram of a model structure proposed in the embodiment of the present application, such as Figure 6 As shown, the target visual compression model (VoCo-LLaMA) includes an attention mask layer and a feature understanding layer. The feature understanding layer may include a pooling layer, an attention layer, a normalization layer, and an output layer for feature fusion and result output in LVLMs or LLMs. The feature understanding layer can be used to generate a text sequence describing an image, and the embodiments of the present application are not repeated here. The computer device can input text information into the target visual compression model, perform text splitting (tokenization) on the text information, and obtain a word unit sequence corresponding to the text information. For example, if the text information is "Let's do tokenization!", the word unit sequence corresponding to the text information can be expressed as [Let,'s,do,tokenization]. Among them, [Let,'s], [do], [token], and [ization] are all word units. A word unit in a word unit sequence refers to the smallest basic unit obtained after the text information is split. The computer device can map each word unit in the word unit sequence separately to obtain N text mapping vectors. The text splitting method may be word-based, character-based, or subword-based, which is not limited in the present application embodiment.
[0136] In the target visual compression model, the computer device may perform data division on the business media data to obtain a plurality of unit media data, and the data division method may be determined based on the resolution. For example, if the size of the business media data is 48 pixels × 48 pixels, the computer device may divide the business media data into 9 image units, and each image unit may be 16 pixels × 16 pixels in ratio. The computer device may perform vector mapping on the unit media data based on the vocabulary to obtain M visual mapping vectors.
[0137] Step S202, combining the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, inserting a compressed marker vector into the mapping vector sequence, and obtaining a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0138] Specifically, the computer device can combine M visual mapping vectors and N text mapping vectors into a mapping vector sequence, and insert the compression mark vector [VoCo] into the mapping vector sequence to obtain a visual compression sequence. The mapping vector sequence can be expressed as {V 0 ,V 1 ,…,V m ,T 0 ,T 1 ,…,T n}. The visual compression sequence can be expressed as {V 0 ,V 0 ,…,V m ,[VoCo],T 0 ,T 1 ,…,T n}.
[0139] Optionally, if the resolution of the business media data is greater than the compression threshold, the computer device may generate a compression vector value S based on the resolution of the business media data, and insert S compression marker vectors after the arrangement position of the M visual mapping vectors in the mapping vector sequence to obtain a visual compression sequence. The S compression marker vectors in the visual compression sequence are located before the N text mapping vectors. If the compression vector value S is 2, the visual compression sequence can be expressed as {V 0 ,V 0 ,…,V m ,[VoCo 1 ],[VoCo 2 ],T 0 ,T 1 ,…,T n}.
[0140] Step S203, inputting the visual compression sequence into a target visual compression model; the target visual compression model includes an attention mask layer; performing a dot multiplication operation on the visual compression sequence and a query parameter matrix to obtain a query matrix, performing a dot multiplication operation on the visual compression sequence and a key parameter matrix to obtain a key matrix, and performing a dot multiplication operation on the visual compression sequence and a value parameter matrix to obtain a value matrix;
[0141] Specifically, the computer device can input the visual compression sequence into the attention mask layer, and the visual compression sequence X can be expressed as X = {V 0 ,V 0 ,…,V m ,[VoCo],T 0 ,T 1 ,…,T n}, the attention mask layer can include the query parameter matrix W Q , key parameter matrix W K Sum parameter matrix W V . Query parameter matrix W Q , key parameter matrix W K Sum parameter matrix W V are all matrices composed of learnable parameters in the attention mask layer, query parameter matrix W Q , key parameter matrix W K Sum parameter matrix W V The matrix dimension of can be smaller than the length of the visual compression sequence.
[0142] The computer device combines the visual compression sequence X with the query parameter matrix W Q Perform a dot multiplication operation to obtain the query matrix Q, and combine the visual compression sequence X with the key parameter matrix W K Perform a dot multiplication operation to obtain the key matrix K, and combine the visual compression sequence X with the value parameter matrix W V Perform a dot multiplication operation to obtain the value matrix V. The process can be shown as formula (1):
[0143] Q,K,V=[W Q ,W K ,W V ]·X Formula (1)
[0144] Step S204, perform a dot multiplication operation on the transpose operation results of the query matrix and the key matrix to obtain an attention score matrix, generate a mask matrix based on the square root of the dimension value of the key matrix and the attention score matrix, and obtain a mask matrix based on the compressed tag vector and the matrix to be masked; perform a dot multiplication operation on the matrix to be masked and the mask matrix to obtain a mask score matrix, normalize the mask score matrix to obtain a normalized matrix, and perform a dot multiplication operation on the normalized matrix and the value matrix to obtain a global compression vector; the mask matrix is used to shield the elements in the matrix to be masked that are associated with N text mapping vectors.
[0145] Specifically, the computer device can perform the transposition operation result K of the query matrix Q and the key matrix T Perform a dot multiplication operation to obtain the attention score matrix. Based on the dimension value d of the key matrix K K The square root of The mask matrix M is obtained based on the compressed tag vector [VoCo] and the mask matrix. Specifically, the computer device can generate an initial matrix of M+N+1 rows by M+N+1 columns based on the compressed tag vector. In the i-th row and j-th column of the initial matrix, if i belongs to the number of rows corresponding to the N text mapping vectors in the mask matrix, and j belongs to the number of columns corresponding to the M visual mapping vectors in the mask matrix, then the element in the i-th row and j-th column of the initial matrix is set to the first mask value. The first mask value can be False or 0 for indicating a fill value.
[0146] In the i-th row and j-th column of the initial matrix, if i belongs to the row number corresponding to the N text mapping vectors in the matrix to be masked, and j belongs to the column number corresponding to the compressed tag vector [VoCo] in the matrix to be masked, then the element in the i-th row and j-th column of the initial matrix is set to the second mask value. The second mask value can be True or 1 for representing a true value. The computer device can set the elements in the initial matrix except the elements with the first mask value to the second mask value to obtain a mask matrix. Among them, the mask matrix is used to mask the elements associated with the N text mapping vectors in the matrix to be masked. For the element M in the i-th row and j-th column of the mask matrix M ij , the above process can be shown as formula (2):
[0147]
[0148] Among them, the mask matrix M∈R (M+N+S)×(M+N+S) , S is the compressed vector value, that is, the number of compressed label vectors [VoCo], and R is a real number set.
[0149] The computer device performs a point multiplication operation on the mask matrix and the mask matrix M to obtain a mask score matrix, normalizes the mask score matrix (softmax) to obtain a normalized matrix, and performs a point multiplication operation on the normalized matrix and the value matrix to obtain a global compression vector VoCo T , the process can be shown as formula (3):
[0150]
[0151] Please join us Figure 7 , Figure 7 is a schematic diagram of a data processing scenario proposed in an embodiment of the present application, such as Figure 7 As shown, by visual compression sequence {V 0 ,V 1 ,…,V m-1 ,V m ,[VoCo],T 0 ,…,T n} For causal transformation processing, the mask matrix M can be set to a lower left triangular matrix to shield the N text mapping vectors in the visual compression sequence during the causal transformation processing, so that the M visual mapping vectors in the visual compression sequence are isolated from the shielded N text mapping vectors. The attention weight between the text mapping vector and the visual mapping vector can be set to False through the mask matrix M, which can effectively "isolate" the text mapping vector from the visual mapping vector, so that the visual mapping vector receives the continuous attention of the compression mark vector [VoCo], and the compression of the visual mapping vector to the global compression vector is realized.
[0152] It can be understood that when the computer device inserts multiple compressed marker vectors into the mapping vector sequence, the attention result vector obtained by performing attention mask calculation on the obtained visual compression sequence is an attention result matrix, and each dimension in the attention result matrix corresponds to a global compression vector. For example, the computer device can insert 2 compressed marker vectors into the mapping vector sequence, and the obtained attention result matrix has 2 dimensions, each dimension corresponds to a global compression vector, and the attention result matrix can also be called a global compression sequence. The length of the global compression vector is affected by the matrix dimension of the query parameter matrix. The length corresponding to each dimension in the matrix dimension of the query parameter matrix can be much smaller than the length of the visual compression sequence. The computer device can also control the length of the global compression vector by adjusting the matrix dimension of the query parameter matrix to ensure that the length of the global compression vector is much smaller than the length of the visual compression sequence.
[0153] Step S205, inputting the global compression vector and N text mapping vectors into the target visual compression model; the target visual compression model includes a feature understanding layer; based on the feature understanding layer, performing feature extraction on the N text mapping vectors to obtain a text feature sequence, performing feature extraction on the global compression vector to obtain a visual feature sequence; generating a prediction probability for the business media data through the text feature sequence and the visual feature sequence, and determining the prediction result with the maximum prediction probability as the service result for the business media data.
[0154] Specifically, the computer device can input the global compression vector and N text mapping vectors into the feature understanding layer, and through the feature understanding layer, perform feature extraction on the N text mapping vectors to obtain a text feature sequence, and perform feature extraction on the global compression vector to obtain a visual feature sequence.
[0155] The prediction probability for the business media data is generated by the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the business media data. The process of generating the service result for the business media data based on the global compression vector and N text mapping vectors can be the same as the process of understanding the tokon of the image and the token of the text by the visual language model (LVLMs) or the large language model (LLM), and the embodiments of the present application will not be repeated here.
[0156] It can be understood that when processing the input of repeated business media data, the output of the activation function of the global compression vector corresponding to the repeated business media data in the Transformer can be stored. The global compression vector is shorter in length and more densely represented, which can improve the computational efficiency during activation function processing. The target visual compression model can cache and reuse the global compression vector. Compared with the visual mapping vector, the computer device can reuse the output of the activation function, which can improve the cache efficiency.
[0157] Optionally, if the service media data includes T video frames, T is a positive integer, and the T video frames can be represented as {X 0 ,…,X i ,…,X T}, the computer device can divide each video frame data in the business media data to obtain the unit media data corresponding to each video frame data, perform vector mapping on the unit media data of each video frame data to obtain the visual mapping vector corresponding to each video frame data, perform vector mapping on the text information corresponding to the business media data to obtain the text mapping vector corresponding to the business media data, and the computer device can insert a compression mark vector into the mapping vector sequence corresponding to each video frame data to obtain a visual compression sequence corresponding to each video frame data, perform causal transformation processing on the visual compression sequence to obtain a global compression vector corresponding to each video frame data. The process of obtaining a global compression vector by calculating the attention mask can be the same as the process of steps S202 to S203 above. The computer device can arrange the T global compression vectors based on the display order of the T video frames in the business media data to obtain a global compression sequence. The global compression sequence F can be expressed as F={VoCo 1 ,VoCo 2 ,…,VoCo n The computer device may generate a service result for the business media data based on the global compression sequence and the N text mapping vectors.
[0158] It can be understood that when the target visual compression model inputs business media data including T video frames, a global compression vector can be obtained by compressing the visual mapping vector corresponding to each video frame data. The global compression vector can form a global compression sequence based on the display order of the video frame data. The global compression sequence contains the temporal relationship between video frames, so that the time dependency and event development relationship between the visual mapping vectors can be captured through the global compression sequence to adapt to the time input and compress the visual mapping vector. Therefore, the temporal relationship between each video frame can be better understood through feature interaction between the global compression sequence and the text mapping vector, which simplifies the process of understanding video data, improves the accuracy of video understanding, and reduces computational costs.
[0159] The embodiment of the present application sets the lower left triangular matrix as a mask matrix by compressing the tag vector, and shields the N text mapping vectors in the visual compression sequence during the causal transformation process of the visual compression sequence through the mask matrix, so that the M visual mapping vectors are isolated from the shielded N text mapping vectors, so that the visual mapping vector is continuously concerned by the compressed tag vector, and the visual mapping vector is compressed to the global compression vector. By compressing the huge visual mapping vector into the global compression vector, the vector length of the global compression vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost, and the context window occupied by the vector length of the global compression vector is much smaller than the M visual mapping vectors, and there is no need to be limited by the context window of the model, and the global compression vector can represent the global semantics of the M visual mapping vectors, which can make the model better understand the global contextual relationship, and can avoid the problem of context loss or forgetting, so as to improve the model performance. Moreover, by calculating the global compression vector with a shorter vector length and the N text mapping vectors in the reasoning stage, the computing cost can be reduced and the computing efficiency can be improved.
[0160] When processing the input of repeated business media data, the output of the activation function in the Transformer of the global compression vector corresponding to the repeated business media data can be stored. The global compression vector is shorter in length and more densely represented, which can improve the computational efficiency when processing the activation function. The target visual compression model can cache and reuse the global compression vector. Compared with the visual mapping vector, the computer device can reuse the output of the activation function, which can improve the cache efficiency. When processing the input of video data, the global compression vector can be obtained by compressing the visual mapping vector corresponding to each video frame data. The global compression vector can form a global compression sequence based on the display order of the video frame data. The global compression sequence contains the temporal relationship between video frames, so that the temporal dependency and event development relationship between the visual mapping vectors can be captured through the global compression sequence to adapt to the time input and compress the visual mapping vector. Therefore, the temporal relationship between each video frame can be better understood by interacting the features of the global compression sequence with the text mapping vector, which simplifies the understanding process of the video data, improves the accuracy of the understanding of the video, and reduces the computational cost.
[0161] See also Figure 8 , Figure 8 This is a flow diagram of a data processing method provided in an embodiment of the present application. Figure 3 The data processing method can be executed by a computer device, which can be Figure 1 The business server 100 shown. The following will take the data processing method executed by a computer device as an example for description. The data processing method may at least include the following steps S301-S305:
[0162] Step S301, inputting a media data sample, a question text and an answer label for the media data sample into an initial visual compression model;
[0163] Specifically, the computer device can use the pre-trained visual language model as the initial visual compression model, and the calculation of the social security can be based on the data distribution information corresponding to the media data sample, obtain multimodal public data with data similar characteristics to the data distribution information, and train the visual language model based on the multimodal public data to obtain an initial visual compression model that converges on multiple modalities. Among them, the initial visual compression model can include the visual encoder in the CLIP-ViT-L (Contrastive Language-Image Pre-training Vision Transformer) model (encoding the input media data sample into a visual mapping vector) and the text encoder of Vicuna-7B (Vicuna-7Billion, a large language model based on the Transformer architecture). Without introducing compressed tag vectors and global compression vectors, keep the visual encoder and language model frozen (retain parameter weights), and align the visual encoder and text encoder with the CC3M dataset (Conceptual Captions3M, a large-scale image description dataset) filtered by LLaVA (LargeLanguage Visual Answering, visual-language model).
[0164] The computer device may input the media data sample, the question text and the answer label for the media data sample into the initial visual compression model. The media data sample, the question text and the answer label for the media data sample may be the question answering-pairs (QA pairs) included in the WebVid dataset (a video understanding dataset, usually used to train and evaluate the performance of video understanding models) or the question answering-pairs generated by Video-ChatGPT (Video-ChatGenerative Pre-Trained).
[0165] It can be understood that the embodiments of the present application train the initial visual compression model by generating questions and answers on a wide range of data sets. During the training process, since the model has the input of the original visual mapping vector, rather than hard compression of the original image or original token through other models, the model can understand the mapping relationship of the visual mapping vectors on multiple modalities, and thus can adapt to the compression of the visual mapping vectors on multiple modalities, thereby improving the versatility of the model.
[0166] Step S302: divide the media data sample into at least two units of media data using the initial visual compression model, perform vector mapping on each unit of media data to obtain M visual mapping vectors, and perform vector mapping on the question text corresponding to the media data sample to obtain N text mapping vectors; M and N are both positive integers;
[0167] Specifically, the computer device can divide the media data sample through the initial visual compression model to obtain several units of media data. The computer device can perform vector mapping on each unit of media data to obtain M visual mapping vectors, and perform vector mapping on the question text corresponding to the media data sample to obtain N text mapping vectors.
[0168] Step S303, combining the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, inserting a compressed marker vector into the mapping vector sequence, and obtaining a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0169] Specifically, the computer device can combine M visual mapping vectors and N text mapping vectors into a mapping vector sequence, insert a compression marker vector into the mapping vector sequence, and obtain a visual compression sequence. The compression marker vector is a special token in the vocabulary of the initial visual compression model used to indicate causal transformation processing. The compression marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors.
[0170] Step S304, based on the compression mark vector, causal transformation processing is performed on the visual compression sequence to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0171] Specifically, the computer device can perform causal transformation processing on the visual compression sequence based on the compression tag vector to obtain a global compression vector. The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors.
[0172] The causal transformation process can be implemented based on the mask matrix in the Causal Transformer. The process can be seen above. Figure 5 The specific description of step S203 to step S204 of the corresponding embodiment will not be repeated here in the embodiment of the present application.
[0173] Step S305, generating prediction results corresponding to the media data samples based on the global compression vector and N text mapping vectors, adjusting the model parameters of the initial visual compression model based on the prediction results and the answer labels, until the initial visual compression model meets the model convergence conditions, and obtaining the target visual compression model; the target visual compression model is used to generate service results for business media data.
[0174] Specifically, the computer device can input the global compression vector and N text mapping vectors into the feature understanding layer, and through the feature understanding layer, perform feature extraction on the N text mapping vectors to obtain a text feature sequence, and perform feature extraction on the global compression vector to obtain a visual feature sequence.
[0175] Taking the classification task as an example, in the result output layer, the predicted probability of the business media data on multiple classification labels is generated through the text feature sequence and the visual feature sequence (each predicted probability can correspond to a predicted result y), and the predicted probability distribution p is obtained. VoCo (y|F,T). The computer device can generate a label probability distribution p based on the answer label QA , the relative entropy between the label probability distribution and the predicted probability distribution is determined as the model loss value L c , the process can be shown as formula (4):
[0176] L c =E T [D KL (p QA ||p VoCo (y|F,T)] Formula (4)
[0177] Among them, E T It refers to the expected mean value for text information, D KL Used to represent the label probability distribution p QA With the predicted probability distribution p VoCo The relative entropy KL between (y|V,T). F represents the sequence of global compression vectors, and T represents the text mapping vector. The computer device can use the model loss value L c The model parameters of the initial visual compression model are adjusted until the initial visual compression model meets the model training conditions, thereby obtaining the target visual compression model (VoCo-LLaMA). The model training condition can be the model loss value L c Stable, no longer significantly decreasing after multiple consecutive epochs (training cycles), or performance indicators (such as accuracy, precision, recall, etc.) no longer improve or reach predetermined targets, etc., which are not limited in the embodiments of the present application.
[0178] It can be understood that in the visual instruction adjustment stage, the global compression vector can directly interact with the text mapping vector, and the text mapping vector only interacts with the global compression vector. Therefore, in the process of model parameter adjustment, the global compression vector can learn and establish an interaction path between the two modes with the text mapping vector. There is no need to design a special alignment module to achieve modal alignment. Through the standard visual instruction adjustment learning process, the training cost of the embodiment of the present application is reduced.
[0179] In the experimental stage of the embodiment of the present application, the embodiment of the present application conducted experiments on common visual understanding benchmarks to evaluate the compression effect of visual mapping vectors. Test datasets in the image field may include GQA (General Question Answering), MMB (MMBench), MME (Multimodal Large Language Model Evaluation), POPE (a benchmark specifically used to evaluate whether multimodal large language models have hallucination problems in visual question answering tasks), SEED-Bench (a benchmark for multimodal large language models), SQAI (image-based setting of ScienceQA), and VQAv2. Test datasets in the video domain can include MSVD QA (a video QA dataset containing 1,970 video clips and 50,505 QA pairs), MSRVTT-QA (a large-scale video QA dataset containing 10K videos and 243K QA pairs), the MSR-VTT dataset, and ActivityNet-QA (a fully annotated video QA dataset containing 58,000 QA pairs derived from 5,800 complex network videos in the ActivityNet dataset).
[0180] By observing the target visual compression model before and after visual compression (i.e., before and after using the compressed token vector and the global compression vector), the compression retention rate and compression ratio of the target visual compression model are tested on these image and video understanding benchmarks. It can be observed that even in the case of a high compression ratio of 576 times, the performance loss achieved by the embodiment of the present application is significantly lower than the compression ratio by two orders of magnitude. An average compression retention rate of 83.7% was achieved on widely used benchmarks. On MMBench (an evaluation benchmark for multimodal large language models), a compression retention rate of 91.3% was achieved. The results show that the target visual compression model can effectively compress visual tokens. The benefits of saved context length and improved computational efficiency far outweigh the performance loss caused by compression.
[0181] And the embodiment of the present application can set the number of compression marker vectors inserted in the mapping vector sequence. The embodiment of the present application gradually increases the number of compression marker vectors on a widely used benchmark test, that is, increases the number of global compression vectors. As the number of global compression vectors increases, the overall compression performance of the model shows an upward trend. An average compression retention rate of 89.1% can be achieved with about five global compression vectors. When the number of global compression vectors reaches 128, an average compression retention rate of 95.3% is achieved, indicating that when the number of global compression vectors exceeds 128, the performance loss caused by compression is almost negligible. The CUDA (Compute Unified Device Architecture) time, FLOPs (Floating Point Operations Per Second) and KV cache storage size (Key-Value Cache Storage Size) in the reasoning process are compared and analyzed. Compared with the single-line cache strategy, the embodiment of the present application achieves a significant reduction of 69.6% in CUDA time and 94.8% in FLOPs. Compared with the full cache strategy, the embodiment of the present application saves 99.8% of cache storage while achieving lower CUDA time and FLOPs.
[0182] The initial visual compression model of the embodiment of the present application can be composed of the visual encoder in the pre-trained CLIP-ViT-L model and the text encoder of Vicuna-7B, and the visual encoder and the text encoder are aligned by the filtered CC3M data set. And generate question-answer data on a wide range of data sets to train the initial visual compression model. A special token of a predetermined compression tag vector is set in the vocabulary of the initial visual compression model to achieve causal transformation processing of the visual compression sequence, wherein the visual compression sequence is composed of a visual mapping vector corresponding to the media data sample, a compression tag vector, and a text mapping vector corresponding to the question text, and a global compression vector is obtained. Based on the global compression vector and N text mapping vectors, the prediction results corresponding to the media data sample are generated, and the model parameters of the initial visual compression model are adjusted based on the prediction results and the answer label until the initial visual compression model meets the model convergence conditions, and the target visual compression model is obtained; the target visual compression model is used to generate service results for business media data. Compressing the huge visual mapping vector into the global compression vector, and representing the global semantics of the M visual mapping vectors by the global compression vector, can enable the model to better understand the global contextual relationship and avoid the problem of context forgetting. And because of the input of the original visual mapping vector, the model can adapt to the compression of the visual mapping vector on multiple modes, which improves the versatility of the model. The vector length of the global compression vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost, and reduce the computational cost in the reasoning stage, and improve the computational efficiency. In the visual instruction adjustment stage, the global compression vector can interact directly with the text mapping vector, and the text mapping vector only interacts with the global compression vector, so in the process of adjusting the model parameters, the global compression vector can learn and establish the interaction path between the two modes with the text mapping vector, and there is no need to design a special alignment module to realize the modal alignment, and the learning process can be adjusted by standard visual instructions, reducing the training cost of the embodiment of the present application.
[0183] See also Fig. 9 , Fig. 9 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 1 .like Fig. 9 As shown, the data processing device 1 includes a target encoding module 910, a target insertion module 920, a target compression module 930 and a target output module 940.
[0184] The target encoding module 910 is used to divide the service media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the service media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0185] The target insertion module 920 is used to combine the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, and insert the compressed marker vector into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0186] The target compression module 930 is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0187] The target output module 940 is used to generate a service result for the business media data based on the global compression vector and the N text mapping vectors.
[0188] In a possible implementation, the target encoding module 910 is used to perform vector mapping on the text information, and when N text mapping vectors are obtained, it is specifically used to perform the following operations:
[0189] Inputting the text information into the target visual compression model, performing text segmentation on the text information in the target visual compression model to obtain a word unit sequence corresponding to the text information; the word unit sequence includes N word units, and a word unit in the word unit sequence refers to the smallest basic unit obtained after the text information is segmented;
[0190] Each word in the word sequence is mapped separately to obtain N text mapping vectors.
[0191] In a possible implementation, the target compression module 930 is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector, and when the global compression vector is obtained, it is specifically used to perform the following operations:
[0192] inputting the visual compression sequence into a target visual compression model; the target visual compression model includes an attention mask layer;
[0193] Perform a dot multiplication operation on the visual compression sequence and the query parameter matrix to obtain a query matrix, perform a dot multiplication operation on the visual compression sequence and the key parameter matrix to obtain a key matrix, and perform a dot multiplication operation on the visual compression sequence and the value parameter matrix to obtain a value matrix;
[0194] A mask matrix is obtained based on the compressed tag vector. Based on the mask matrix, attention calculation is performed on the query matrix, key matrix and value matrix to obtain a global compressed vector.
[0195] In a possible implementation, the target compression module 930 is used to obtain a mask matrix based on the compressed tag vector, and perform attention calculation on the query matrix, the key matrix, and the value matrix based on the mask matrix. When the global compression vector is obtained, it is specifically used to perform the following operations:
[0196] Perform a dot multiplication operation on the query matrix and the transposed result of the key matrix to obtain an attention score matrix, generate a mask matrix based on the square root of the dimension value of the key matrix and the attention score matrix, and obtain a mask matrix based on the compressed tag vector and the mask matrix;
[0197] The matrix to be masked is multiplied by the mask matrix to obtain a mask score matrix, the mask score matrix is normalized to obtain a normalized matrix, and the normalized matrix is multiplied by the value matrix to obtain a global compression vector; the mask matrix is used to shield the elements associated with the N text mapping vectors in the matrix to be masked.
[0198] In a possible implementation, when the target compression module 930 is used to obtain the mask matrix based on the compressed mark vector and the matrix to be masked, it is specifically used to perform the following operations:
[0199] Generate an initial matrix of M+N+1 rows by M+N+1 columns based on the compressed tag vector, and in the i-th row and j-th column of the initial matrix, if i belongs to the number of rows corresponding to the N text mapping vectors in the matrix to be masked, and j belongs to the number of columns corresponding to the M visual mapping vectors in the matrix to be masked, then set the element in the i-th row and j-th column of the initial matrix to the first mask value;
[0200] The elements in the initial matrix except the elements having the first mask value are set to the second mask value to obtain a mask matrix.
[0201] In a possible implementation, the target compression module 930 is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector, and when the global compression vector is obtained, it is specifically used to perform the following operations:
[0202] A mask matrix is obtained based on the compressed marker vector, and a causal transformation is performed on the visual compression sequence according to the mask matrix to obtain a global compression vector; the mask matrix is used to shield N text mapping vectors in the visual compression sequence during the causal transformation processing, and the M visual mapping vectors are isolated from the shielded N text mapping vectors.
[0203] In a possible implementation, when the target output module 940 is used to generate a service result for the business media data based on the global compression vector and the N text mapping vectors, it is specifically used to perform the following operations:
[0204] Inputting the global compression vector and the N text mapping vectors into a target visual compression model; the target visual compression model includes a feature understanding layer;
[0205] Based on the feature understanding layer, feature extraction is performed on N text mapping vectors to obtain a text feature sequence, and feature extraction is performed on the global compression vector to obtain a visual feature sequence;
[0206] The prediction probability for the business media data is generated through the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the business media data.
[0207] In a possible implementation, the arrangement positions of the M visual mapping sequences in the mapping vector sequence are before the arrangement positions of the N text mapping vectors; the target insertion module 920 is used to insert the compressed mark vector into the mapping vector sequence, and when the visual compression sequence is obtained, it is specifically used to perform the following operations:
[0208] If the resolution of the business media data is greater than the compression threshold, a compression vector value S is generated based on the resolution of the business media data, and S compression marker vectors are inserted after the arrangement position of the M visual mapping vectors in the mapping vector sequence to obtain a visual compression sequence; S is a positive integer; the S compression marker vectors in the visual compression sequence are located before the N text mapping vectors;
[0209] The target compression module 930 is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector, and when the global compression vector is obtained, it is specifically used to perform the following operations:
[0210] Based on the S compressed marker vectors, the visual compression sequence is causally transformed to obtain the global compression vectors corresponding to the S compressed marker vectors.
[0211] In a possible implementation, the service media data includes T video frames, where T is a positive integer, and the global compression vector includes global compression vectors corresponding to the T video frames respectively; when the target output module 940 is used to generate a service result for the service media data based on the global compression vector and the N text mapping vectors, it is specifically used to perform the following operations:
[0212] Based on the display order of T video frames in the business media data, T global compression vectors are arranged to obtain a global compression sequence, and a service result for the business media data is generated based on the global compression sequence and N text mapping vectors.
[0213] The embodiment of the present application sets the lower left triangular matrix as a mask matrix by compressing the tag vector, and shields the N text mapping vectors in the visual compression sequence during the causal transformation process of the visual compression sequence through the mask matrix, so that the M visual mapping vectors are isolated from the shielded N text mapping vectors, so that the visual mapping vector is continuously concerned by the compressed tag vector, and the visual mapping vector is compressed to the global compression vector. By compressing the huge visual mapping vector into the global compression vector, the vector length of the global compression vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost, and the context window occupied by the vector length of the global compression vector is much smaller than the M visual mapping vectors, and there is no need to be limited by the context window of the model, and the global compression vector can represent the global semantics of the M visual mapping vectors, which can make the model better understand the global contextual relationship, and can avoid the problem of context loss or forgetting, so as to improve the model performance. Moreover, by calculating the global compression vector with a shorter vector length and the N text mapping vectors in the reasoning stage, the computing cost can be reduced and the computing efficiency can be improved.
[0214] When processing the input of repeated business media data, the output of the activation function in the Transformer of the global compression vector corresponding to the repeated business media data can be stored. The global compression vector is shorter in length and more densely represented, which can improve the computational efficiency when processing the activation function. The target visual compression model can cache and reuse the global compression vector. Compared with the visual mapping vector, the computer device can reuse the output of the activation function, which can improve the cache efficiency. When processing the input of video data, the global compression vector can be obtained by compressing the visual mapping vector corresponding to each video frame data. The global compression vector can form a global compression sequence based on the display order of the video frame data. The global compression sequence contains the temporal relationship between video frames, so that the temporal dependency and event development relationship between the visual mapping vectors can be captured through the global compression sequence to adapt to the time input and compress the visual mapping vector. Therefore, the temporal relationship between each video frame can be better understood by interacting the features of the global compression sequence with the text mapping vector, which simplifies the understanding process of the video data, improves the accuracy of the understanding of the video, and reduces the computational cost. In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0215] See also Fig.10 , Fig.10 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 2 .like Fig.10 As shown, the data processing device 2 includes a sample input module 1010 , an initial encoding module 1020 , an initial insertion module 1030 , an initial compression module 1040 and a model adjustment module 1050 .
[0216] A sample input module 1010 is used to input a media data sample, a question text and an answer label for the media data sample into an initial visual compression model;
[0217] The initial encoding module 1020 is used to divide the media data sample into at least two units of media data through an initial visual compression model, perform vector mapping on each unit of media data to obtain M visual mapping vectors, and perform vector mapping on the question text corresponding to the media data sample to obtain N text mapping vectors; M and N are both positive integers;
[0218] An initial insertion module 1030 is used to combine the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, and insert a compressed marker vector into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0219] The initial compression module 1040 is used to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0220] The model adjustment module 1050 is used to generate prediction results corresponding to media data samples based on the global compression vector and N text mapping vectors, and adjust the model parameters of the initial visual compression model based on the prediction results and the answer label until the initial visual compression model meets the model convergence conditions, thereby obtaining the target visual compression model; the target visual compression model is used to generate service results for business media data.
[0221] In a possible implementation, the sample input module 1010 is further configured to perform the following operations:
[0222] Based on the data distribution information corresponding to the media data samples, multimodal public data with data characteristics similar to the data distribution information is obtained, and the visual language model is trained based on the multimodal public data to obtain an initial visual compression model that converges on multiple modalities.
[0223] In a possible implementation, the prediction result is a label probability distribution; the model adjustment module 1050 is used to adjust the model parameters of the initial visual compression model based on the prediction result and the answer label until the initial visual compression model meets the model convergence condition and the target visual compression model is obtained, and is specifically used to perform the following operations:
[0224] A label probability distribution is generated based on the answer label, and the relative entropy between the label probability distribution and the predicted probability distribution is determined as the model loss value. The model parameters of the initial visual compression model are adjusted according to the model loss value until the initial visual compression model meets the model training conditions, thereby obtaining the target visual compression model.
[0225] The initial visual compression model of the embodiment of the present application can be composed of the visual encoder in the pre-trained CLIP-ViT-L model and the text encoder of Vicuna-7B, and the visual encoder and the text encoder are aligned by the filtered CC3M data set. And generate question-answer data on a wide range of data sets to train the initial visual compression model. A special token of a predetermined compression tag vector is set in the vocabulary of the initial visual compression model to achieve causal transformation processing of the visual compression sequence, wherein the visual compression sequence is composed of a visual mapping vector corresponding to the media data sample, a compression tag vector, and a text mapping vector corresponding to the question text, and a global compression vector is obtained. Based on the global compression vector and N text mapping vectors, the prediction results corresponding to the media data sample are generated, and the model parameters of the initial visual compression model are adjusted based on the prediction results and the answer label until the initial visual compression model meets the model convergence conditions, and the target visual compression model is obtained; the target visual compression model is used to generate service results for business media data. Compressing the huge visual mapping vector into the global compression vector, and representing the global semantics of the M visual mapping vectors by the global compression vector, can enable the model to better understand the global contextual relationship and avoid the problem of context forgetting. And because of the input of the original visual mapping vector, the model can adapt to the compression of the visual mapping vector on multiple modes, which improves the versatility of the model. The vector length of the global compression vector is much smaller than the sum of the vector lengths of the M visual mapping vectors, which can greatly reduce the cache cost, and reduce the computational cost in the reasoning stage, and improve the computational efficiency. In the visual instruction adjustment stage, the global compression vector can interact directly with the text mapping vector, and the text mapping vector only interacts with the global compression vector, so in the process of adjusting the model parameters, the global compression vector can learn and establish the interaction path between the two modes with the text mapping vector, and there is no need to design a special alignment module to realize the modal alignment, and the learning process can be adjusted by standard visual instructions, reducing the training cost of the embodiment of the present application.
[0226] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0227] See also Fig.11 , Fig.11 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Fig.11 As shown, the computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Fig.11 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0228] In such Fig.11 In the computer device 1000 shown, the network interface 1004 can provide a network communication element; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005.
[0229] When the computer device 1000 is a data processing apparatus 1, the following is achieved:
[0230] Divide the business media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the business media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers;
[0231] The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0232] Based on the compressed tag vector, the visual compression sequence is causally transformed to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0233] A service result for the business media data is generated based on the global compression vector and the N text mapping vectors.
[0234] When the computer device 1000 is a data processing device 2, the following is achieved:
[0235] Inputting the media data sample, the question text and the answer label for the media data sample into the initial visual compression model;
[0236] The media data sample is divided into at least two units of media data through the initial visual compression model, each unit of media data is vector-mapped to obtain M visual mapping vectors, and the question text corresponding to the media data sample is vector-mapped to obtain N text mapping vectors; M and N are both positive integers;
[0237] The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors;
[0238] Based on the compressed tag vector, the visual compression sequence is causally transformed to obtain a global compression vector; the global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors;
[0239] Based on the global compression vector and N text mapping vectors, prediction results corresponding to the media data samples are generated. Based on the prediction results and the answer labels, model parameters of the initial visual compression model are adjusted until the initial visual compression model meets the model convergence conditions, thereby obtaining the target visual compression model; the target visual compression model is used to generate service results for business media data.
[0240] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 4 , Figure 5 and Figure 8The description of the data processing method in any corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here.
[0241] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program, and when the processor executes the computer program, it can execute the above Figure 4 , Figure 5 and Figure 8 The description of the above data processing method in any corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0242] The computer-readable storage medium may be the data processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been displayed or is to be displayed.
[0243] In addition, it should be noted that: the embodiment of the present application also provides a computer program product, the computer program product includes a computer program, the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above Figure 4 , Figure 5 and Figure 8 A method provided by any corresponding embodiment.
[0244] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.
[0245] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of network elements in the above description. Whether these network elements are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described network elements for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0246] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable device to generate a machine, so that the instructions executed by the processor of the computer or other programmable device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide the functions for implementing the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0247] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0248] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0249] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: include: Divide the business media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the business media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers; The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors; Based on the compression mark vector, performing causal transformation processing on the visual compression sequence to obtain a global compression vector; The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors; A service result for the business media data is generated based on the global compression vector and the N text mapping vectors.
2. The method according to claim 1, characterized in that The performing vector mapping on the text information to obtain N text mapping vectors includes: Inputting the text information into a target visual compression model, performing text segmentation on the text information in the target visual compression model to obtain a word unit sequence corresponding to the text information; the word unit sequence includes N word units, and a word unit in the word unit sequence refers to the smallest basic unit obtained after the text information is segmented; Mapping is performed on each word in the word sequence to obtain N text mapping vectors.
3. The method according to claim 1, characterized in that The step of performing causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector includes: Inputting the visual compression sequence into a target visual compression model; the target visual compression model includes an attention mask layer; Performing a dot multiplication operation on the visual compression sequence and the query parameter matrix to obtain a query matrix, performing a dot multiplication operation on the visual compression sequence and the key parameter matrix to obtain a key matrix, and performing a dot multiplication operation on the visual compression sequence and the value parameter matrix to obtain a value matrix; A mask matrix is obtained based on the compressed tag vector, and attention calculation is performed on the query matrix, the key matrix and the value matrix based on the mask matrix to obtain a global compressed vector.
4. The method according to claim 3, characterized in that The step of obtaining a mask matrix based on the compressed tag vector and performing attention calculation on the query matrix, the key matrix and the value matrix based on the mask matrix to obtain a global compressed vector includes: Performing a dot multiplication operation on the query matrix and the transposed operation result of the key matrix to obtain an attention score matrix, generating a to-be-masked matrix based on the square root of the dimension value of the key matrix and the attention score matrix, and obtaining a mask matrix based on the compressed tag vector and the to-be-masked matrix; The matrix to be masked is multiplied by a dot operation with the mask matrix to obtain a mask score matrix, the mask score matrix is normalized to obtain a normalized matrix, and the normalized matrix is multiplied by a dot operation with the value matrix to obtain a global compression vector; the mask matrix is used to shield the elements in the matrix to be masked that are associated with the N text mapping vectors.
5. The method according to claim 4, characterized in that The obtaining of a mask matrix based on the compressed tag vector and the matrix to be masked includes: Generate an initial matrix of M+N+1 rows by M+N+1 columns based on the compressed tag vector, in the i-th row and j-th column of the initial matrix, if i belongs to the number of rows corresponding to the N text mapping vectors in the matrix to be masked, and j belongs to the number of columns corresponding to the M visual mapping vectors in the matrix to be masked, then set the element in the i-th row and j-th column of the initial matrix to the first mask value; The elements in the initial matrix except the elements having the first mask value are set to the second mask value to obtain a mask matrix.
6. The method according to claim 1, characterized in that The step of performing causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector includes: A mask matrix is obtained based on the compressed marker vector, and a causal transformation process is performed on the visual compression sequence according to the mask matrix to obtain a global compression vector; the mask matrix is used to shield N text mapping vectors in the visual compression sequence during the causal transformation process, and the M visual mapping vectors are isolated from the shielded N text mapping vectors.
7. The method according to claim 1, characterized in that The generating a service result for the business media data based on the global compression vector and the N text mapping vectors includes: Inputting the global compression vector and the N text mapping vectors into a target visual compression model; the target visual compression model includes a feature understanding layer; Based on the feature understanding layer, feature extraction is performed on the N text mapping vectors to obtain a text feature sequence, and feature extraction is performed on the global compression vector to obtain a visual feature sequence; The prediction probability for the service media data is generated by using the text feature sequence and the visual feature sequence, and the prediction result with the maximum prediction probability is determined as the service result for the service media data.
8. The method according to claim 1, characterized in that The arrangement positions of the M visual mapping sequences in the mapping vector sequence are before the arrangement positions of the N text mapping vectors; The step of inserting a compressed marker vector into the mapping vector sequence to obtain a visual compression sequence comprises: If the resolution of the business media data is greater than the compression threshold, a compression vector value S is generated based on the resolution of the business media data, and S compression mark vectors are inserted after the arrangement position of the M visual mapping vectors in the mapping vector sequence to obtain a visual compression sequence; S is a positive integer; the S compression mark vectors in the visual compression sequence are located before the N text mapping vectors; The step of performing causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector includes: Based on the S compression marker vectors, causal transformation processing is performed on the visual compression sequence to obtain global compression vectors corresponding to the S compression marker vectors respectively.
9. The method according to claim 1, characterized in that: The service media data includes T video frames, where T is a positive integer, and the global compression vector includes global compression vectors corresponding to the T video frames respectively; The generating a service result for the business media data based on the global compression vector and the N text mapping vectors includes: Based on the display order of the T video frames in the business media data, the T global compression vectors are arranged to obtain a global compression sequence, and a service result for the business media data is generated based on the global compression sequence and the N text mapping vectors.
10. A data processing method, characterized in that: include: Inputting the media data sample, the question text and the answer label for the media data sample into the initial visual compression model; The media data sample is divided into at least two units of media data through the initial visual compression model, each unit of media data is vector-mapped to obtain M visual mapping vectors, and the question text corresponding to the media data sample is vector-mapped to obtain N text mapping vectors; M and N are both positive integers; The M visual mapping vectors and the N text mapping vectors are combined into a mapping vector sequence, and a compressed marker vector is inserted into the mapping vector sequence to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors; Based on the compression mark vector, performing causal transformation processing on the visual compression sequence to obtain a global compression vector; The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors; Generate a prediction result corresponding to the media data sample based on the global compression vector and the N text mapping vectors, and adjust the model parameters of the initial visual compression model based on the prediction result and the answer label until the initial visual compression model meets the model convergence condition, thereby obtaining a target visual compression model; The target visual compression model is used to generate a service result for business media data.
11. The method according to claim 10, characterized in that Also includes: Based on the data distribution information corresponding to the media data samples, multimodal public data having data characteristics similar to the data distribution information is obtained, and a visual language model is trained based on the multimodal public data to obtain an initial visual compression model that converges on multiple modalities.
12. The method according to claim 10, characterized in that The prediction result is a label probability distribution; the model parameters of the initial visual compression model are adjusted based on the prediction result and the answer label until the initial visual compression model meets the model convergence condition, thereby obtaining a target visual compression model, including: A label probability distribution is generated based on the answer label, and the relative entropy between the label probability distribution and the predicted probability distribution is determined as a model loss value. The model parameters of the initial visual compression model are adjusted according to the model loss value until the initial visual compression model meets the model training conditions, thereby obtaining a target visual compression model.
13. A data processing device, characterized in that: include: A target encoding module is used to divide the business media data into at least two unit media data, perform vector mapping on each unit media data to obtain M visual mapping vectors, obtain text information for the business media data, perform vector mapping on the text information to obtain N text mapping vectors; M and N are both positive integers; A target insertion module, used for combining the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, inserting a compressed marker vector into the mapping vector sequence, and obtaining a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors; A target compression module, configured to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors; A target output module is used to generate a service result for the business media data based on the global compression vector and the N text mapping vectors.
14. A data processing device, characterized in that: include: A sample input module, used for inputting a media data sample, a question text and an answer label for the media data sample into an initial visual compression model; An initial encoding module is used to divide the media data sample into at least two units of media data through an initial visual compression model, perform vector mapping on each unit of media data to obtain M visual mapping vectors, and perform vector mapping on the question text corresponding to the media data sample to obtain N text mapping vectors; M and N are both positive integers; An initial insertion module, used for combining the M visual mapping vectors and the N text mapping vectors into a mapping vector sequence, inserting a compressed marker vector into the mapping vector sequence, to obtain a visual compression sequence; the compressed marker vector in the visual compression sequence is located between the M visual mapping vectors and the N text mapping vectors; An initial compression module, configured to perform causal transformation processing on the visual compression sequence based on the compression mark vector to obtain a global compression vector; The global compression vector is used to represent the global semantics of the M visual mapping vectors, and the vector length of the global compression vector is less than the sum of the vector lengths of the M visual mapping vectors; A model adjustment module, configured to generate a prediction result corresponding to the media data sample based on the global compression vector and the N text mapping vectors, and adjust model parameters of the initial visual compression model based on the prediction result and the answer label until the initial visual compression model satisfies a model convergence condition, thereby obtaining a target visual compression model; The target visual compression model is used to generate a service result for business media data.
15. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1-12.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 12.
17. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium and is suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 12.
Citation Information
Cited By
Data processing method, device and equipment and readable storage medium
CN118916519A
Audio and video generation method, electronic equipment and computer readable storage medium
CN119295618A
Video feature compression method, device, equipment, medium and product
CN119835434A
Multi-label text data set distillation method and device, computer equipment and storage medium
CN120087449A
Distillation method, device, computer equipment and storage medium for multi-label text dataset
CN120087449B
