Data processing method and apparatus thereof
By fusing additional feature representations into the generative model to update the encoder, the problems of high generative model training cost and low content accuracy are solved, achieving efficient model updates and improved copyright security.
Patent Information
- Application Number
- PCT/CN2024/137304
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-12
- Filing Date
- 2024-12-06
- Publication Date
- 2025-09-18
AI Technical Summary
Existing generative models require a lot of time and computing power during training, and the generated content may have copyright infringement and social bias issues that are difficult to effectively correct.
By obtaining the first input and the second input, the encoder is used to generate the first and second feature representations, and the first and second feature representations are fused with the additional third feature representation, and the encoder is updated to minimize the difference, avoiding the need to retrain the generation model.
It reduces the training cost of the generative model, improves the accuracy and copyright security of the generated content, and reduces the risk of social bias.
Smart Images

Figure CN2024137304_18092025_PF_FP_ABST
Abstract
Description
A data processing method and device thereof
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 12, 2024, with application number 202410283878.4 and application name “A data processing method and device thereof”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence, and in particular to a data processing method and device thereof. Background Art
[0003] Artificial Intelligence (AI) is the theory, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that seeks to understand the essence of intelligence and develop new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0004] Generative models, such as text-to-image diffusion models, have rapidly developed in recent years. However, these models can create inaccurate content due to outdated or flawed internal knowledge. Furthermore, the generated content can raise potential risks related to copyright infringement and social bias.
[0005] In existing technologies, in order to solve the aforementioned problems, it is necessary to reprocess the training data to train the model. However, training a generative model from scratch requires a lot of time and computing power. Summary of the Invention
[0006] In a first aspect, the present application provides a data processing method, the method comprising: obtaining a first input and a second input, the first input being a concept that needs to be corrected or relearned for a generation model, and the second input being specific content to be corrected or relearned, and obtaining, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder, respectively; fusing the first feature representation and the third feature representation to obtain a fused feature, wherein the third feature representation may not be obtained by the encoder but may be additionally set, and when updating the model, the third feature representation may be updated to obtain the updated fused feature, and updating the encoder with the goal of minimizing at least one difference including the first difference.
[0007] In an embodiment of the present application, an additional feature representation (third feature representation) is set. For example, the additional feature representation can be a randomly initialized feature representation, and the additional feature representation can be fused with the feature representation output by the target network layer of the encoder (if the feature representation is not set, the first feature representation can be input to the network after the target network layer. If the feature representation is set, the fusion result of the feature representation and the first feature representation can be input to the network after the target network layer). In an embodiment of the present application, it can be considered that the updated fusion feature is a better feature that the encoder needs to obtain. Therefore, the encoder can be updated with the feature that can be obtained by the intermediate network layer of the encoder as the update target. This process is calculated based on an optimization target with a closed-form solution. There is no need to reconstruct the training samples for model training. In addition, there is no need to update the parameters of the generated model, but only the encoder can be updated, thereby reducing the training cost of the model. The training cost is reflected in the time cost and computing power cost.
[0008] The first difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fusion feature.
[0009] In a possible implementation, the first input and the second input are texts, and the generation model is a text-graph model.
[0010] In a possible implementation, the first input and the second input are different descriptions of the same object.
[0011] For example, the first input and the second input are different names for the same object. For example, the first input may be "snowbird" and the second input may be "junco." The generative model cannot understand "snowbird" and cannot generate a corresponding image (possibly because other concepts influence the concept of "snowbird"). Therefore, the object represented by "snowbird" can be described by another name.
[0012] For example, the second input is a more general description of the same object than the first input. In other words, the second input is a more ambiguous description than the first input. The generative model can change its original understanding of the object from the first input to the second input, thereby forgetting the concept of the first input. For example, the first input can be the artist's name (name), and the second input can be normal art. Because the image corresponding to the artist's name (name) may have copyright issues, the generative model does not need to generate the image corresponding to the artist's name (name). Therefore, the artist's name can be described through a more ambiguous (i.e., general) description.
[0013] For example, the second input is a more specific description of the same object than the first input. In other words, the second input is a more accurate and detailed description than the first input. The generative model can transform its original understanding of the object from the first input to the second input, thereby learning and correcting the concept of the first input. For example, the first input may be "the president" and the second input may be a name.
[0014] In a possible implementation, the generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
[0015] In one possible implementation, the method further includes: obtaining a third input; obtaining, based on the third input, a third feature representation of the target network layer output of the encoder through the encoder; wherein the at least one difference also includes a second difference, and the second difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
[0016] In one possible implementation, the minimizing of at least one difference including the first difference includes: minimizing the fusion result of multiple differences including the first difference. For example, the fusion result is obtained by weighting the multiple differences. The weight used for weighting can be called a balance factor. By introducing a balance factor α∈[0,1) representing the editing strength, it is used to adjust the balance between concept preservation and editing effect in the optimization objective. Based on this weight, the editing strength and the ability to generate non-target concepts can be adjusted, and an editing strength factor is designed in the optimization objective, so that the editing strength of the concept can be flexibly adjusted.
[0017] In a possible implementation, the target network layer is the penultimate network layer of the encoder.
[0018] In a second aspect, the present application provides a data processing device, comprising:
[0019] An acquisition module, configured to acquire a first input and a second input;
[0020] A processing module is used to obtain, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder according to the first input and the second input; fuse the first feature representation and the third feature representation to obtain a fused feature; obtain first data and second data according to the fused feature and the second feature representation through a generative model, and update the fused feature according to the difference between the first data and the second data to obtain the updated fused feature; update the encoder with the goal of minimizing at least one difference including a first difference, where the first difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fused feature.
[0021] In a possible implementation, the first input and the second input are texts, and the generation model is a text-graph model.
[0022] In a possible implementation, the first input and the second input are different descriptions of the same object; wherein,
[0023] The first input and the second input are different names for the same object; or,
[0024] The second input is a more general description of the same object than the first input; or
[0025] The second input is a more specific description of the same object than the first input.
[0026] In a possible implementation, the generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
[0027] In a possible implementation, the acquisition module is further configured to: acquire a third input;
[0028] The processing module is further used to: obtain, through the encoder, a third feature representation of the target network layer output of the encoder based on the third input; wherein the at least one difference also includes a second difference, and the second difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
[0029] In a possible implementation, minimizing at least one difference including the first difference includes: minimizing a fusion result of multiple differences including the first difference.
[0030] In a possible implementation, the fusion result is obtained by weighting the multiple differences.
[0031] In a possible implementation, the target network layer is the penultimate network layer of the encoder.
[0032] In a third aspect, an embodiment of the present application provides a training device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the first aspect and any optional method thereof.
[0033] In a fourth aspect, an embodiment of the present application provides an execution device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to execute the second aspect and any optional method thereof.
[0034] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, the computer executes the above-mentioned first aspect and any optional method thereof, and the above-mentioned second aspect and any optional method thereof.
[0035] In a sixth aspect, an embodiment of the present application provides a computer program which, when executed on a computer, enables the computer to execute the above-mentioned first aspect and any optional method thereof, and the above-mentioned second aspect and any optional method thereof.
[0036] In a seventh aspect, the present application provides a chip system comprising a processor configured to support the execution of a data processing device to implement the functions described in the aforementioned aspects, such as transmitting or processing the data or information described in the aforementioned methods. In one possible design, the chip system further comprises a memory configured to store program instructions and data necessary for executing or training the device. The chip system may consist of a single chip or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] FIG1A is a schematic diagram of a structure of an artificial intelligence main framework;
[0038] 1B and 1C are schematic diagrams of the application system framework of the present invention;
[0039] FIG1D is a schematic diagram of an optional hardware structure of a terminal;
[0040] FIG2 is a schematic diagram of the structure of a server;
[0041] FIG3 is a schematic diagram of a system architecture of the present application;
[0042] Figure 4 shows a process of cloud services;
[0043] FIG5 is a flowchart of a data processing method provided in an embodiment of the present application;
[0044] FIG6 is a schematic diagram of a data processing method provided in an embodiment of the present application;
[0045] FIG7 is a schematic diagram of a data processing method provided in an embodiment of the present application;
[0046] FIG8 is a schematic diagram of a data processing method provided in an embodiment of the present application;
[0047] 9A to 9C are schematic diagrams of the effects provided by the embodiments of the present application;
[0048] FIG10 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;
[0049] FIG11 is a schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0050] FIG12 is a schematic diagram of a structure of a training device provided in an embodiment of the present application;
[0051] FIG13 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The following describes the embodiments of the present invention in conjunction with the accompanying drawings. The terms used in the embodiments of the present invention are only used to explain the specific embodiments of the present invention, and are not intended to limit the present invention.
[0053] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0054] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0055] As used herein, the terms "substantially," "about," and similar terms are used as terms of approximation, not as terms of degree, and are intended to take into account the inherent variations in measurements or calculations that one of ordinary skill in the art would recognize. Furthermore, the use of "may" when describing embodiments of the present invention refers to "one or more possible embodiments." As used herein, the terms "use," "using," and "used" may be considered synonymous with the terms "utilize," "utilizing," and "utilized," respectively. Additionally, the term "exemplary" is intended to refer to an example or illustration.
[0056] First, the overall workflow of an AI system will be described. See Figure 1A, which shows a schematic diagram of the main AI framework. This AI framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process 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. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.
[0057] (1) Infrastructure
[0058] Infrastructure provides computing power for AI systems, enabling communication with the outside world and supporting this through a foundational platform. External communication occurs through sensors; computing power is provided by intelligent chips (CPUs, NPUs, GPUs, ASICs, FPGAs, and other hardware accelerators). The foundational platform includes a distributed computing framework and network-related platform guarantees and support, including cloud storage and computing, and interconnected networks. For example, sensors communicate with the outside world to acquire data, which is then fed into the intelligent chips within the distributed computing system provided by the foundational platform for computation.
[0059] (2) Data
[0060] Data above the infrastructure layer represents data sources for AI. This data includes graphics, images, voice, and text, as well as IoT data from traditional devices. This includes business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0061] (3) Data processing
[0062] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
[0063] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0064] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0065] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
[0066] (4) General ability
[0067] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0068] (5) Smart products and industry applications
[0069] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0070] This application can be applied to the field of natural language processing in the field of artificial intelligence. Taking natural language processing as an example, the following will introduce multiple application scenarios that have been implemented in products.
[0071] First, we will introduce the application scenarios of this application. This application can be applied to, but is not limited to, applications with image generation (hereinafter referred to as generation applications) or cloud services provided by cloud-side servers. The following are introduced respectively:
[0072] 1. Generate application
[0073] The product form of the embodiment of the present application can be a generation type application. The generation type application can be run on a terminal device or a cloud-side server.
[0074] In one possible implementation, a generation application can implement an image generation task and obtain a processing result, for example, a text-based image generation task.
[0075] For example, the generation application may implement at least an image generation task based on a diffusion method, but is not limited thereto.
[0076] In one possible implementation, the user can open a generation application installed on the terminal device and input image data and text data (the text may be triggered by instructions and not necessarily actively input by the user). The generation application can process the image and text using a model trained by the method provided in the embodiment of the present application, or using the method provided in the embodiment of the present application, and present the processing results to the user (the presentation method may be but is not limited to display, playback, saving, uploading to the cloud side, etc.).
[0077] In one possible implementation, a user can open a generation application installed on a terminal device and input image data and text data. The generation application can send the image data and text data to a cloud-side server. The cloud-side server processes the image or text using a model trained using the method provided in an embodiment of the present application, and transmits the processing results back to the terminal device. The terminal device can present the processing results to the user (the presentation method may be, but is not limited to, display, playback, saving, uploading to the cloud side, etc.).
[0078] Next, the generation type application in the embodiment of this application is introduced from the functional architecture and the product architecture that realizes the function.
[0079] Referring to FIG. 1B , FIG. 1B is a schematic diagram of the functional architecture of a generation-type application in an embodiment of the present application:
[0080] In one possible implementation, as shown in FIG1B , a generation application 102 may receive input parameters 101 (e.g., including an image or text) and generate a processing result 103. The generation application 102 may be executed on (for example) at least one computer system and include computer code that, when executed by one or more computers, causes the computers to execute a model trained using the method provided in the embodiments of the present application.
[0081] Referring to FIG. 1C , FIG. 1C is a schematic diagram of the entity architecture for running a generation-type application in an embodiment of the present application:
[0082] Referring to FIG1C , FIG1C shows a schematic diagram of a system architecture. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers (FIG1C illustrates one server as an example), and the server 200 may provide image synthesis functionality for one or more terminals.
[0083] Among them, the terminal 100 can be installed with a generation application, or a web page related to the image synthesis or natural language generation function can be opened. The above application and web page can provide an interface. The terminal 100 can receive the relevant parameters entered by the user on the image synthesis or natural language generation function interface, and send the above parameters to the server 200. The server 200 can obtain the processing results based on the received parameters and return the processing results to the terminal 100.
[0084] 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 by itself without the need for the cooperation of the server, and the embodiments of the present application are not limited to this.
[0085] Next, the product form of the terminal 100 in FIG1C is described;
[0086] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.
[0087] FIG1D shows a schematic diagram of an optional hardware structure of the terminal 100 .
[0088] 1D , the terminal 100 may include components such as 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, and a power supply 190. Those skilled in the art will appreciate that FIG1D is merely an example of a terminal or multi-function device and does not limit the terminal or multi-function device. The terminal or multi-function device may include more or fewer components than shown, or may combine certain components or have different components.
[0089] The input unit 130 can be used to receive input digital or character information and generate key signal input related to user settings and function control of the portable multifunction device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can detect user touch operations on or near it (for example, operations performed on or near the touch screen using a finger, joint, stylus, or any other suitable object) and drive corresponding connected devices according to pre-set programs. The touch screen can detect user touch actions on the touch screen, convert the touch actions into touch signals and transmit them to the processor 170. It can also receive and execute commands sent by the processor 170; the touch signals include at least touch point coordinate information. The touch screen 131 provides an input interface and an output interface between the terminal 100 and the user. Touch screens can be implemented using various types, including resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 131, the input unit 130 may also include other input devices. Specifically, the other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0090] Among them, other input devices 132 can receive input image data or text data.
[0091] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In an embodiment of the present application, the display unit 140 may be used to display the interface of a generated application, processing results, etc.
[0092] Memory 120 can be used to store instructions and data. It primarily includes an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files and text. The instruction storage area can store software units such as the operating system, applications, and instructions required for at least one function, or subsets or extensions thereof. It may also include non-volatile random access memory (RAM). It provides processor 170 with management functions for the hardware, software, and data resources within the computing and processing device, supporting control software and applications. It is also used to store multimedia files and running programs and applications.
[0093] The processor 170 is the control center of the terminal 100. It connects all components of the terminal 100 using various interfaces and circuits. By executing instructions stored in the memory 120 and accessing data stored therein, it executes various functions of the terminal 100 and processes data, thereby providing overall control of the terminal device. Optionally, the processor 170 may include one or more processing units. Preferably, the processor 170 may integrate an application processor and a modem processor, with the application processor primarily processing the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory may be implemented on a single chip; in other embodiments, they may be implemented on separate chips. The processor 170 may also generate corresponding operational control signals and send them to the corresponding components of the computing and processing device. It may also read and process data in the software, particularly the data and programs in the memory 120, to enable the various functional modules therein to perform their corresponding functions, thereby controlling the corresponding components to operate as instructed.
[0094] Among them, the memory 120 can be used to store software codes related to the data processing method, 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 corresponding functions.
[0095] The RF unit 110 (optional) can be used to send and receive information or receive and send signals during a call. For example, after receiving downlink information from the base station, it is passed to the processor 170 for processing; in addition, it sends the designed uplink data to the base station. Generally, 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. In addition, the RF unit 110 can also communicate with network devices and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of 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.
[0096] In this embodiment of the present application, the RF unit 110 may send image data or text data to the server 200 and receive a processing result sent by the server 200.
[0097] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0098] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0099] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to other devices for communication, or to connect a charger to charge the terminal 100 .
[0100] Although not shown, the terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied to the terminal 100 shown in FIG1D .
[0101] Next, the product form of the server 200 in FIG1C is described;
[0102] FIG2 provides a schematic diagram of the structure of a server 200. As shown in FIG2, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0103] Bus 201 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, FIG2 shows only one thick line, but this does not imply that there is only one bus or only one type of bus.
[0104] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0105] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard drive (HDD), or solid state drive (SSD).
[0106] The memory 204 may be used to store software codes related to the data processing method, and the processor 202 may execute the steps of the data processing method of the chip, and may also schedule other units to implement corresponding functions.
[0107] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0108] It should be understood that the steps related to the model reasoning 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 system architecture provided in the embodiments of this application is described in detail below with reference to Figure 3.
[0109] FIG3 is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in FIG3 , 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 .
[0110] The execution device 510 includes a calculation module 511, an I / O interface 512, a pre-processing module 513, and a post-processing module 514. The calculation module 511 may include the target model / rule 501, and the pre-processing module 513 and the post-processing module 514 are optional.
[0111] The execution device 510 may be a terminal device or a server that runs the aforementioned generation application, or an image classification or retrieval application.
[0112] The data acquisition device 560 is used to collect training samples. The training samples can be image data or text data. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0113] The training device 520 can maintain training samples in the database 530 to train the neural network (such as the neural network model in the embodiment of the present application (such as an encoder, a generation model (such as a diffusion model), etc.)) to obtain the target model / rule 501.
[0114] 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.
[0115] It should be noted that, in actual applications, the training samples maintained in the database 530 may not all be collected by the data acquisition device 560, but may also be received from other devices. It should also be noted that the training device 520 may not train the target model / rule 501 entirely based on the training samples maintained in the database 530, but may also obtain training samples from the cloud or other places for model training. The above description should not be used as a limitation on the embodiments of the present application.
[0116] The target model / rule 501 obtained through training with the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in FIG3 . The execution device 510 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR) device, an in-vehicle terminal, etc., or a server, etc.
[0117] Specifically, the training device 520 may transfer the trained model to the execution device 510 .
[0118] In Figure 3, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with an external device. The user can input data (such as image data or text data in the embodiment of the present application) into the I / O interface 512 through the client device 540.
[0119] Preprocessing module 513 and preprocessing module 514 are used to preprocess the input data received by I / O interface 512. It should be understood that preprocessing module 513 and preprocessing module 514 may be absent or only one preprocessing module may be present. If preprocessing module 513 and preprocessing module 514 are absent, computing module 511 may be used directly to process the input data.
[0120] When the execution device 510 preprocesses the input data, or when the computing module 511 of the execution device 510 performs calculations and other related processing, the execution device 510 can call the data, code, etc. in the data storage system 550 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 550.
[0121] Finally, the I / O interface 512 provides the processed results to the client device 540 and thus to the user.
[0122] In the scenario shown in FIG3 , the user can manually input data, and this "manual input data" can be operated through the interface provided by I / O interface 512. In another scenario, client device 540 can automatically send input data to I / O interface 512. If user authorization is required for client device 540 to automatically send input data, the user can set the corresponding permissions in client device 540. The user can view the results output by execution device 510 on client device 540, and the specific presentation form can be a display, sound, action, or other specific method. Client device 540 can also serve as a data acquisition terminal, collecting input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data, and storing them in database 530. Of course, collection can also be performed without client device 540, and instead the I / O interface 512 directly stores the input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data in database 530.
[0123] It is worth noting that FIG3 is merely a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation. For example, in FIG3 , the data storage system 550 is an external memory relative to the execution device 510. In other cases, the data storage system 550 can also be placed in the execution device 510. It should be understood that the execution device 510 can be deployed in the client device 540.
[0124] From the inference side of the model:
[0125] In the embodiment of the present application, the computing module 511 of the above-mentioned execution device 510 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in the embodiment of the present application.
[0126] In an embodiment of the present application, the computing module 511 of the execution device 510 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0127] Specifically, the computing module 511 of the execution device 510 can be a hardware system with an execution instruction function, and the steps related to the model reasoning process provided in the embodiment of the present application can be software codes stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model reasoning process provided in the embodiment of the present application.
[0128] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to the model reasoning process provided in the embodiment of the present application can also be implemented by the hardware system that does not have the function of executing instructions in the computing module 511 of the execution device 510, which is not limited here.
[0129] From the training side of the model:
[0130] In an embodiment of the present application, the above-mentioned training device 520 can obtain the code stored in the memory (not shown in Figure 3, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in the embodiment of the present application.
[0131] In an embodiment of the present application, the training device 520 may include a hardware circuit (such as an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a general-purpose processor, a digital signal processor (DSP), a microprocessor or a microcontroller, etc.), or a combination of these hardware circuits. For example, the training device 520 may be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0132] It should be understood that the training device 520 can be a combination of a hardware system that does not have the function of executing instructions and a hardware system that has the function of executing instructions. Some of the steps related to model training provided in the embodiments of the present application can also be implemented by the hardware system in the training device 520 that does not have the function of executing instructions, which is not limited here.
[0133] 2. Image synthesis cloud services provided by the server:
[0134] In a possible implementation, the server may provide the image synthesis function service to the terminal side through an application programming interface (API).
[0135] Among them, the terminal device can send relevant parameters (such as images, text and other data) to the server through the API provided by the cloud. The server can obtain processing results based on the received parameters, etc., and return the processing results to the terminal.
[0136] The description of the terminal and the server can be the same as that of the above embodiments, and will not be repeated here.
[0137] FIG4 shows a process of using an image synthesis function cloud service provided by a cloud platform.
[0138] 1. Activate and purchase content review services.
[0139] 2. Users can download the software development kit (SDK) corresponding to the content review service. Usually, the cloud platform provides multiple development versions of the SDK for users to choose according to the requirements of the development environment, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.
[0140] 3. After the user downloads the corresponding version of the SDK to the local computer as needed, they import the SDK project into the local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment, forming an application that integrates image synthesis capabilities.
[0141] 4. When an image synthesis application is used and needs to perform image synthesis, it can trigger an API call for this function. When the application triggers this function, it initiates an API request to a running instance of the image synthesis service in the cloud environment. The API request includes an image or text, and the running instance in the cloud environment processes the image and obtains the processing result.
[0142] 5. The cloud environment returns the processing results to the application, thus completing a call to the image synthesis function.
[0143] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0144] (1) Neural Network
[0145] A neural network can be composed of neural units. A neural unit can refer to an operation unit that takes xs (i.e., input data) and intercept 1 as input. The output of the operation unit can be:
[0146] Where s = 1, 2, ... n, 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, which is used to introduce nonlinear characteristics into the neural network to convert the input signal of the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, 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. The local receptive field can be an area composed of several neural units.
[0147] (2) Deep Neural Networks
[0148] Deep Neural Network (DNN), also known as multi-layer neural network, can be understood as a neural network with many hidden layers. There is no special metric for "many" here. Based on the position of different layers in DNN, the neural network inside DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer. Although DNN looks complicated, the work of each layer is actually not complicated. Simply put, it is the following linear relationship expression: in, is the input vector, is the output vector, is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since there are many DNN layers, the coefficient W and the offset vector The definition of these parameters in DNN is as follows: Take the coefficient W as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.
[0149] In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as
[0150] It's important to note that the input layer has no W parameter. In deep neural networks, more hidden layers allow the network to better capture complex real-world situations. Theoretically, a model with more parameters has higher complexity and greater "capacity," meaning it can handle more complex learning tasks. Training a deep neural network is essentially the process of learning the weight matrix, with the ultimate goal of obtaining the weight matrices for all layers of a trained deep neural network (a weight matrix formed by the vectors W across many layers).
[0151] (3) Loss function
[0152] During the training of a deep neural network, because we want the output of the deep neural network to be as close as possible to the desired predicted value, we can compare the current network's predicted value with the desired target value and then update the weight vector of each layer of the neural network based on the difference between the two. (Of course, before the first update, there is usually an initialization process, which pre-configures the parameters for each layer in the deep neural network.) For example, if the network's predicted value is too high, the weight vector is adjusted to make it predict a lower value. This adjustment is continued until the deep neural network can predict the desired target value or a value very close to the desired target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value." This is the loss function (or objective function), which is an important equation used to measure the difference between the predicted value and the target value. For example, the loss function output value (loss) indicates a greater difference, so training a deep neural network becomes a process of minimizing this loss.
[0153] (4) Backpropagation algorithm
[0154] The back propagation (BP) algorithm can be used to correct the size of the initial model parameters during training, reducing the model's error loss. Specifically, forward propagation of the input signal to the output generates error loss. This error loss information is then backpropagated to update the parameters in the initial model, thereby converging the error loss. The BP algorithm is a backward propagation movement driven by error loss, aiming to obtain optimal model parameters, such as the weight matrix.
[0155] (5) Diffusion model
[0156] A generative model used to generate data, such as images and text. The core idea of the diffusion model is to diffuse noise into the data and then gradually remove the noise to restore the original data. The diffusion model consists of two stages: the forward process (noise diffusion) and the reverse process (noise removal and restoration).
[0157] Generative models, such as text-to-image diffusion models, have rapidly developed in recent years. However, these models can create inaccurate content due to outdated or flawed internal knowledge. Furthermore, the generated content can raise potential risks related to copyright infringement and social bias.
[0158] Existing technologies address this issue by reprocessing the training data to train the model. However, training a generative model from scratch requires significant time and computing power. Another solution, concept editing, involves modifying an already trained model's knowledge of specific concepts. This approach can address this issue efficiently and conveniently.
[0159] It is worth mentioning that in actual engineering, we need to face diversified concept editing problems, which requires concept editing methods to be able to handle multiple types of editing tasks and edit large-scale concepts. However, most existing work tends to focus on a single specific task, such as concept elimination, and is only applicable to small-scale concept editing. Some existing methods choose to effectively fine-tune some parameters of the model (such as the parameters of the cross-attention layer and self-attention layer in the U-Net network) to alleviate the problem. However, when editing multiple concepts, the model weights need to be modified sequentially, which introduces cumulative errors and leads to catastrophic forgetting. It cannot effectively edit more than 10 concepts and is extremely time-consuming.
[0160] In order to solve the above problems, the present invention provides a data processing method. The data processing method of the present invention is described in detail below with reference to the accompanying drawings.
[0161] Referring to Figure 5, Figure 5 is a flow chart of a data processing method provided in an embodiment of the present application. As shown in Figure 5, a data processing method provided in an embodiment of the present application may include steps 501 to 503, and these steps are described in detail below.
[0162] 501. Obtain a first input and a second input.
[0163] The embodiment corresponding to FIG5 may be a training process of a model (eg, a diffusion model), such as a model pre-training or model fine-tuning process.
[0164] The generative model may generate corresponding data based on input data. For example, the input data may be text, and the generative model may be a text graph model. The generative model may generate an image including semantic content indicated by the input text.
[0165] For generative models, due to training samples or other reasons, the trained model may still have poor understanding of some concepts, or may not understand them at all, resulting in the generated results not matching the requirements of the input data.
[0166] For example, for some nouns, the generative model may not understand and thus generate images containing the wrong object (not the object indicated by the input text).
[0167] For example, for some nouns, images containing objects that their semantic references are illegal, such as copyright issues. In this case, the generative model should generate images that do not contain objects that the noun semantics refers to.
[0168] For example, for some nouns, the image containing the object of its semantic reference is wrong. For example, due to timeliness, it is A during training, but it changes from A to B over time. In this case, the generative model will generate an image containing A.
[0169] The embodiments of the present application can be exemplarily applied to application scenarios such as preventing a cultural image model from plagiarizing an artist's style, correcting a cultural image model's erroneous understanding of concepts, and correcting a cultural image model's gender bias.
[0170] Application Scenario 1: Preventing the literary image model from plagiarizing the artist’s style
[0171] Currently, the Wenshengtu diffusion model can generate images by imitating the styles of multiple artists. Therefore, in actual deployment, the deployer may bear legal risks in terms of copyright due to this situation.
[0172] Application Scenario 2: Correcting Misunderstandings of Concepts in the Wensheng Graph Model
[0173] Currently, for some concept aliases (such as the scientific names of animals), generative diffusion models are prone to generating inaccurate images, which can mislead users.
[0174] Application Scenario 3: Correcting Gender Bias in the Wensheng Graph Model
[0175] The generated images of existing Vignette Diffusion models reflect social and cultural biases in the dataset and may further reinforce these biases. For example, for some professions (such as doctors), when gender is not specified, the Vignette Diffusion models often generate images of a single gender (e.g., all male doctors).
[0176] The purpose of the embodiment of the present application is to enable the generative model to learn concepts that need to be corrected (or newly learned) by updating the parameters of the generative model, wherein the first input can be the concept that needs to be corrected (or newly learned) and the second input can be the corrected concept.
[0177] In a possible implementation, the first input and the second input are different descriptions of the same object.
[0178] For example, the first input and the second input are different names for the same object. For example, referring to FIG6 , the first input may be "snowbird" and the second input may be "junco." The generative model cannot understand "snowbird" and cannot generate a corresponding image (possibly due to the influence of other concepts on the concept of "snowbird"). Therefore, the object represented by "snowbird" can be described by another name.
[0179] For example, the second input is a more general description of the same object than the first input. In other words, the second input is a more vague description than the first input. The generative model can change the original understanding of the object from the first input to the second input, thereby forgetting the concept of the first input. For example, referring to Figure 6, the first input can be the artist's name (name), and the second input can be normal art. Since the image corresponding to the artist's name (name) may have copyright issues, the generative model does not need to generate the image corresponding to the artist's name (name). Therefore, the artist's name (name) can be described by a more vague (i.e., general) description.
[0180] For example, the second input is a more specific description of the same object than the first input. In other words, the second input is a more accurate and detailed description than the first input. The generative model can transform its original understanding of the object from the first input to the second input, thereby learning and correcting the concept of the first input. For example, referring to Figure 6, the first input may be "the president" and the second input may be a name.
[0181] 502. According to the first input and the second input, obtain, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder, respectively.
[0182] In one possible implementation, for the input data (for example, the first input and the second input in the embodiment of the present application), features can first be extracted through an encoder to obtain corresponding feature representations. For example, when the first input and the second input are text, the encoder can be a text encoder.
[0183] Optionally, the text encoder can be consistent with the text encoder structure of CLIP, with the main framework being a transformer for extracting text features.
[0184] In a possible implementation, based on the first input and the second input, a first feature representation and a second feature representation of a target network layer output of the encoder are respectively obtained through an encoder.
[0185] In a possible implementation, the target network layer is the penultimate network layer of the encoder.
[0186] For example, the first input and the second input are text, and the network layer in the encoder can obtain the feature representation corresponding to each token of the input and the overall feature representation (for example, the feature vector of the [EOS] token, which is the feature obtained by encoding the entire input). In an embodiment of the present application, the first feature representation obtained by the encoder processing the first input can be the feature representation of the first input as a whole, and the second feature representation obtained by the encoder processing the second input can be the feature representation of the second input as a whole.
[0187] 503. Fuse the first feature representation and the third feature representation to obtain a fused feature.
[0188] In an embodiment of the present application, an additional feature representation is set. For example, the additional feature representation can be a randomly initialized feature representation. The additional feature representation can be fused with the feature representation output by the target network layer of the encoder (if the feature representation is not set, the first feature representation can be input into the network after the target network layer. If the feature representation is set, the fusion result of the feature representation and the first feature representation can be input into the network after the target network layer).
[0189] For example, the feature representation may have the same size as the first feature representation, so that the feature representation may be fused with the first feature representation (eg, fused by an addition operation).
[0190] 504. According to the fused feature and the second feature representation, a first data and a second data are obtained respectively by generating a model, and according to the difference between the first data and the second data, the fused feature is updated to obtain the updated fused feature.
[0191] In one possible implementation, the target network layer may be an intermediate network layer of an encoder, and may be processed by a network layer subsequent to the target network layer in the encoder based on the fused features and the second feature representation to obtain a processing result of the encoder, which may be input into a subsequent generative model to obtain a generation result. In this embodiment of the present application, the first data and the second data may be obtained, respectively, by a generative model based on the fused features and the second feature representation, wherein the first data and the second data may be generation results obtained by the generative model or may be outputs of an intermediate layer.
[0192] In a possible implementation, the generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
[0193] For example, the generative model can be a diffusion model. In the diffusion model architecture, the denoising module of the diffusion model adds noise to the input feature representation multiple times (that is, denoising at multiple steps). The denoising module of the diffusion model can predict the noise added at each step and perform denoising based on the predicted noise to obtain a generated image. The model can be a neural network with a UNet architecture. Unet is an end-to-end convolutional neural network mainly used for image segmentation. It is characterized by a U-shaped structure that includes an encoder and a decoder. The encoder uses convolutional layers and maximum pooling layers to achieve feature extraction and downsampling; the decoder performs feature fusion and recovery through upsampling and skip connections. This architecture is mainly used to predict the noise added in the text feature forward pass in the diffusion framework.
[0194] When using the diffusion model to generate images conditioned on text, the input can be denoised by the denoising module of the diffusion model. Specifically, the noise can be added according to the noise given by β t The variance given is gradually added to the sample Gaussian noise to produce a series of latent variables x1,x2,…,x T , where t is the number of steps to add noise (or it can be called step length), and N is the normal distribution:
[0195] Then learn a denoising module Φ θ (x t ,t) (that is, the denoising module in the diffusion model) to approximate the true posterior distribution, where u θ and Σ θ is the mean and variance predicted by the model: p θ (x t-1 |x t )=N(u θ (x t ,t),Σ θ (x t ,t));
[0196] In order to perform the inverse denoising process, we sample from random noise x T Starting from N(0,I), the noise is gradually reduced and finally a sample x0 is obtained. The existing method uses a denoising network Φ θ (x t ,t), which predicts the noise component of the noise sample and the following training objectives:
[0197] Among them, t can be uniformly sampled from 1, 2, ..., T, ∈ is the noise added to each step of the model. Here x0 can be the feature of the text.
[0198] In an embodiment of the present application, in the first stage, the model itself may not be updated (that is, the model parameters may not be updated), but an additional feature representation may be updated.
[0199] Specifically, the optimization goal can be set to align the features and predicted noise of the text encoding of the target concept and the anchor concept at the same time. The approach of aligning the features of the text encoding can be regarded as knowledge distillation from the text encoder of the text graph diffusion model (CLIP Text Encoder for Stable Diffusion), while the approach of aligning the predicted noise can be regarded as knowledge distillation from the visual skeleton network of the diffusion model (U-Net for Stable Diffusion). Regarding the alignment of the features of the text encoding, since it is generally believed that for CLIP's GPT-2 style text encoder, the feature vector of the [EOS] token encodes the features of the entire sentence, the optimization goal of this part is to align the final representation vector of the [EOS] token of the text prompt related to the target concept and the anchor concept. Specifically, it is to calculate the MSE Loss of the two representation row vectors, denoted as For the alignment prediction noise, the MSE Loss of the prediction noise based on the target concept condition and the prediction noise based on the anchor concept can be directly calculated, which is recorded as as the corresponding optimization target.
[0200] The loss may be constructed based on the difference between the first data and the second data, or based on the result obtained by the encoder.
[0201] For example, the embodiment of the present application can combine two loss functions, so the final loss function is where λ s is a factor used to balance the two loss functions. It can be a loss constructed based on the first data and the second data, The loss can be constructed based on the result obtained by the encoder, as shown in Figure 6. The feature update based on the two losses can be called double self-distillation.
[0202] It should be understood that when multiple concepts need to be corrected or relearned, a corresponding feature representation can be set and updated for each concept that needs to be modified in the above manner, so that an updated feature representation corresponding to each concept can be obtained.
[0203] For example, in the first stage (parallel editing of multiple target concepts and optimization using double self-distillation), the textual prompts of the target concept and the anchor concept can be input to the text encoder respectively. For the textual feature extraction of the target concept, its corresponding representation vector is additionally modified (the modified value is the optimization target). The features of the text encoding related to the target concept and the anchor concept are aligned with the conditional prediction noise, thereby performing double self-distillation. Each target concept is optimized to obtain a new representation vector.
[0204] 505. Update the encoder with minimization of at least one difference including a first difference as an update target, where the first difference is a difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fused feature.
[0205] In the embodiment of the present application, the updated fusion feature can be considered as the better feature that the encoder needs to obtain. Therefore, the encoder can be updated with the goal of obtaining the feature in the intermediate network layer of the encoder. This process is calculated based on an optimization objective with a closed-form solution, and does not require the reconstruction of training samples for model training. In addition, there is no need to update the parameters of the generated model, but only the encoder, thereby reducing the cost of model training.
[0206] In an embodiment of the present application, in the second stage (the process diagram of the first and second stages can be shown in Figure 7), it is assumed that the MLP in the text encoder of the text graph diffusion model is an associative memory, and based on this assumption, the weight matrix of the MLP is optimized, thereby integrating the modification results of each concept obtained in the first stage, calculating the closed-form solution of the weight modification value, and updating the multi-layer weights of the text encoder. The embodiment of the present application can reduce the impact of catastrophic forgetting and can modify a large number of concepts simultaneously on multiple tasks. The embodiment of the present application proposes a unified two-stage method for concept editing of the text graph diffusion model, by independently editing multiple concepts using the "double self-distillation" method in the first stage, and merging the results of the first stage into the modification values of the text encoder weights of the text graph model in the second stage. Compared with existing methods, it is possible to edit the target concept as an anchor concept, and simultaneously complete tasks such as concept forgetting, correction, updating, and bias elimination, and the number of successful edits is greatly improved, for example, the styles of 1,000 artists can be forgotten at the same time.
[0207] In addition, in a possible implementation, the method further includes: obtaining a third input, wherein the third input may be a concept that does not need to be corrected and relearned, and the generative model's ability to understand this part of the concepts should not be affected by those concepts that need to be corrected; in an embodiment of the present application, based on the third input, the encoder can be used to obtain a third feature representation of the target network layer output of the encoder; wherein the at least one difference also includes a second difference, and the second difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
[0208] For example, referring to FIG. 6 , W in FIG. 6 * This is the optimization goal.
[0209] In one possible implementation, the minimizing of at least one difference including the first difference includes: minimizing the fusion result of multiple differences including the first difference. For example, the fusion result is obtained by weighting the multiple differences. The weight used for weighting can be called a balance factor. By introducing a balance factor α∈[0,1) representing the editing strength, it is used to adjust the balance between concept preservation and editing effect in the optimization objective. Based on this weight, the editing strength and the ability to generate non-target concepts can be adjusted, and an editing strength factor is designed in the optimization objective, so that the editing strength of the concept can be flexibly adjusted.
[0210] Next, the beneficial effects of the embodiments of the present application are described in conjunction with experiments:
[0211] The performance of the embodiment of the present application when forgetting up to 1,000 artist styles was evaluated using the artist style elimination test benchmark adopted by UCE, and compared with existing technologies.
[0212] The data used in this example are the UCE artist style test benchmark and COCO-30K text descriptions. The artist style test benchmark tests the effect of removing up to 1,000 artist styles, including the effect of removing them and preserving the styles of 500 artists that are not desired to be removed. COCO-30k consists of 30,000 text descriptions corresponding to images in the COCO dataset, which is used to measure the overall generation quality of the generative model.
[0213] This embodiment directly provides qualitative examples of the effectiveness of artist style removal. To determine the effectiveness of artist style preservation, this embodiment calculates the LPIPS (perceptual metric) and CLIP (clipping) scores of the generated image after and before artist style removal, as well as the generated image and the textual hint used. For the styles of the held-out artists, higher LPIPS (perceptual metric) and CLIP scores indicate better preservation quality.
[0214] To assess the model's overall generative capabilities, this example calculates the FID (Fréchet inception distance) between the generated image and the original image on the COCO-30k Caption dataset, as well as the CLIP (Contrastive Language-Image Pre-Training) score with the corresponding text. A lower FID and a higher CLIP score indicate a better preservation of the model's overall generative capabilities.
[0215] This embodiment of the present application uses simple template-based training text prompts and model-generated anchor concept images as training data. Adam is used for optimization, and a constant learning rate of 5e-4 is used. The optimization of the representation vector for a single concept is completed after 200 steps. Because the task of forgetting artist styles is relatively simple and does not require modifying a large number of model parameters, only the multilayer perceptrons in layers 7-10 of the Stable Diffusion v1.4 text encoder are edited. As shown in Figure 8, this embodiment of the present application successfully forgets 1 to 1,000 artist styles.
[0216] As shown in FIG9A , for different forgetting scales, the embodiment of the present application can successfully forget the artistic style of the artist, and the forgetting effect does not decrease with the increase of the forgetting scale. When forgetting the styles of 1 to 1,000 artists, the embodiment of the present application can well preserve the styles of other artists and has almost no impact on the overall generation ability of the model.
[0217] Furthermore, this embodiment of the present application effectively preserves the model's generative capabilities. EMCID can generate "The Great Wave off Kanagawa" with minimal distortion even after forgetting the styles of 1,000 artists. Furthermore, the quality of the model's generation results on the COCO-30k dataset remains virtually unchanged. In contrast, UCE's generative capabilities begin to decline significantly after forgetting more than 100 artist styles.
[0218] Specifically, the embodiment of the present application uses the designed concept editing test benchmark ICEB (ImageNet Concept Editing Benchmark) to test the performance of the embodiment of the present application in large-scale arbitrary concept editing.
[0219] The data of this embodiment is 3330 test text descriptions (5 for each concept) generated by a language model based on 666 concepts of ImageNet, and 1991 text descriptions (3 for each concept) created based on templates. A large-scale arbitrary concept editing task was designed on this data set. The task requires editing up to 300 target concepts (selected from ImageNet classes) into other anchor concepts (also selected from ImageNet classes). The editing effect on the target concepts was tested, and the preservation effect on the 366 concepts (holdout concepts) was also tested.
[0220] The embodiment of this application designs a variety of indicators to measure the effect of concept editing and preservation. Specifically, there are four indicators: Holdout Delta, which indicates the preservation effect of retained concepts. The higher the value, the better the preservation effect; Target Forget, which indicates the forgetting effect of the original target concept. The higher the value, the better the forgetting effect; Target2Anchor, which indicates the conversion effect of editing the original target concept into the anchor concept. The higher the value, the better the conversion effect; Alias2Anchor, which indicates the effect of converting the alias of the original target concept into the anchor concept. The higher the value, the better the conversion effect. The above indicators are all calculated by obtaining the category prediction probability of ViT-B for the generated image.
[0221] This embodiment of the application uses simple template-based training text prompts and model-generated anchor concept images as training data. It uses Adam for optimization and a constant learning rate of 5e-4. It can complete the optimization of the representation vector for a single concept after 200 steps. The MLP of all Transformer layers except the last layer of the text encoder is modified, and the editing strength α is set to 0.6. As shown in Figure 9B, this embodiment of the application is the only method that can simultaneously guarantee the concept editing effect and the preservation effect of retained concepts after editing 300 concepts.
[0222] As shown in Figure 9C, the experimental results of this embodiment show that the method of can effectively edit the target concept into an anchor concept at different editing scales (from 10 to 300 concepts), and exhibits significantly superior editing effects and image quality preservation capabilities compared to other baseline methods. Especially when the number of edits increases, the method of the embodiment of the present application exhibits more stable performance, demonstrating its efficiency and superiority in handling large-scale arbitrary concept editing tasks. In contrast, after editing up to 100 concepts, at least one of the model's generation capabilities and editing effects will be severely negatively affected by the baseline method.
[0223] In addition, the embodiment of the present application enables the user to adjust the intensity of concept editing when performing arbitrary concept editing. On the one hand, it can flexibly adjust the visual effect, and on the other hand, it can also balance the effects of target concept editing and other concept preservation.
[0224] 10 , which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. As shown in FIG10 , a data processing device provided in an embodiment of the present application, the device 1000 includes:
[0225] An acquisition module 1001 is configured to acquire a first input and a second input;
[0226] For a detailed description of the acquisition module 1001 , reference may be made to the description of step 501 in the above embodiment, which will not be repeated here.
[0227] The processing module 1002 is used to obtain, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder according to the first input and the second input, respectively; fuse the first feature representation and the third feature representation to obtain a fused feature; obtain first data and second data according to the fused feature and the second feature representation, respectively, through a generative model, and update the fused feature according to the difference between the first data and the second data to obtain the updated fused feature; update the encoder with the goal of minimizing at least one difference including a first difference, where the first difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fused feature.
[0228] For a detailed description of the processing module 1002 , reference may be made to the description of steps 502 to 504 in the above embodiment, which will not be repeated here.
[0229] In a possible implementation, the first input and the second input are texts, and the generation model is a text-graph model.
[0230] In a possible implementation, the first input and the second input are different descriptions of the same object; wherein,
[0231] The first input and the second input are different names for the same object; or,
[0232] The second input is a more general description of the same object than the first input; or
[0233] The second input is a more specific description of the same object than the first input.
[0234] In a possible implementation, the generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
[0235] In a possible implementation, the acquisition module is further configured to: acquire a third input;
[0236] The processing module is further used to: obtain, through the encoder, a third feature representation of the target network layer output of the encoder based on the third input; wherein the at least one difference also includes a second difference, and the second difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
[0237] In a possible implementation, minimizing at least one difference including the first difference includes: minimizing a fusion result of multiple differences including the first difference.
[0238] In a possible implementation, the fusion result is obtained by weighting the multiple differences.
[0239] In a possible implementation, the target network layer is the penultimate network layer of the encoder.
[0240] Next, a terminal device provided in an embodiment of the present application is introduced. Please refer to Figure 11. Figure 11 is a structural diagram of a terminal device provided in an embodiment of the present application. The terminal device 1100 can be specifically manifested as a virtual reality VR device, a mobile phone, a tablet, a laptop computer, a smart wearable device, etc., which is not limited here. Specifically, the terminal device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103 and a memory 1104 (wherein the number of processors 1103 in the terminal device 1100 can be one or more, and Figure 11 takes one processor as an example), wherein the processor 1103 may include an application processor 11031 and a communication processor 11032. In some embodiments of the present application, the receiver 1101, the transmitter 1102, the processor 1103 and the memory 1104 may be connected via a bus or other means.
[0241] The memory 1104 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1103. A portion of the memory 1104 may also include non-volatile random access memory (NVRAM). The memory 1104 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.
[0242] Processor 1103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all of these buses are referred to as a bus system in the figure.
[0243] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1103. Processor 1103 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in processor 1103. The above processor 1103 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can 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 1103 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, 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 1104. Processor 1103 reads information from memory 1104 and, in conjunction with its hardware, completes the steps involved in the model training or model inference process in the above method.
[0244] Receiver 1101 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1102 can be used to output digital or character information through the first interface. Transmitter 1102 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1102 can also include a display device such as a display screen.
[0245] The embodiment of the present application also provides a server. Please refer to Figure 12. Figure 12 is a schematic diagram of the structure of the server provided in the embodiment of the present application. The server 1200 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1212 (for example, one or more processors) and a memory 1232, and one or more storage media 1230 (for example, one or more mass storage devices) for storing application programs 1242 or data 1244. Among them, the memory 1232 and the storage medium 1230 can be temporary storage or permanent storage. The program stored in the storage medium 1230 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the central processing unit 1212 can be configured to communicate with the storage medium 1230 to execute a series of instruction operations in the storage medium 1230 on the server 1200.
[0246] The server 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1258; or one or more operating systems 1241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0247] In an embodiment of the present application, the central processing unit 1212 is used to execute actions related to model training or model reasoning in the above embodiments.
[0248] An embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0249] A computer-readable storage medium is also provided in an embodiment of the present application, which stores a program for signal processing. When the computer-readable storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0250] The execution device, training device or terminal device provided in the embodiments of the present application can specifically be a chip, and 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, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0251] Specifically, see Figure 13 , which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip may be a neural network processor (NPU) 1300. NPU 1300 is mounted on a host CPU (host CPU) as a coprocessor, with tasks assigned by the host CPU. The core of the NPU is arithmetic circuit 1303, which is controlled by controller 1304 to extract matrix data from memory and perform multiplication operations.
[0252] In some implementations, the arithmetic circuit 1303 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1303 is a two-dimensional systolic array. The arithmetic circuit 1303 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1303 is a general-purpose matrix processor.
[0253] For example, assume there are input matrix A, weight matrix B, and output matrix C. The computation circuit retrieves the corresponding data of matrix B from weight memory 1302 and caches it on each PE in the computation circuit. The computation circuit then retrieves the data of matrix A from input memory 1301 and performs a matrix operation on it with matrix B. The partial or final matrix result is stored in accumulator 1308.
[0254] Unified memory 1306 is used to store input and output data. Weight data is directly transferred to weight memory 1302 through the Direct Memory Access Controller (DMAC) 1305. Input data is also transferred to unified memory 1306 through the DMAC.
[0255] BIU stands for Bus Interface Unit 1310 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1309 .
[0256] The bus interface unit 1310 (BIU) is used for the instruction fetch memory 1309 to obtain instructions from the external memory, and is also used for the storage unit access controller 1305 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0257] DMAC is mainly used to move input data in the external memory DDR to the unified memory 1306 or to move weight data to the weight memory 1302 or to move input data to the input memory 1301.
[0258] The vector calculation unit 1307 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1303, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0259] In some implementations, the vector calculation unit 1307 can store the processed output vector in the unified memory 1306. For example, the vector calculation unit 1307 can apply a linear function or a nonlinear function to the output of the operation circuit 1303, such as linear interpolation of the feature plane extracted by the convolution layer, or accumulate a vector of values to generate an activation value. In some implementations, the vector calculation unit 1307 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1303, for example, for use in subsequent layers in a neural network.
[0260] An instruction fetch buffer 1309 connected to the controller 1304 is used to store instructions used by the controller 1304;
[0261] Unified memory 1306, input memory 1301, weight memory 1302, and instruction fetch memory 1309 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0262] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0263] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0264] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0265] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0266] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. A data processing method, characterized in that: The method comprises: Get the first input and the second input; Obtaining, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder according to the first input and the second input; Fusing the first feature representation and the third feature representation to obtain a fused feature; Representing the fused feature and the second feature by generating a model to obtain first data and second data respectively, and updating the fused feature according to a difference between the first data and the second data to obtain an updated fused feature; The encoder is updated with the goal of minimizing at least one difference including a first difference, where the first difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fused feature.
2. The method according to claim 1, characterized in that The first input and the second input are texts, and the generation model is a text-to-graph model.
3. The method according to claim 1 or 2, characterized in that The first input and the second input are different descriptions of the same object; wherein, The first input and the second input are different names for the same object; or, The second input is a more general description of the same object than the first input; or The second input is a more specific description of the same object than the first input.
4. The method according to any one of claims 1 to 3, characterized in that: The generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Get the third input; According to the third input, a third feature representation of the target network layer output of the encoder is obtained through the encoder; wherein, The at least one difference also includes a second difference, where the second difference is a difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
6. The method according to any one of claims 1 to 5, characterized in that: The minimizing at least one difference including the first difference comprises: Minimize the fusion result of multiple differences including the first difference.
7. The method according to claim 6, characterized in that The fusion result is obtained by weighting the multiple differences.
8. The method according to any one of claims 1 to 7, characterized in that: The target network layer is the penultimate network layer of the encoder.
9. A data processing device, characterized in that: The device comprises: An acquisition module, configured to acquire a first input and a second input; A processing module is used to obtain, through an encoder, a first feature representation and a second feature representation of a target network layer output of the encoder according to the first input and the second input; fuse the first feature representation and the third feature representation to obtain a fused feature; obtain first data and second data according to the fused feature and the second feature representation through a generative model, and update the fused feature according to the difference between the first data and the second data to obtain the updated fused feature; update the encoder with the goal of minimizing at least one difference including a first difference, where the first difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the first input and the updated fused feature.
10. The device according to claim 9, characterized in that The first input and the second input are texts, and the generation model is a text-to-graph model.
11. The device according to claim 9 or 10, characterized in that The first input and the second input are different descriptions of the same object; wherein, The first input and the second input are different names for the same object; or, The second input is a more general description of the same object than the first input; or The second input is a more specific description of the same object than the first input.
12. The device according to any one of claims 9 to 11, characterized in that The generation model is a diffusion model; the first data and the second data are noises obtained by a noise adding module of the diffusion model, or the first data and the second data are denoising results obtained by a denoising module of the diffusion model.
13. The device according to any one of claims 9 to 12, characterized in that The acquisition module is further configured to: acquire a third input; The processing module is further used to: obtain, through the encoder, a third feature representation of the target network layer output of the encoder based on the third input; wherein the at least one difference also includes a second difference, and the second difference is the difference between the feature representation obtained by the target network layer when the updated encoder processes the third input and the third feature representation.
14. The device according to any one of claims 9 to 13, characterized in that The minimizing at least one difference including the first difference includes: minimizing a fusion result of multiple differences including the first difference.
15. The device according to claim 14, characterized in that The fusion result is obtained by weighting the multiple differences.
16. The device according to any one of claims 9 to 15, characterized in that The target network layer is the penultimate network layer of the encoder.
17. A computer storage medium, characterized in that The computer storage medium stores one or more instructions that, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 8.
18. A computer program product, characterized in that The method comprises computer-readable instructions, which, when executed on a computer device, cause the computer device to execute the method according to 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 configured to execute the code to perform the method according to any one of claims 1 to 8.
20. A chip comprising a processor, characterized in that: The processor is used to support a data processing device to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Data processing method and device
CN116861850A
Image processing method and device, electronic equipment and computer readable storage medium
CN116958320A
Content generation method and device, electronic equipment and storage medium
CN117520587A
Text-conditioned image search based on transformation, aggregation, and composition of visio-linguistic features
US20220245391A1
Cited By
Generative model reasoning using internal image and video generation
US20260179261A1