A data processing method and apparatus
Patent Information
- Application Number
- CN202211005409.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-22
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-08-22
AI Technical Summary
以图文匹配(text-image matching,TIM)为例,训练目标用来判断全局文字是否和全局的扫描文档图片是否匹配,该任务学习难度小,使得训练的模型不具备文本和图像元素的对齐能力
[0308] The following section describes the beneficial effects of this application based on experimental results:
Smart Images

Figure CN115512005B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more particularly to a data processing method and apparatus thereof. Background Technology
[0002] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0003] Existing cross-modal visual language models (or multimodal models or multimodal language models) have relatively weak text modeling capabilities in their alignment methods. Taking text-image alignment (TIA) as an example, TIA simply determines whether a character is occluded, without adequately considering the semantic information between occluded characters, resulting in the model not truly understanding the document's content.
[0004] Current multimodal models have weak text-image alignment capabilities, meaning they lack the ability to align text and image elements. Taking text-image matching (TIM) as an example, the training objective is to determine whether global text matches global scanned document images. This task has low learning difficulty, resulting in trained models that lack the ability to align text and image elements. Summary of the Invention
[0005] This application provides a data processing method that enables the features extracted by the image encoder and text encoder to contain more accurate semantic information of the text in the image, thereby enhancing the image-text matching ability of the subsequent network. In this application, the alignment ability between the image and text can be improved by first using a dual-tower approach, and then the interactive learning ability of the features can be further enhanced by using a single-tower structure.
[0006] In a first aspect, this application provides a data processing method, comprising: obtaining a first feature representation and a second feature representation, wherein the first feature representation is obtained by processing an image using an image encoder, and the second feature representation is the text features of a first text; the first text is the text content included in the image; obtaining a third feature representation by passing the first feature representation and the second feature representation through a target encoder; the target encoder is used to realize the interaction between the feature representations; executing a downstream task based on the third feature representation to obtain an execution result; the similarity between the execution result and the corresponding annotation, and the similarity between the first feature representation and the second feature representation, are used to update the image encoder.
[0007] In this application, text-image contrastive learning (TIC) is used to enhance the matching ability between images and text. Specifically, for image features and text features, a loss constructed through similarity comparison is used to update the image encoder (if the text features are obtained through a text encoder, the text encoder can also be updated). Although the image features and the text features in the image are not features of the same modality, since the text is text in the image, the image features also contain certain semantic information of the text. Therefore, there is a correlation between image features and text features (belonging to the same image) in the semantic dimension (or other information dimensions). The aforementioned similarity can include the similarity between the semantic information in the image and the semantic information in the text. Therefore, updating the image encoder and text encoder (if a text encoder exists in the architecture) based on the loss constructed based on this similarity enables the features extracted by the image encoder and text encoder to contain more accurate semantic information of the text in the image, thereby enhancing the image-text matching ability of the subsequent network.
[0008] Furthermore, in the architecture of the cross-modal language model, which includes a graph encoder, a text encoder, and a target encoder for providing information on the interaction between features, this application updates the graph encoder and text encoder by using the loss constructed from the similarity between the intermediate outputs of the model (i.e., the outputs of the graph encoder and the text encoder). This allows the downstream tasks to be performed based on the feature representations output by the graph encoder and the text encoder (although the accuracy is not as high as that of the downstream tasks based on the feature representations output by the target encoder). In some scenarios, since the amount of data to be processed by the downstream tasks is large, the feature representations output by the graph encoder and the text encoder can be used for coarse ranking, and the feature representations output by the target encoder can be used for fine ranking to improve the recall rate.
[0009] In one possible implementation, the second feature is represented as a text feature obtained by processing the first text through a text encoder; the similarity between the first feature representation and the second feature representation is also used to update the text encoder.
[0010] In one possible implementation, similarity is related to the similarity between the semantic information of the text contained in the image and the semantic information of the text itself.
[0011] In one possible implementation, the similarity between the execution result and the corresponding annotation is also used to update the target encoder.
[0012] In one possible implementation,
[0013] The first text is all the text contained in the image; or...
[0014] The first text is a portion of the total text contained in the image.
[0015] In one possible implementation,
[0016] The image is a portion of the image region extracted from the original input image, and the text included in the image is a portion of the text contained in the input image; or,
[0017] The image is the original input image.
[0018] In one possible implementation, the image can be the original input image (or a portion of the original input image, but containing all the text of the input image). The first text can be all the text contained in the image.
[0019] In one possible implementation, the image can be the original input image (or a portion of the original input image, but which contains all the text of the input image). The first text can be a portion of the text contained in the image.
[0020] In one possible implementation, the image can be a partial image region extracted from the original input image, which includes a portion of the text of all the text in the original input image, and the first text can be all the text included in the image.
[0021] In one possible implementation, the image can be a partial image region extracted from the original input image, which includes a portion of the text in the original input image, and the first text can be a portion of the text contained in the image.
[0022] In one possible implementation, the input original image may include one or more lines of text, or the input original image may include one or more columns of text. Optionally, the image may include one line or one column of text from the original image, and the first text may be one or more text units.
[0023] When performing image-text comparison learning, the loss for updating the image encoder and the text encoder can be constructed based on the similarity between the image features of the image and the text features of the first text. Optionally, this similarity is related to the similarity between the semantic information of the text contained in the image and the semantic information of the text itself.
[0024] It should be understood that the loss for updating the graph encoder and the text encoder can also be constructed based on the similarity between the image features of the image and the text features of the text not included in the image. The difference is that the image features of the image and the text features of the text in the image are positive examples (that is, the corresponding annotation similarity is high), while the image features of the image and the text features of the text not included in the image are negative examples (that is, the corresponding annotation similarity is low).
[0025] In one possible implementation, for the same original input image, the image features corresponding to the entire input image can be compared with the text features of all the text included in the input image, or the image features of a partial image region in the input image can be compared with the text features of a partial text included in the input image, or the image features corresponding to the entire input image can be compared with the text features of a partial text included in the input image, or a combination of the above methods.
[0026] In one possible implementation, for the same original input image, the text features corresponding to all the text included in the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to all the text included in the input image can be compared with the image features corresponding to the entire input image.
[0027] In one possible implementation, for different original input images, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features corresponding to the entire input image. Or, a combination of the above methods can be used.
[0028] In one possible implementation, for different original input images, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features corresponding to the entire input image.
[0029] In one possible implementation, the first text includes a first subtext and a second subtext, and the second feature representation includes a first sub-feature corresponding to the first subtext and a second sub-feature corresponding to the second subtext; the first sub-feature does not contain the position of the first subtext in the image; the second sub-feature contains the position of the second subtext in the image; and downstream tasks are performed based on the third feature representation, including: predicting a first position of the first subtext in the image based on the third feature representation; and the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
[0030] In one possible implementation, the image comprises multiple image blocks; the first location is the image block where the first sub-text is predicted to be located; and the label is the image block where the first sub-text is actually located.
[0031] This application proposes a Background Music (BGM) mechanism for single-tower models to enhance spatial layout awareness, which helps improve model performance in location-sensitive tasks. For example, in information extraction, key-value pairs are usually adjacent pairs of data. Because the model has already learned to perceive location and layout information during the pre-training stage, it will have good performance in information extraction tasks.
[0032] In one possible implementation, the first feature representation includes a third sub-feature and a fourth sub-feature; the method further includes: obtaining a feature prediction value at the third position based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
[0033] In one possible implementation, the feature prediction value at the third position is obtained based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation. This includes: obtaining the fourth feature representation through a self-attention network based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; and obtaining the feature prediction value at the third position through a prediction network based on the fourth feature representation.
[0034] In one possible implementation, to improve the learning ability of image representation, a loss function can be constructed based on image features. Specifically, a portion of the image can be masked, and the masked region can be reconstructed using the result from the image encoder. The network is then updated based on the difference between the pixel values of the reconstructed region and the real image of the masked region. However, existing methods have weak image representation learning capabilities. This is because, to reduce the computational overhead of the model, the image needs to be compressed to a smaller resolution (e.g., 224*224). When the image contains dense text, the pixels in the image struggle to accurately represent the textual information, resulting in limited image representation learning capabilities for the trained model.
[0035] In this embodiment of the application, in order to improve the learning ability of image representation, the image features of the image can be masked instead of the image itself, and the image features of the masked region can be reconstructed. The network is then updated based on the difference between the reconstruction result and the image features of the masked region. Since image features can carry richer image and text information than pixel values themselves, the learning ability of the trained network to represent images can be improved. The above method can be called mask image modeling (MIM).
[0036] Secondly, this application provides a data processing method, the method comprising:
[0037] Acquire images;
[0038] The image is processed by an image encoder to obtain the first feature representation;
[0039] The text contained in the image is processed by a text encoder to obtain a second feature representation;
[0040] Based on the first and second feature representations, a third feature representation is obtained through the target encoder; the target encoder is used to realize the interaction between the feature representations.
[0041] Based on the third feature, downstream tasks are executed to obtain the execution result.
[0042] Thirdly, this application provides a data processing apparatus, comprising:
[0043] The acquisition module is used to acquire a first feature representation and a second feature representation. The first feature representation is obtained by processing the image based on the image encoder. The second feature representation is the text features of the first text. The first text is the text content included in the image. The similarity between the first feature representation and the second feature representation is used to update the image encoder.
[0044] The encoding module is used to obtain a third feature representation based on the first feature representation and the second feature representation through the target encoder; the target encoder is used to realize the interaction between the feature representations.
[0045] The task execution module is used to execute downstream tasks based on the third feature representation and obtain the execution result.
[0046] In one possible implementation, the second feature is represented as a text feature obtained by processing the first text through a text encoder; the similarity between the first feature representation and the second feature representation is also used to update the text encoder.
[0047] In one possible implementation, similarity is related to the similarity between the semantic information of the text contained in the image and the semantic information of the text itself.
[0048] In one possible implementation,
[0049] The first text is all the text contained in the image; or...
[0050] The first text is a portion of the total text contained in the image.
[0051] In one possible implementation,
[0052] The image is a portion of the image region extracted from the original input image, and the text included in the image is a portion of the text contained in the input image; or,
[0053] The image is the original input image.
[0054] In one possible implementation, the first text includes a first subtext and a second subtext, and the second feature representation includes a first sub-feature corresponding to the first subtext and a second sub-feature corresponding to the second subtext; the first sub-feature does not contain the position of the first subtext in the image; the second sub-feature contains the position of the second text in the image;
[0055] The task execution module is specifically used for:
[0056] Based on the third feature representation, the first position of the first subtext in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
[0057] In one possible implementation, the image comprises multiple image blocks; the first location is the image block where the first sub-text is predicted to be located; and the label is the image block where the first sub-text is actually located.
[0058] In one possible implementation, the first feature representation includes a third sub-feature and a fourth sub-feature; the method also includes:
[0059] The prediction module is used to obtain the feature prediction value at the third position based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
[0060] In one possible implementation, the prediction module is specifically used for:
[0061] Based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation, the fourth feature representation is obtained through a self-attention network.
[0062] Based on the fourth feature representation, the feature prediction value at the third position is obtained through the prediction network.
[0063] Fourthly, this application provides a data processing apparatus, the apparatus comprising:
[0064] The acquisition module is used to acquire images;
[0065] The encoding module is used to process the image through the image encoder to obtain the first feature representation;
[0066] The text contained in the image is processed by a text encoder to obtain a second feature representation;
[0067] Based on the first and second feature representations, a third feature representation is obtained through the target encoder; the target encoder is used to realize the interaction between the feature representations.
[0068] The task execution module is used to execute downstream tasks based on the third feature representation and obtain the execution result.
[0069] Fifthly, embodiments of this application provide a training apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect above and any of its optional methods.
[0070] In a sixth aspect, embodiments of this application provide an execution apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the second aspect above and any of its optional methods.
[0071] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, as well as the methods described in the second aspect and any optional methods thereof.
[0072] Eighthly, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, as well as the methods described in the second aspect and any optional methods thereof.
[0073] Ninthly, this application provides a chip system including a processor for supporting an execution data processing device in performing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. The chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description
[0074] Figure 1A A structural diagram illustrating the main framework of artificial intelligence;
[0075] Figure 1B and Figure 1C This is a schematic diagram of the application system framework of the present invention;
[0076] Figure 1D This is a schematic diagram of an optional hardware structure for a terminal.
[0077] Figure 2 This is a schematic diagram of the structure of a server;
[0078] Figure 3 This is a schematic diagram of a system architecture according to this application;
[0079] Figure 4 A process for providing a cloud service;
[0080] Figure 5 A process for providing a cloud service;
[0081] Figure 6 This is a schematic diagram of a system architecture according to this application;
[0082] Figure 7 A flowchart illustrating a data processing method provided in an embodiment of this application;
[0083] Figures 8 to 10 A flowchart illustrating a data processing method provided in an embodiment of this application;
[0084] Figure 11 This is a schematic diagram of a system architecture according to this application;
[0085] Figure 12 A schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application;
[0086] Figure 13 A schematic diagram of the structure of the execution device provided in the embodiments of this application;
[0087] Figure 14 A schematic diagram of the structure of the training device provided in the embodiments of this application;
[0088] Figure 15 This is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation
[0089] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.
[0090] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0091] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0092] The terms “substantially,” “about,” and similar terms used herein are used as approximations rather than as terms of degree, and are intended to take into account the inherent biases of measurements or calculations known to those skilled in the art. Furthermore, the use of “may” in describing embodiments of the invention refers to “one or more possible embodiments.” The terms “use,” “using,” and “used” used herein are to be considered synonymous with the terms “utilize,” “utilizing,” and “utilized,” respectively. Additionally, the term “exemplary” is intended to refer to an instance or illustration.
[0093] First, the overall workflow of the artificial intelligence system is described; please refer to [link / reference]. Figure 1A , Figure 1AThe diagram illustrates a structural framework for artificial intelligence (AI). The framework is further elaborated below along two dimensions: the "Intelligent Information Chain" (horizontal axis) and the "IT Value Chain" (vertical axis). The "Intelligent Information Chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT Value Chain" reflects the value that AI brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed through technological means) to the industrial ecosystem of the system.
[0094] (1) Infrastructure
[0095] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.
[0096] (2) Data
[0097] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0098] (3) Data processing
[0099] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.
[0100] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training on data, including symbolization and formalization.
[0101] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.
[0102] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.
[0103] (4) General ability
[0104] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0105] (5) Smart Products and Industry Applications
[0106] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, smart cities, etc.
[0107] This application can be applied to the field of natural language processing in the field of artificial intelligence. The following will introduce several application scenarios that have been implemented in products, taking natural language processing as an example.
[0108] First, we will introduce the application scenarios of this application. This application can be applied, but is not limited to, to applications with text processing capabilities for images (hereinafter referred to as cross-modal language processing applications) or cloud services provided by cloud-side servers, etc., which will be introduced separately below:
[0109] I. Cross-modal language processing applications
[0110] The product form of this application embodiment can be a cross-modal language processing application. Cross-modal language processing applications can run on terminal devices or cloud-based servers.
[0111] In one possible implementation, a cross-modal language processing application can perform image-text related processing tasks based on the input image and obtain the processing result.
[0112] For example, the text-related processing tasks in the aforementioned images may include information extraction, contract review, and retrieval and question-and-answer. In the information extraction scenario, users can customize the fields of interest in the image, such as Party A, Party B, and contract number. In the contract review scenario, relevant personnel can verify whether different versions of the contract are consistent, such as whether a change in Party A's name will introduce risk clauses. In the retrieval and question-and-answer scenario, it can help users quickly retrieve relevant text in the image by asking questions or using keywords, and find possible answers within the text.
[0113] For example, the aforementioned images are images captured by devices such as cameras, printers, and scanners. As an example, in one application scenario, in fields such as finance, accounting, and taxation, businesses need to scan documents such as receipts or invoices to obtain image files, and then recognize the text in the image files to extract text information, thereby enabling functions such as digital document archiving, rapid document indexing, or document analysis. In another application scenario, users need to input information from documents such as ID cards, driver's licenses, vehicle registration certificates, or passports. Users can then use a camera to capture images of these documents and recognize the text in the images to extract key information.
[0114] It should be understood that the examples given here are only for the convenience of understanding the application scenarios of the embodiments of this application, and do not exhaustively list the application scenarios of the embodiments of this application.
[0115] In one possible implementation, a user can open a cross-modal language processing application installed on a terminal device and input an image. The cross-modal language processing application can process the image using a cross-modal language model trained by the method provided in this application embodiment and present the processing result to the user (the presentation method may include, but is not limited to, displaying, saving, uploading to the cloud, etc.).
[0116] In one possible implementation, a user can open a cross-modal language processing application installed on a terminal device and input an image. The cross-modal language processing application can then send the image to a cloud-based server. The cloud-based server processes the image using a cross-modal language model trained by the method provided in this application embodiment and sends the processing result back to the terminal device. The terminal device can then present the processing result to the user (the presentation method may include, but is not limited to, displaying, saving, or uploading to the cloud).
[0117] The following sections will introduce the cross-modal language processing application in this application embodiment from the perspectives of functional architecture and product architecture that implements the functions.
[0118] Reference Figure 1B , Figure 1B This is a schematic diagram of the functional architecture of a cross-modal language processing application in this application embodiment:
[0119] In one possible implementation, such as Figure 1BAs shown, a cross-modal language processing application 102 can receive input parameters 101 (e.g., including images) and produce a processing result 103. The cross-modal language processing application 102 can execute on (for example) at least one computer system and includes computer code that, when executed by one or more computers, causes the computers to execute a cross-modal language model trained using the methods provided in the embodiments of this application.
[0120] Reference Figure 1C , Figure 1C This is a schematic diagram of the entity architecture for running a cross-modal language processing application in this embodiment of the application:
[0121] See Figure 1C , Figure 1C A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers (…). Figure 1C (The example includes a server), server 200 can provide cross-modal language processing services for one or more terminals.
[0122] The terminal 100 may have a cross-modal language processing application installed, or a webpage related to cross-modal language processing functions opened. The application and webpage can provide an interface. The terminal 100 can receive relevant parameters input by the user on the cross-modal language processing function interface and send the parameters to the server 200. The server 200 can obtain the processing result based on the received parameters and return the processing result to the terminal 100.
[0123] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters on its own, without the need for the server to cooperate. This application embodiment is not limited to this.
[0124] The following description Figure 1C The product form of the mid-terminal 100;
[0125] The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.
[0126] Figure 1D A schematic diagram of an optional hardware structure for terminal 100 is shown.
[0127] refer to Figure 1D As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a processor 170, an external interface 180, a power supply 190, and other components. Those skilled in the art will understand that... Figure 1D These are merely examples of terminals or multi-functional devices and do not constitute a limitation on terminals or multi-functional devices. They may include more or fewer components than shown in the illustration, or combine certain components, or use different components.
[0128] The input unit 130 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit 130 may include a touchscreen 131 (optional) and / or other input devices 132. The touchscreen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touchscreen), and drive the corresponding connection devices according to a pre-set program. The touchscreen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touchscreen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, various types of touchscreens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used to implement the touchscreen. Besides the touchscreen 131, the input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons 132, power buttons 133, etc.), trackball, mouse, joystick, etc.
[0129] The input device 132 can receive input images, etc.
[0130] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In this embodiment, the display unit 140 can be used to display the interface and processing results of a cross-modal language processing application.
[0131] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.
[0132] The processor 170 is the control center of the terminal 100. It connects various parts of the terminal 100 via various interfaces and lines. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it performs various functions and processes data of the terminal 100, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented separately on independent chips. The processor 170 can also be used to generate corresponding operation control signals, send them to the corresponding components of the computing processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that the various functional modules therein perform corresponding functions, thereby controlling the corresponding components to act according to the instructions.
[0133] The memory 120 can be used to store software code related to the data processing method, and the processor 170 can execute the steps of the chip's data processing method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.
[0134] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0135] In this embodiment of the application, the radio frequency unit 110 can send an image to the server 200 and receive the processing result sent by the server 200.
[0136] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.
[0137] The terminal 100 also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0138] Terminal 100 also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect terminal 100 to other devices for communication or to connect a charger to charge terminal 100.
[0139] Although not shown, terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with various functions, etc., which will not be described in detail here. Some or all of the methods described below can be applied to, for example... Figure 1D In the terminal 100 shown.
[0140] The following description Figure 1C The product form of the mid-range server 200;
[0141] Figure 2 A structural diagram of a server 200 is provided, as follows: Figure 2 As shown, server 200 includes bus 201, processor 202, communication interface 203, and memory 204. Processor 202, memory 204, and communication interface 203 communicate with each other via bus 201.
[0142] Bus 201 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 2 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0143] The processor 202 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0144] Memory 204 may include volatile memory, such as random access memory (RAM). Memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0145] The memory 204 can be used to store software code related to the data processing method, and the processor 202 can execute the steps of the chip's data processing method, and can also schedule other units to achieve corresponding functions.
[0146] It should be understood that the aforementioned terminal 100 and server 200 can be centralized or distributed devices. The processors (e.g., processor 170 and processor 202) in the aforementioned terminal 100 and server 200 can be hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the processor can be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0147] It should be understood that the steps related to the model inference process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and server is not limited to the processor-memory architecture described above. The following section will further explain... Figure 3 The system architecture provided in the embodiments of this application will be described in detail.
[0148] Figure 3 This is a schematic diagram of the system architecture provided for an embodiment of this application. Figure 3 As shown, the system architecture 500 includes an execution device 510, a training device 520, a database 530, a client device 540, a data storage system 550, and a data acquisition system 560.
[0149] The execution device 510 includes a calculation module 511, an I / O interface 512, a preprocessing module 513, and a preprocessing module 514. The calculation module 511 may include a target model / rule 501, while the preprocessing modules 513 and 514 are optional.
[0150] The execution device 510 can be a terminal device or a server that runs the aforementioned cross-modal language processing application.
[0151] The data acquisition device 560 is used to acquire training samples. Training samples can be multiple images, etc. After acquiring the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0152] The training device 520 can maintain training samples in the database 530 and obtain the target model / rule 501 from the neural network to be trained (e.g., the cross-modal language model in the embodiments of this application (e.g., including text encoder, image encoder, target encoder, etc.)).
[0153] It should be understood that the training device 520 can perform a pre-training process on the neural network to be trained based on the training samples maintained in the database 530, or fine-tune the model based on the pre-training.
[0154] It should be noted that in practical applications, the training samples maintained in database 530 may not all come from the data acquisition device 560; they may also be received from other devices. Furthermore, it should be noted that training device 520 may not necessarily train the target model / rule 501 entirely based on the training samples maintained in database 530; it may also obtain training samples from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application.
[0155] The target model / rule 501 trained using training device 520 can be applied to different systems or devices, such as... Figure 3 The execution device 510 shown can be a terminal, such as a mobile phone terminal, tablet computer, laptop computer, augmented reality (AR) / virtual reality (VR) device, vehicle terminal, etc., or it can be a server, etc.
[0156] Specifically, the training device 520 can transfer the trained model to the execution device 510.
[0157] exist Figure 3 In the execution device 510, an input / output (I / O) interface 512 is configured for data interaction with external devices. Users can input data (such as images in this embodiment) into the I / O interface 512 through the client device 540.
[0158] Preprocessing modules 513 and 514 are used to preprocess the input data received from the I / O interface 512. It should be understood that preprocessing modules 513 and 514 may be absent, or only one preprocessing module may be used. When preprocessing modules 513 and 514 are absent, the calculation module 511 can be used directly to process the input data.
[0159] During the preprocessing of input data by the execution device 510, or during the calculation module 511 of the execution device 510 performing calculations and other related processes, the execution device 510 can call data, code, etc. in the data storage system 550 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 550.
[0160] Finally, the I / O interface 512 provides the processing result to the client device 540, thereby providing it to the user.
[0161] exist Figure 3 In the illustrated scenario, the user can manually provide input data, which can be done through the interface provided by I / O interface 512. Alternatively, the client device 540 can automatically send input data to I / O interface 512. If user authorization is required for the client device 540 to automatically send input data, the user can set the corresponding permissions in the client device 540. The user can view the output results of the execution device 510 on the client device 540, which can be presented in various forms such as display, sound, or animation. The client device 540 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530. Alternatively, data can be collected directly from the I / O interface 512 without going through the client device 540, using the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530.
[0162] It is worth noting that, Figure 3 This is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the diagram do not constitute any limitation. For example, in Figure 3 In this context, the data storage system 550 is an external storage device relative to the execution device 510. However, in other cases, the data storage system 550 may also be placed within the execution device 510. It should be understood that the aforementioned execution device 510 may be deployed within the client device 540.
[0163] From the inference side of the model:
[0164] In this embodiment, the computing module 511 of the execution device 520 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in this embodiment.
[0165] In this embodiment of the application, the computing module 511 of the execution device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0166] Specifically, the computing module 511 of the execution device 520 can be a hardware system with the function of executing instructions. The steps related to the model inference process provided in this application embodiment can be software code stored in the memory. The computing module 511 of the execution device 520 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model inference process provided in this application embodiment.
[0167] It should be understood that the computing module 511 of the execution device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the model reasoning process provided in the embodiments of this application can also be implemented by the hardware system in the computing module 511 of the execution device 520 without the function of executing instructions, which is not limited here.
[0168] From the training side of the model:
[0169] In this embodiment of the application, the training device 520 can access the memory ( Figure 3 (Not shown in the diagram, but can be integrated into the training device 520 or deployed separately from the training device 520) The code stored in the diagram can be used to implement the steps related to model training in the embodiments of this application.
[0170] In this embodiment of the application, the training device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0171] It should be understood that the training device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the training of the neutralization model provided in the embodiments of this application can also be implemented by the hardware system in the training device 520 without the function of executing instructions, which is not limited here.
[0172] II. Cloud services providing cross-modal language processing capabilities:
[0173] In one possible implementation, the server can provide cross-modal language processing services to the client side through an application programming interface (API).
[0174] In this process, the terminal device can send relevant parameters (such as images) to the server through the API provided by the cloud. The server can obtain the processing results based on the received parameters and return the processing results to the terminal.
[0175] The description of the terminal and server can be found in the above embodiments, and will not be repeated here.
[0176] like Figure 4 This demonstrates the process of using a cloud service that provides cross-modal language processing capabilities through a cloud platform.
[0177] 1. Activate and purchase content moderation services.
[0178] 2. Users can download the software development kit (SDK) corresponding to the content moderation service. Cloud platforms usually provide multiple development versions of the SDK for users to choose from according to their development environment needs, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.
[0179] 3. After downloading the corresponding version of the SDK to their local machine according to their needs, users can import the SDK project into their local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment, thus forming an application that integrates cross-modal language processing capabilities.
[0180] 4. When an application needs to perform cross-modal language processing, it can trigger an API call for the cross-modal language processing function. When the application triggers the cross-modal language processing function, it sends an API request to the running instance of the cross-modal language processing service in the cloud environment. The API request carries an image, which is then processed by the running instance in the cloud environment to obtain the processing result.
[0181] 5. The cloud environment returns the processing result to the application, thus completing a cross-modal language processing function service call.
[0182] III. Cloud services for model training provided by the server:
[0183] In one possible implementation, the server can pre-train a model with cross-modal language processing capabilities based on training data provided by the client (e.g., images).
[0184] In one possible implementation, the server can provide model training services to the client side through an application programming interface (API).
[0185] In this process, the terminal device can send relevant parameters to the server through the API provided by the cloud. The server can obtain the processing results based on the received parameters and return the processing results (such as models with cross-modal language processing capabilities) to the terminal.
[0186] like Figure 5 This demonstrates the process of using a cloud service for model training provided by a cloud platform.
[0187] The description of the terminal and server can be found in the above embodiments, and will not be repeated here.
[0188] IV. Federal Training
[0189] Federated learning consists of two steps: model distribution and model upload. The central node distributes the model to the terminal devices via the network; each terminal device uses local data to calculate the gradient of the model; each distributed node encrypts the gradient and uploads it to the central node; the central node aggregates the gradients of each terminal distributed node and updates the parameters of the central node model using a parameter averaging algorithm.
[0190] See Figure 6 , Figure 6 This application provides an example of a model training method architecture, such as... Figure 6 As shown, the architecture provided in this application embodiment includes: a cloud-side central node, such as a cloud-side server. A1, A2, ... are distributed nodes of type A, such as a mobile phone product held by a user. B1, B2, ... are distributed nodes of type B, such as a personal computer held by a user. After obtaining the consent of the administrator of the distributed nodes (such as the user of the mobile phone or computer), the administrator of the distributed nodes voluntarily shares the data generated during their daily use of the device, under the premise of privacy protection, and adds it to the model training plan. The device becomes a distributed node in the architecture. The system in this embodiment can also include more types of distributed nodes, such as smartwatches, etc. To protect data privacy, the distributed nodes do not upload data to the central node, but only store data locally. The distributed nodes are connected to the cloud server through a communication network. The cloud-side central node can run large models, while each distributed node can only run small models due to hardware limitations, and A and B can have different data processing capabilities.
[0191] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.
[0192] (1) Neural Network
[0193] A neural network can be composed of neural units, which can be defined as a computational unit that takes xs (i.e., input data) and an intercept of 1 as input. The output of this computational unit can be:
[0194]
[0195] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer, and the activation function can be the sigmoid function. A neural network is a network formed by connecting multiple of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.
[0196] (2) Transformer layer
[0197] The neural network includes an embedding layer and at least one transformer layer. The at least one transformer layer can be N transformer layers (N being an integer greater than 0). Each transformer layer includes sequentially adjacent attention layers, add and normalize layers, feed-forward layers, and add and normalize layers. In the embedding layer, the current input is embedded to obtain multiple embedding vectors. In the attention layer, P input vectors are obtained from the layer above the first transformer layer. Using any first input vector among the P input vectors as the center, intermediate vectors corresponding to the first input vector are obtained based on the correlation between each input vector within a preset attention window and the first input vector. This process determines P intermediate vectors corresponding to the P input vectors. In the pooling layer, the P intermediate vectors are merged into Q output vectors, where the multiple output vectors obtained from the last transformer layer are used as feature representations of the current input.
[0198] (3) Attention mechanism
[0199] Attention mechanisms mimic the internal processes of biological observation—aligning internal experience with external senses to increase the precision of observation in specific areas. They enable the rapid sifting of high-value information from a large volume of data using limited attentional resources. Attention mechanisms can quickly extract important features from sparse data and are therefore widely used in natural language processing tasks, particularly machine translation. Self-attention mechanisms, an improvement on attention mechanisms, reduce reliance on external information and are better at capturing the internal correlations of data or features. The core idea of attention mechanisms can be rewritten as follows:
[0200] In this formula, Lx = ||Source|| represents the length of the Source. The meaning is that the elements in the Source are imagined as a series of data pairs. Given a Query element in the Target, the similarity or relevance between the Query and each Key is calculated to obtain the weight coefficient of the Value corresponding to each Key. Then, the Values are weighted and summed to obtain the final Attention value. Therefore, the Attention mechanism essentially performs a weighted sum of the Values of the elements in the Source, while the Query and Key are used to calculate the weight coefficients of their corresponding Values. Conceptually, Attention can be understood as selectively filtering a small amount of important information from a large amount of information and focusing on this important information, ignoring most of the unimportant information. The focusing process is reflected in the calculation of the weight coefficients; the larger the weight, the more focused it is on its corresponding Value. That is, the weight represents the importance of the information, and the Value is the corresponding information. Self-attention can be understood as intra attention. The attention mechanism occurs between the elements of the Target (Query) and all elements of the Source. Self-attention refers to the attention mechanism that occurs between elements within the Source or between elements within the Target. It can also be understood as the attention calculation mechanism in the special case where Target = Source. The specific calculation process is the same, only the calculation object changes.
[0201] (4) Natural Language Processing (NLP)
[0202] Natural language is human language, and Natural Language Processing (NLP) is the processing of human language. NLP is a systematic process of analyzing, understanding, and extracting information from text data in an intelligent and efficient manner. By using NLP and its components, we can manage very large amounts of text data, perform numerous automated tasks, and solve a wide variety of problems, such as automatic summarization, machine translation (MT), named entity recognition (NER), relation extraction (RE), information extraction (IE), sentiment analysis, speech recognition, question answering systems, and topic segmentation, among others.
[0203] (5) Pre-trained language model
[0204] A pre-trained language model is a natural language sequence encoder that encodes each word in a natural language sequence into a vector representation for prediction tasks. Its training consists of two phases. In the pre-training phase, the model is trained on a large-scale unsupervised text environment to learn word representations. In the fine-tuning phase, the model is initialized using the parameters learned in the pre-training phase and then trained on downstream tasks such as text classification and sequence labeling with fewer steps, successfully transferring the semantic information obtained in pre-training to downstream tasks.
[0205] (6) Backpropagation algorithm
[0206] Convolutional neural networks can employ backpropagation (BP) to correct the parameters in the initial super-resolution model during training, thereby reducing the reconstruction error loss. Specifically, forward propagation of the input signal to the output generates an error loss; this error loss information is then propagated back to update the parameters in the initial super-resolution model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining the optimal parameters of the super-resolution model, such as the weight matrix.
[0207] (7) Loss Function
[0208] In training a deep neural network, to ensure the output closely approximates the desired predicted value, we compare the network's prediction with the target value. Based on the difference, we update the weight vector of each layer (usually pre-configuring parameters before the initial update). For example, if the prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network predicts the target value or a value very close to it. Therefore, we need to predefine "how to compare the difference between the predicted and target values," which is the loss function or objective function. These are important equations used to measure the difference between the predicted and target values. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and training the deep neural network becomes a process of minimizing this loss.
[0209] Existing cross-modal visual language models (or multimodal models or multimodal language models) have relatively weak text modeling capabilities in their alignment methods. Taking TIA as an example, TIA simply determines whether a character is occluded, without adequately considering the semantic information between occluded characters, resulting in the model not truly understanding the document's content.
[0210] Current multimodal models have weak text-image alignment capabilities, meaning they lack the ability to align text and image elements. Taking text-image matching (TIM) as an example, the training objective is to determine whether global text matches global scanned document images. This task has low learning difficulty, resulting in trained models that lack the ability to align text and image elements.
[0211] To address the aforementioned problems, embodiments of this application provide a data processing method. The data processing method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0212] Reference Figure 7 , Figure 7 This is a flowchart illustrating a data processing method provided in an embodiment of this application, such as... Figure 7 As shown in the embodiment of this application, a data processing method may include steps 701 to 703, which are described in detail below.
[0213] 701. Obtain a first feature representation and a second feature representation, wherein the first feature representation is obtained by processing the image according to the image encoder, and the second feature representation is the text feature of the first text; the first text is the text content included in the image.
[0214] In one possible implementation, the original input image can be obtained and encoded using an image encoder to obtain an encoded result of the input image. This encoded result may include an image feature representation of the input image. It should be understood that the original input image in this application may refer to an image input into the extended modality language model, or an image after preprocessing of an image in the extended modality language model.
[0215] In one possible implementation, the image encoder can extract features from the input image. Specifically, the image encoder can be a convolutional neural network, a histogram of oriented gradients (HOG), a local binary pattern (LBP), or other neural networks used for feature extraction from images.
[0216] In one possible implementation, the input image can be processed by an image encoder to obtain the image feature representation corresponding to the input image.
[0217] In one possible implementation, the text contained in an image can be identified. For example, optical character recognition (OCR) can be used to identify the text contained in an image. Optionally, the positional information corresponding to each text unit can also be identified. This positional information can indicate the location of the region where the text unit is located in the image. For example, the region where the text unit is located can be represented by a rectangle, and the positional information can be the coordinates of the top-left and bottom-right points of the rectangle.
[0218] In one possible implementation, the text feature representation corresponding to the text can be obtained.
[0219] In one possible implementation, the text can be embedded through an embedding layer to obtain an embedding vector, which can be a representation of the text features corresponding to the text.
[0220] The embedding layer can be called the input embedding layer. The current input can be each text unit in the text. After obtaining the current input, the embedding layer can perform embedding processing on each text unit in the current input to obtain the embedding vector corresponding to each text unit.
[0221] In some embodiments, a position vector of each text unit may also be acquired, where the position vector is used to indicate the position of the text unit; the position is used to represent the position of the text unit in the text. Specifically, the position is used to indicate the relative positional relationship between the text unit and other text units in the text.
[0222] In one implementation, the embedding layer may include an input embedding layer and a positional encoding layer. In the input embedding layer, word embedding processing may be performed on each text unit in the current input, so as to obtain an embedding vector of each text unit. In the positional encoding layer, the position of each text unit in the current input may be acquired, and then a position vector is generated for the position of each text unit.
[0223] In some examples, the position of each text unit in the text may be the absolute position of each text unit in the text. Taking the current input "When should I pay back Huabei" as an example, the position of the character "几" may be represented as the first position, the position of the character "号" may be represented as the second position, and so on. In some examples, the position of each text unit in the text may be the relative position of each text unit in the text. Still taking the current input "When should I pay back Huabei" as an example, the position of the character "几" may be represented as before the character "号", the position of the character "号" may be represented as after the character "几" and before the character "应", and so on. When the embedding vector and the position vector of each text unit in the current input are obtained, the position vector of each text unit and the corresponding embedding vector may be fused to obtain the embedding vector of each text unit, that is, a plurality of embedding vectors corresponding to the current input are obtained. It should be understood that the fusion manner may be performing an addition operation on the embedding vector and the position vector, or using other operations to enable the embedding vector to carry information of one text unit in the text and the position of the one text unit in the text, and the specific fusion manner is not limited herein. For example, the fusion manner includes, but is not limited to, concatenate, add, fusion, multiply and the like.
[0224] In a possible implementation, the text may be subjected to embedding processing through an embedding layer to obtain an embedding vector, and the embedding vector is processed by a text encoder to obtain a text feature representation corresponding to the text.
[0225] In this embodiment, text-image contrastive learning (TIC) is used to enhance the matching ability between images and text, thereby improving the model's information processing capability for cross-modal data such as image and text information. Specifically, for image features and text features, a loss constructed through similarity comparison is used to update the image encoder (if the text features are obtained through the text encoder, the text encoder can also be updated). Although the image features and text features in the image are not features of the same modality, since the text is text in the image, the image features also contain certain semantic information of the text. Therefore, there is a correlation between image features and text features (belonging to the same image) in the semantic dimension (or other information dimensions). The aforementioned similarity can include the similarity between the semantic information in the image and the semantic information in the text. Therefore, updating the image encoder and text encoder (if a text encoder exists in the architecture) based on the loss constructed based on this similarity enables the features extracted by the image encoder and text encoder to contain more accurate semantic information of the text in the image, thereby enhancing the image-text matching ability of the subsequent network.
[0226] Furthermore, in the architecture of the cross-modal language model, which includes a graph encoder, a text encoder, and a target encoder for providing information on the interaction between features, this application updates the graph encoder and text encoder by using the loss constructed from the similarity between the intermediate outputs of the model (i.e., the outputs of the graph encoder and the text encoder). This allows the downstream tasks to be performed based on the feature representations output by the graph encoder and the text encoder (although the accuracy is not as high as that of the downstream tasks based on the feature representations output by the target encoder). In some scenarios, since the amount of data to be processed by the downstream tasks is large, the feature representations output by the graph encoder and the text encoder can be used for coarse ranking, and the feature representations output by the target encoder can be used for fine ranking to improve the recall rate.
[0227] Let's take an image and the first text as examples to illustrate the process of image-text comparison learning (i.e., text-image alignment):
[0228] In one possible implementation, the image can be the original input image (or a portion of the original input image, but containing all the text of the input image). The first text can be all the text contained in the image.
[0229] In one possible implementation, the image can be the original input image (or a portion of the original input image, but which contains all the text of the input image). The first text can be a portion of the text contained in the image.
[0230] In one possible implementation, the image can be a partial image region extracted from the original input image, which includes a portion of the text of all the text in the original input image, and the first text can be all the text included in the image.
[0231] In one possible implementation, the image can be a partial image region extracted from the original input image, which includes a portion of the text in the original input image, and the first text can be a portion of the text contained in the image.
[0232] In one possible implementation, the input original image may include one or more lines of text, or the input original image may include one or more columns of text. Optionally, the image may include one line or one column of text from the original image, and the first text may be one or more text units.
[0233] When performing image-text comparison learning, the loss for updating the image encoder and the text encoder can be constructed based on the similarity between the image features of the image and the text features of the first text. Optionally, this similarity is related to the similarity between the semantic information of the text contained in the image and the semantic information of the text itself.
[0234] It should be understood that the loss for updating the graph encoder and the text encoder can also be constructed based on the similarity between the image features of the image and the text features of the text not included in the image. The difference is that the image features of the image and the text features of the text in the image are positive examples (that is, the corresponding annotation similarity is high), while the image features of the image and the text features of the text not included in the image are negative examples (that is, the corresponding annotation similarity is low).
[0235] In one possible implementation, the aforementioned similarity can be either the similarity between text features and image features, or the similarity between image features and text features.
[0236] In one possible implementation, for the same original input image, the image features corresponding to the entire input image can be compared with the text features of all the text included in the input image, or the image features of a partial image region in the input image can be compared with the text features of a partial text included in the input image, or the image features corresponding to the entire input image can be compared with the text features of a partial text included in the input image, or a combination of the above methods.
[0237] In one possible implementation, for the same original input image, the text features corresponding to all the text included in the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to all the text included in the input image can be compared with the image features corresponding to the entire input image.
[0238] In one possible implementation, for different original input images, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features corresponding to the entire input image. Or, a combination of the above methods can be used.
[0239] In one possible implementation, for different original input images, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Alternatively, the text features of a portion of the text included in a portion of the input image can be compared with the image features of a portion of the image region in the input image. Or, the text features corresponding to the entire text included in a portion of the input image can be compared with the image features corresponding to the entire input image.
[0240] In one possible implementation, the image features of a portion of the image region can be determined by an image region feature extraction module (e.g., through a region of interest (ROI) head) based on the image features obtained by the image encoder. For example, the image region feature extraction module can perform bilinear interpolation on the image features (output by the image encoder) of the image region to be extracted to obtain the image features of a portion of the image region.
[0241] By using the above methods and comparing coarse-grained and fine-grained learning, we can enhance the overall matching of images and text and the matching of regions and text lines, thereby improving the performance of the model in downstream tasks such as information extraction.
[0242] For example, when constructing image-text contrast learning, the loss function of image-text contrast learning can be defined as:
[0243]
[0244] in, This represents the similarity between the k-th image and the j-th text.
[0245] For example, the loss function for text-image contrast learning can be defined as:
[0246]
[0247] in, This represents the similarity between the k-th text and the j-th image.
[0248] For example, the overall contrastive learning loss function for text lines and image regions can be defined as:
[0249]
[0250] To construct a fine-grained similarity matrix, the bidirectional similarity between image and text line regions can be expressed as follows:
[0251]
[0252] in,
[0253] The following is an example of an application of text-image contrastive learning (TIC):
[0254] Reference Figure 8 This embodiment can be divided into the following steps:
[0255] 1) Scale the image to a specific resolution (e.g., 448x448);
[0256] 2) Use OCR tools to obtain the text line content and position (bounding box) of the document;
[0257] 3) Extract visual representations of text lines using Mask R-CNN;
[0258] 4) Use Roberta to extract textual representations from document text lines;
[0259] 5) Construct a visual-text matching matrix and select the most matching text (visual) token for each visual (text) element;
[0260] 6) Optimize the TIC loss for image-text comparison learning.
[0261] 702. Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations.
[0262] In this application, the alignment capability of multimodal systems can be improved by first using a dual-tower approach, and then the interactive learning capability of features can be further enhanced by using a single-tower structure for multimodal systems. This is beneficial for downstream tasks such as efficient document retrieval (first coarse ranking and then fine ranking).
[0263] In one possible implementation, a third feature representation can be obtained by a target encoder based on the first feature representation and the second feature representation. The third feature representation may include text features corresponding to the first text and image features corresponding to the image. Unlike the first feature representation and the second feature representation, the features output by the target encoder are learned based on the interaction between the first feature representation and the second feature representation.
[0264] 703. Based on the third feature representation, perform downstream tasks to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, are used to update the image encoder.
[0265] In one possible implementation, the target encoder can obtain a third feature representation, which can be used to perform downstream tasks to obtain an execution result. This execution result can be used to construct a loss with the corresponding annotations to update the graph encoder, the text encoder (if any), and the target encoder.
[0266] In one possible implementation, different losses can be constructed by setting different downstream tasks.
[0267] In one possible implementation, downstream tasks may include bounding-box gridmatching (BGM).
[0268] In one possible implementation, the first text may include a first sub-text and a second sub-text, and the second feature represents a first sub-feature corresponding to the first sub-text and a second sub-feature corresponding to the second sub-text; the first sub-feature does not include the position of the first sub-text in the image; the second sub-feature includes the position of the second sub-text in the image; that is, when generating the text features of the first text, for a portion of the first text (e.g., the second sub-text), the text and position information can be used to generate corresponding text features (e.g., the second sub-feature), and for a portion of the first text (e.g., the first sub-text), the text and position information can be used to generate corresponding text features (e.g., the first sub-feature), which is equivalent to the first sub-feature not including the position of the first sub-text in the image; and the second sub-feature including the position of the second sub-text in the image.
[0269] In one possible implementation, optical character recognition (OCR) can be used to identify the text contained in an image and its corresponding location information. This location information can indicate the position of the area where the text is located in the image. For example, the area where the text is located can be represented by a rectangle, and the location information can be the coordinates of the top left and bottom right points of the rectangle.
[0270] Furthermore, the third feature representation may include the location information of the second sub-text but not the location information of the first sub-text (this omission can be understood as due to the input, but it can be implicitly included), and can be predicted based on the third feature representation. Specifically, the first position of the first sub-text in the image can be predicted based on the third feature representation; the similarity between the first position and the corresponding annotation (i.e., the true position of the first sub-text in the image) is used to update the image encoder and the target encoder.
[0271] In one possible implementation, the image comprises multiple image blocks; the first position is the image block where the first sub-text is predicted to be located; and the annotation is the image block where the first sub-text is actually located.
[0272] For example, refer to Figure 9 This embodiment can be divided into the following steps:
[0273] 1) Scale the image to a specific resolution (e.g., 448x448);
[0274] 2) Divide the image area into several regions (e.g., 4x4 grids);
[0275] 3) Use OCR to obtain the coordinates of the bounding box for each character;
[0276] 4) Randomly select a certain proportion of text lines that do not contain mask language modeling (MLM) (if the downstream task includes MLM), and cover the text box coordinates of each character in the text line (for example, the text box coordinates can be set to [0, 0, 0, 0]).
[0277] 5) Determine which area of the image contains the text whose location information is obscured.
[0278] The features of each word can be represented as an aggregation of multimodal features, such as:
[0279] E i =E word (t i )+E layout (ti )
[0280] Where E word and E layout These represent the word embedding and layout information of the i-th word, respectively.
[0281] By masking the layout information of the i-th word and then predicting the category of the word in the spatial partition of the original image, the loss function of BGM can be defined as:
[0282]
[0283] Among them, y ij p represents the true label of the i-th word. ij This represents the probability that the i-th word belongs to the j-th image region.
[0284] This application proposes a Background Music (BGM) mechanism for single-tower models to enhance spatial layout awareness, which helps improve model performance in location-sensitive tasks. For example, in information extraction, key-value pairs are usually adjacent pairs of data. Because the model has already learned to perceive location and layout information during the pre-training stage, it will have good performance in information extraction tasks.
[0285] Furthermore, downstream tasks can also include MLM. Specifically, during the feedforward process of model training, text units in the text can be masked (e.g., with random masks). The masked text units can be used as predicted text, while the unmasked text units can be used as known text. The model can then predict the text at the positions of the masked text units sequentially, based on the unmasked text units (or the already predicted masked text units). For example, the text could be "the cat sat on the mat," and after masking, it can be "the_sat_the mat." Here, the symbol "_" represents the mask, not the underscore. During the first prediction, the text at the position of one of the "_" symbols can be predicted using the initial flag and the unmasked text units.
[0286] In one possible implementation, to improve the learning ability of image representation, a loss function can be constructed based on image features. Specifically, a portion of the image can be masked, and the masked region can be reconstructed using the result from the image encoder. The network is then updated based on the difference between the pixel values of the reconstructed region and the real image of the masked region. However, existing methods have weak image representation learning capabilities. This is because, to reduce the computational overhead of the model, the image needs to be compressed to a smaller resolution (e.g., 224*224). When the image contains dense text, the pixels in the image struggle to accurately represent the textual information, resulting in limited image representation learning capabilities for the trained model.
[0287] In this embodiment of the application, in order to improve the learning ability of image representation, the image features of the image can be masked instead of the image itself, and the image features of the masked region can be reconstructed. The network is then updated based on the difference between the reconstruction result and the image features of the masked region. Since image features can carry richer image and text information than pixel values themselves, the learning ability of the trained network to represent images can be improved. The above method can be called mask image modeling (MIM).
[0288] In one possible implementation, the first feature representation includes a third sub-feature and a fourth sub-feature; a feature prediction value at the third position can be obtained based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
[0289] In one possible implementation, a fourth feature representation can be obtained through a self-attention network based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; and a feature prediction value at the third position can be obtained through a prediction network based on the fourth feature representation.
[0290] It should be understood that the object to be masked (the first feature representation) can be obtained by the image encoder, or it can be obtained by processing the image features obtained by the image encoder, such as the image features determined by the image region feature extraction module (for example, by the region of interest (ROI) head) for a portion of the image region.
[0291] For example, refer to Figure 10 This embodiment can be divided into the following steps:
[0292] 1) Scale the image to a specific resolution (e.g., 448x448);
[0293] 2) Calculate the convolutional feature map of the current image;
[0294] 3) Calculate the visual features (ROI features) of each text box region;
[0295] 4) Randomly select a certain proportion of text lines that do not contain MLM (if the downstream task includes MLM), and cover the corresponding region of the text line in the feature map of the convolutional network;
[0296] 5) Feed all ROI features (including masked ROI features) into self-attention.
[0297] 6) Reconstruct the features of the masked ROI using contrastive / L1 loss, etc.
[0298] To enhance the representation learning of image branches, we first extract the visual features of each text line using ROI alignment:
[0299]
[0300] in Let W represent the ROI visual features of the i-th text line, and let W and b be the network parameters.
[0301] Optionally, an attention mechanism can be used to recompute a new aggregated representation of the visual features of each line of text:
[0302] H=Atten(f;φ)=Atten({fi};φ);
[0303] Where H is the latent space representation of ROI features, Atten is the self-attention module, and φ is the network parameter.
[0304] The loss function for reconstructing the visual mask features of text lines in an image can be expressed as:
[0305]
[0306] in, H represents the visual reconstruction feature of the i-th occluded text box. i express The corresponding groundtruth labels.
[0307] This embodiment employs higher resolution in conjunction with MIM (Masked Image Modeling) to enhance the visual representation learning of text line regions. Based on the feature map angle, the occlusion visual feature map is reconstructed, and the ROI features of adjacent unmasked text lines are used to help reconstruct the visual features of the occluded text lines. By enhancing the learning ability of visual representations, multimodal feature alignment can be further improved, and the model's performance in downstream tasks such as text and image classification can be enhanced.
[0308] The following section describes the beneficial effects of this application based on experimental results:
[0309] As shown in Table 1, this application outperforms state-of-the-art performance on public datasets such as information extraction datasets (FUNSD, CORD, and SROI) and image-text classification datasets (such as RVL-CDIP).
[0310] Table 1
[0311]
[0312] This application provides a data processing method, comprising: obtaining a first feature representation and a second feature representation, wherein the first feature representation is obtained by processing an image using an image encoder, and the second feature representation is a text feature of a first text; the first text is the text content included in the image; the similarity between the first feature representation and the second feature representation is used to update the image encoder; a third feature representation is obtained by using a target encoder based on the first feature representation and the second feature representation; the target encoder is used to realize the interaction between the feature representations; and a downstream task is executed based on the third feature representation to obtain an execution result.
[0313] In this embodiment, text-image contrastive learning (TIC) is used to enhance the matching ability between images and text. Specifically, for the image features and text features of the image, a loss constructed through similarity comparison is used to update the image encoder (if the text features are obtained through the text encoder, the text encoder can also be updated). Although the image features of the image and the text features of the text in the image are not features of the same modality, since the text is text in the image, the image features also contain certain semantic information of the text. Therefore, there is a correlation between the image features and the text features (belonging to the same image) in the semantic dimension (or other information dimensions). The aforementioned similarity can include the similarity between the semantic information in the image and the semantic information in the text. Therefore, updating the image encoder and the text encoder (if a text encoder exists in the architecture) based on the loss constructed based on this similarity enables the features extracted by the image encoder and the text encoder to contain more accurate semantic information of the text in the image, thereby enhancing the image-text matching ability of the subsequent network.
[0314] Furthermore, in the architecture of the cross-modal language model, which includes a graph encoder, a text encoder, and a target encoder for providing information on the interaction between features, this application updates the graph encoder and text encoder by using the loss constructed from the similarity between the intermediate outputs of the model (i.e., the outputs of the graph encoder and the text encoder). This allows the downstream tasks to be performed based on the feature representations output by the graph encoder and the text encoder (although the accuracy is not as high as that of the downstream tasks based on the feature representations output by the target encoder). In some scenarios, since the amount of data to be processed by the downstream tasks is large, the feature representations output by the graph encoder and the text encoder can be used for coarse ranking, and the feature representations output by the target encoder can be used for fine ranking to improve the recall rate.
[0315] Reference Figure 11 , Figure 11 This diagram illustrates the architecture of the model in this application. It employs a dual-tower approach to align image and text features, followed by a single-tower approach to construct a multimodal image-text interaction module. In the dual-tower section, features are extracted from image and text encodings separately. Then, coarse-grained and fine-grained contrastive learning is used to enhance overall image-text matching and region-text line matching capabilities. In the single-tower section, BGM (Box Grid Matching) is proposed to improve spatial layout awareness. To enhance the model's ability to model visual representations, a higher resolution is used in the visual branch in conjunction with MIM (Masked Image Modeling) to improve the visual representation learning of text line regions.
[0316] In addition, this application also provides a data processing method, the method comprising:
[0317] Acquire images;
[0318] The image is processed by an image encoder to obtain a first feature representation;
[0319] The text contained in the image is processed by a text encoder to obtain a second feature representation;
[0320] Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations.
[0321] Based on the third feature, downstream tasks are executed to obtain the execution result.
[0322] Reference Figure 12 , Figure 12 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application, such as... Figure 12 As shown in the figure, an embodiment of this application provides a data processing apparatus 1200, comprising:
[0323] The acquisition module 1201 is used to acquire a first feature representation and a second feature representation. The first feature representation is obtained by processing the image according to the image encoder. The second feature representation is the text feature of the first text. The first text is the text content included in the image.
[0324] The specific description of the acquisition module 1201 can be found in the description of step 701 in the above embodiments, and will not be repeated here.
[0325] The encoding module 1202 is used to obtain a third feature representation based on the first feature representation and the second feature representation through a target encoder; the target encoder is used to realize the interaction between the feature representations.
[0326] The specific description of the encoding module 1202 can be found in the description of step 702 in the above embodiment, and will not be repeated here.
[0327] The task execution module 1203 is used to execute downstream tasks based on the third feature representation to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, are used to update the image encoder.
[0328] The specific description of the task execution module 1203 can be found in the description of step 703 in the above embodiments, and will not be repeated here.
[0329] In one possible implementation, the second feature is represented as a text feature obtained by processing the first text through a text encoder; the similarity between the first feature representation and the second feature representation is also used to update the text encoder.
[0330] In one possible implementation, the similarity between the first feature representation and the second feature representation is related to the similarity between the textual semantic information contained in the image and the semantic information of the text itself.
[0331] In one possible implementation,
[0332] The first text is all the text contained in the image; or,
[0333] The first text is a portion of all the text contained in the image.
[0334] In one possible implementation,
[0335] The image is a partial image region extracted from the original input image, and the text included in the image is a portion of the text contained in the input image; or,
[0336] The image is the original input image.
[0337] In one possible implementation, the first text includes a first subtext and a second subtext, and the second feature represents a first sub-feature corresponding to the first subtext and a second sub-feature corresponding to the second subtext; the first sub-feature does not contain the position of the first subtext in the image; the second sub-feature contains the position of the second text in the image;
[0338] The task execution module is specifically used for:
[0339] Based on the third feature representation, the first position of the first sub-text in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
[0340] In one possible implementation, the image comprises multiple image blocks; the first position is the image block where the first sub-text is predicted to be located; and the annotation is the image block where the first sub-text is actually located.
[0341] In one possible implementation, the first feature representation includes a third sub-feature and a fourth sub-feature; the method further includes:
[0342] The prediction module is used to obtain a feature prediction value at the third position based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
[0343] In one possible implementation, the prediction module is specifically used for:
[0344] Based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation, a fourth feature representation is obtained through a self-attention network.
[0345] Based on the fourth feature representation, the feature prediction value at the third position is obtained through the prediction network.
[0346] In addition, this application also provides a data processing apparatus, the apparatus comprising:
[0347] The acquisition module is used to acquire images;
[0348] The encoding module is used to process the image through an image encoder to obtain a first feature representation;
[0349] The text contained in the image is processed by a text encoder to obtain a second feature representation;
[0350] Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations.
[0351] The task execution module is used to execute downstream tasks based on the third feature representation and obtain the execution result.
[0352] The following describes an execution device provided in an embodiment of this application. Please refer to [link / reference]. Figure 13 , Figure 13 This is a schematic diagram of an execution device provided in an embodiment of this application. The execution device 1300 can specifically be a virtual reality (VR) device, a mobile phone, a tablet, a laptop, a smart wearable device, a monitoring data processing device, or a server, etc., and is not limited thereto. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303, and a memory 1304 (wherein the execution device 1300 may have one or more processors 1303). Figure 13(Taking a processor as an example), processor 1303 may include application processor 13031 and communication processor 13032. In some embodiments of this application, receiver 1301, transmitter 1302, processor 1303 and memory 1304 may be connected via bus or other means.
[0353] Memory 1304 may include read-only memory and random access memory, and provides instructions and data to processor 1303. A portion of memory 1304 may also include non-volatile random access memory (NVRAM). Memory 1304 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0354] Processor 1303 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.
[0355] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1303. The processor 1303 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 1303 or by instructions in software form. The processor 1303 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1303 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1304. Processor 1303 reads the information from memory 1304 and, in conjunction with its hardware, completes the steps involved in the model inference process described above.
[0356] Receiver 1301 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1302 can be used to output digital or character information through the first interface; transmitter 1302 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1302 may also include a display device such as a display screen.
[0357] This application also provides a training device; please refer to [link / reference]. Figure 14 , Figure 14This is a schematic diagram of a training device provided in an embodiment of this application. Specifically, the training device 1400 is implemented by one or more servers. The training device 1400 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1414 (e.g., one or more processors) and memory 1432, and one or more storage media 1430 (e.g., one or more mass storage devices) for storing application programs 1442 or data 1444. The memory 1432 and storage media 1430 can be temporary or persistent storage. The program stored in the storage media 1430 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the training device. Furthermore, the CPU 1414 may be configured to communicate with the storage media 1430 and execute the series of instruction operations in the storage media 1430 on the training device 1400.
[0358] The training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input / output interfaces 1458; or, one or more operating systems 1441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0359] In this embodiment, the central processing unit 1414 is used to perform actions related to model training in the above embodiments.
[0360] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0361] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0362] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the data processing method described in the above embodiments, or to cause the chip within the training device to execute the data processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).
[0363] For details, please refer to Figure 15 , Figure 15 This is a schematic diagram of a chip provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1500. The NPU 1500 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1503, which is controlled by the controller 1504 to extract matrix data from the memory and perform multiplication operations.
[0364] In some implementations, the arithmetic circuit 1503 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1503 is a two-dimensional pulsating array. The arithmetic circuit 1503 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1503 is a general-purpose matrix processor.
[0365] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1502 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1501 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is stored in the accumulator 1508.
[0366] Unified memory 1506 is used to store input and output data. Weight data is directly transferred to weight memory 1502 via Direct Memory Access Controller (DMAC) 1505. Input data is also transferred to unified memory 1506 via DMAC.
[0367] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1509.
[0368] The Bus Interface Unit (BIU) 1510 is used by the instruction fetch memory 1509 to fetch instructions from external memory, and also by the memory access controller 1505 to fetch the original data of the input matrix A or the weight matrix B from external memory.
[0369] The DMAC is mainly used to move input data from external memory DDR to unified memory 1506, or to weight data to weight memory 1502, or to input data to input memory 1501.
[0370] The vector computation unit 1507 includes multiple arithmetic processing units that, when needed, further process the output of the computation circuit 1503, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0371] In some implementations, the vector computation unit 1507 can store the processed output vector in the unified memory 1506. For example, the vector computation unit 1507 can apply a linear function, or a nonlinear function, to the output of the computation circuit 1503, such as performing linear interpolation on the feature planes extracted by the convolutional layer, or, for example, accumulating a vector of values to generate activation values. In some implementations, the vector computation unit 1507 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit 1503, for example, for use in subsequent layers of the neural network.
[0372] The instruction fetch buffer 1509 connected to the controller 1504 is used to store the instructions used by the controller 1504;
[0373] Unified memory 1506, input memory 1501, weighted memory 1502, and instruction fetch memory 1509 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.
[0374] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.
[0375] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0376] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0377] In the above embodiments, the implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of a computer program product.
[0378] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A data processing method, characterized in that, include: A first feature representation and a second feature representation are obtained. The first feature representation is obtained by processing the image using an image encoder. The second feature representation is the text feature of the first text. The first text is the text content included in the image. The first text includes a first sub-text and a second sub-text. The second feature representation includes a first sub-feature corresponding to the first sub-text and a second sub-feature corresponding to the second sub-text. The first sub-feature does not include the position of the first sub-text in the image. The second sub-feature includes the position of the second sub-text in the image. Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations. Based on the third feature representation, downstream tasks are executed to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, are used to update the image encoder; the similarity between the first feature representation and the second feature representation is related to the similarity between the textual semantic information contained in the image and the semantic information of the text itself; The step of performing downstream tasks based on the third feature representation includes: Based on the third feature representation, the first position of the first sub-text in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
2. The method according to claim 1, characterized in that, The second feature is a text feature obtained by processing the first text through a text encoder; the similarity between the first feature representation and the second feature representation is also used to update the text encoder.
3. The method according to any one of claims 1 to 2, characterized in that, The first text is all the text contained in the image; or, The first text is a portion of all the text contained in the image.
4. The method according to any one of claims 1 to 2, characterized in that, The image is a partial image region extracted from the original input image, and the text included in the image is a portion of the text contained in the input image; or, The image is the original input image.
5. The method according to claim 1, characterized in that, The image includes multiple image blocks; the first position is the image block where the first sub-text is predicted to be located; the annotation is the image block where the first sub-text is actually located.
6. The method according to any one of claims 1 to 2, characterized in that, The first feature representation includes a third sub-feature and a fourth sub-feature; the method further includes: Based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation, a feature prediction value at the third position is obtained; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
7. The method according to claim 6, characterized in that, The step of obtaining the feature prediction value at the third position based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation includes: Based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation, a fourth feature representation is obtained through a self-attention network. Based on the fourth feature representation, the feature prediction value at the third position is obtained through the prediction network.
8. A data processing method, characterized in that, The method includes: Acquire images; The image is processed by an image encoder to obtain a first feature representation; The text contained in the image is processed by a text encoder to obtain a second feature representation. The text includes a first sub-text and a second sub-text. The second feature representation includes a first sub-feature corresponding to the first sub-text and a second sub-feature corresponding to the second sub-text. The first sub-feature does not contain the position of the first sub-text in the image. The second sub-feature contains the position of the second sub-text in the image. Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations. Based on the third feature representation, downstream tasks are executed to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, are used to update the image encoder and the text encoder; the similarity between the first feature representation and the second feature representation is related to the similarity between the text semantic information contained in the image and the semantic information of the text itself; The step of performing downstream tasks based on the third feature representation includes: Based on the third feature representation, the first position of the first sub-text in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
9. A data processing apparatus, characterized in that, include: The acquisition module is used to acquire a first feature representation and a second feature representation. The first feature representation is obtained by processing the image using an image encoder. The second feature representation is the text feature of a first text. The first text is the text content included in the image. The first text includes a first sub-text and a second sub-text. The second feature representation includes a first sub-feature corresponding to the first sub-text and a second sub-feature corresponding to the second sub-text. The first sub-feature does not include the position of the first sub-text in the image. The second sub-feature includes the position of the second sub-text in the image. An encoding module is used to obtain a third feature representation based on the first feature representation and the second feature representation through a target encoder; the target encoder is used to realize the interaction between the feature representations. The task execution module is used to execute downstream tasks based on the third feature representation to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, is used to update the image encoder; the similarity between the first feature representation and the second feature representation is related to the similarity between the text semantic information contained in the image and the semantic information of the text itself; Specifically, the task execution module is used for: Based on the third feature representation, the first position of the first sub-text in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
10. The apparatus according to claim 9, characterized in that, The second feature is a text feature obtained by processing the first text through a text encoder; the similarity between the first feature representation and the second feature representation is also used to update the text encoder.
11. The apparatus according to any one of claims 9 to 10, characterized in that, The first text is all the text contained in the image; or, The first text is a portion of all the text contained in the image.
12. The apparatus according to any one of claims 9 to 10, characterized in that, The image is a partial image region extracted from the original input image, and the text included in the image is a portion of the text contained in the input image; or, The image is the original input image.
13. The apparatus according to claim 9, characterized in that, The image includes multiple image blocks; the first position is the image block where the first sub-text is predicted to be located; the annotation is the image block where the first sub-text is actually located.
14. The apparatus according to any one of claims 9 to 10, characterized in that, The first feature indicates that it includes a third sub-feature and a fourth sub-feature; the device further includes: The prediction module is used to obtain a feature prediction value at the third position based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation; the similarity between the feature prediction value and the third sub-feature is used to update the image encoder.
15. The apparatus according to claim 14, characterized in that, The prediction module is specifically used for: Based on the fourth sub-feature, the second position of the fourth sub-feature in the first feature representation, and the third position of the third sub-feature in the first feature representation, a fourth feature representation is obtained through a self-attention network. Based on the fourth feature representation, the feature prediction value at the third position is obtained through the prediction network.
16. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire images; The encoding module is used to process the image through an image encoder to obtain a first feature representation; The text contained in the image is processed by a text encoder to obtain a second feature representation. The text includes a first sub-text and a second sub-text. The second feature representation includes a first sub-feature corresponding to the first sub-text and a second sub-feature corresponding to the second sub-text. The first sub-feature does not contain the position of the first sub-text in the image. The second sub-feature contains the position of the second sub-text in the image. Based on the first feature representation and the second feature representation, a third feature representation is obtained through a target encoder; the target encoder is used to realize the interaction between the feature representations. The task execution module is used to execute downstream tasks based on the third feature representation to obtain execution results; the similarity between the execution results and the corresponding annotations, as well as the similarity between the first feature representation and the second feature representation, is used to update the image encoder and the text encoder; the similarity between the first feature representation and the second feature representation is related to the similarity between the text semantic information contained in the image and the semantic information of the text itself; The step of performing downstream tasks based on the third feature representation includes: Based on the third feature representation, the first position of the first sub-text in the image is predicted; the similarity between the first position and the corresponding annotation is used to update the image encoder and the target encoder.
17. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operation of the method according to any one of claims 1 to 8.
18. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1 to 8.
19. A system comprising at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other. The at least one memory is used to store code; The at least one processor is used to execute the code to perform the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Cross-modal image-text matching training method and device, storage medium and electronic equipment
CN114283430A