Data processing method and device

By splitting the confidence matrix into row vector factor and column vector factor and correcting the first-order moment estimation, the problem of memory consumption and convergence speed of adaptive gradient optimization algorithm in large-scale language model training is solved, and more accurate parameters are achieved Updated and faster model convergence.

WO2024230549A1PCT designated stage expired Publication Date: 2024-11-14HUAWEI TECH CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/090538
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-06
Filing Date
2024-04-29
Publication Date
2024-11-14

AI Technical Summary

Technical Problem

Adaptive gradient optimization algorithms lead to increased memory consumption in large-scale language model training, limiting the training of deep neural networks, and existing memory saving optimizers have problems with convergence speed and training results.

Method used

By splitting the confidence matrix into row vector factors and column vector factors for storage, and using these factors to correct first-order moment estimation, more accurate parameter updates are achieved, reducing training results losses and improving model convergence speed.

Benefits of technology

It effectively reduces the loss of training results during parameter update, improves the convergence speed of the model, and reduces storage usage, and is suitable for large-scale language model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024090538_14112024_PF_FP_ABST
    Figure CN2024090538_14112024_PF_FP_ABST
Patent Text Reader

Abstract

A data processing method, applied to the field of artificial intelligence. The method comprises: acquiring first data, the first data being a confidence matrix of a first-order moment estimation corresponding to an update gradient of a target parameter in a neural network; reading second data and third data from a memory cell, the second data corresponding to a row vector factor of the confidence matrix, and the third data corresponding to a column vector factor of the confidence matrix; respectively updating the second data and the third data according to the first data to obtain updated second data and updated third data, the updated second data and the updated third data being fused to obtain fourth data; and adjusting the first-order moment estimation according to the fourth data, and updating the target parameter by using the adjusted first-order moment estimation. According to the present application, the first-order moment estimation is corrected by means of the fourth data, so that a more accurate first-order moment estimation can be obtained, thereby reducing the loss of training results in the parameter update process, and improving the convergence rate of a model.
Need to check novelty before this filing date? Find Prior Art

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 May 6, 2023, with application number 202310511006.4 and invention 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] First-order optimization algorithms are an important component of training deep neural networks and have achieved excellent results in the training of many large-scale language models. Stochastic gradient descent (SGD) updates weights and biases by calculating the gradient of the loss function on small batches of data. Based on the stochastic gradient descent algorithm, a series of adaptive gradient optimization algorithms have been derived. Compared to setting a global learning rate for all dimensions of model parameters in SGD, the adaptive gradient optimization algorithm calculates the corresponding learning rate for each parameter in the model by dividing the gradient by the accumulated value of the square of the past gradients. As the most widely used adaptive gradient algorithm, the Adam optimization algorithm has demonstrated excellent performance in the training of large-scale language models, with faster convergence speed and less hyperparameter adjustment than SGD.

[0005] However, the excellent performance of adaptive gradient optimization algorithms also leads to increased memory consumption during training. For example, Adam requires additional storage of first-order and second-order moment estimates of the gradient, which doubles the memory requirements compared to SGD. As the size of neural networks continues to increase, memory limitations have become a major bottleneck in training large deep neural networks. To reduce the memory consumption of optimization algorithms, the current mainstream approach is to use vectors that occupy less memory space to approximate the matrix used to store second-order moment estimates. For example, Adafactor. For an n*m matrix, the Adafactor optimizer can reduce the memory requirements of the matrix from O(nm) to O(n+m), achieving sublinear memory savings.

[0006] However, compared with the traditional Adam optimizer, Adafactor has problems such as slow convergence speed and loss of training results in large-scale language model training tasks.

[0007] Summary of the Invention

[0008] This application provides a data processing method that can reduce the loss of training results during parameter updating and improve the convergence speed of the model.

[0009] In a first aspect, the present application provides a data processing method, which includes: obtaining first data, which is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network; reading second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix; updating the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data; adjusting the first-order moment estimate according to the fourth data, and using the adjusted first-order moment estimate to update the target parameter.

[0010] Through the above method, on the one hand, the confidence matrix is ​​split into row vector factors and column vector factors for storage, thereby reducing the storage occupancy of the storage unit; on the other hand, the first-order moment estimate is corrected by the fourth data, thereby obtaining a more accurate first-order moment estimate, thereby reducing the loss of training results during the parameter update process and improving the convergence speed of the model.

[0011] In a possible implementation, the method further includes: writing the updated second data and the updated third data into the storage unit.

[0012] In a possible implementation, the confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

[0013] In one possible implementation, obtaining the first data includes: obtaining fifth data and sixth data, where the fifth data and the sixth data are respectively the first-order moment estimate and the second-order moment estimate corresponding to the updated gradient; adjusting the updated gradient according to the sixth data to obtain seventh data; and determining the first data based on the difference between the fifth data and the seventh data.

[0014] In a possible implementation, the difference is specifically a difference value, and the first data is the square of the difference value.

[0015] In one possible implementation, adjusting the first-order moment estimate according to the fourth data and updating the target parameter using the adjusted first-order moment estimate includes updating the target parameter using the following formula:

[0016] in,

[0017] The X t is the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

[0018] In a possible implementation, the storage unit is a memory.

[0019] In a second aspect, the present application provides a data processing device, comprising:

[0020] A processing module, configured to obtain first data, where the first data is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network;

[0021] A read / write module, configured to read second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix;

[0022] The processing module is further configured to update the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data;

[0023] The first-order moment estimate is adjusted according to the fourth data, and the target parameter is updated using the adjusted first-order moment estimate.

[0024] In a possible implementation, the read / write module is further configured to:

[0025] The updated second data and the updated third data are written into the storage unit.

[0026] In a possible implementation, the confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

[0027] In a possible implementation, the processing module is further configured to:

[0028] Acquire fifth data and sixth data, where the fifth data and the sixth data are respectively a first-order moment estimate and a second-order moment estimate corresponding to the updated gradient;

[0029] Adjusting the update gradient according to the sixth data to obtain seventh data;

[0030] The first data is determined according to a difference between the fifth data and the seventh data.

[0031] In a possible implementation, the difference is specifically a difference value, and the first data is the square of the difference value.

[0032] In a possible implementation, the processing module is specifically configured to:

[0033] Update the target parameters using the following formula:

[0034] in,

[0035] The X t is the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

[0036] In a possible implementation, the storage unit is a memory.

[0037] In a third aspect, an embodiment of the present application provides a data processing 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.

[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the above-mentioned first aspect and any optional method thereof.

[0039] In a fifth 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.

[0040] In a sixth aspect, the present application provides a chip system comprising a processor configured to support a data processing device in implementing 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 solely of a chip or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 is a schematic diagram of the structure of the artificial intelligence main framework;

[0042] Figures 2 and 3 are schematic diagrams of the application system framework of the present invention;

[0043] FIG4 is a schematic diagram of an application scenario of the present application;

[0044] FIG5 is a schematic diagram of a system architecture of the present application;

[0045] FIG6 is a schematic diagram of a system architecture of the present application;

[0046] FIG7A is a schematic diagram of a system architecture of the present application;

[0047] FIG7B is a schematic diagram of a system architecture of the present application;

[0048] FIG8 is a flowchart of a data processing method provided in an embodiment of the present application;

[0049] FIG9 is a flowchart of a data processing method provided in an embodiment of the present application;

[0050] FIG10 is a flowchart of a data processing method provided in an embodiment of the present application;

[0051] FIG11 is a schematic structural diagram of a data processing device provided in an embodiment of the present application;

[0052] FIG12 is a schematic diagram of a structure of an execution device provided in an embodiment of the present application;

[0053] FIG13 is a schematic diagram of a structure of a training device provided in an embodiment of the present application;

[0054] FIG14 is a schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] 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.

[0056] 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.

[0057] 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.

[0058] 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.

[0059] First, let's describe the overall workflow of an AI system. See Figure 1, which shows a schematic diagram of the AI ​​framework. This 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.

[0060] (1) Infrastructure

[0061] 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.

[0062] (2) Data

[0063] 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.

[0064] (3) Data processing

[0065] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.

[0066] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.

[0067] 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.

[0068] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.

[0069] (4) General ability

[0070] 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.

[0071] (5) Smart products and industry applications

[0072] 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.

[0073] The embodiment of the present application can be applied to the training process of a neural network model. Next, the application scenario of the neural network in the embodiment of the present application (or the task performed during the inference or feedforward training of the neural network model) is introduced.

[0074] 1. Computer Vision

[0075] The embodiments of the present application can be applied in computer vision-related fields such as driving assistance, autonomous driving, and mobile terminals.

[0076] Taking computer vision as an example, the application system framework of the embodiment of the present application is shown in Figures 2 and 3. The video is extracted by frame to obtain a single picture (or an image collected by other means), and the picture is sent to the neural network model shown in Figure 2 or Figure 3 in the embodiment of the present application to obtain 2D, 3D, Mask (mask), key points and other information of the object of interest in the picture. These detection results are output to the post-processing module for processing, such as being sent to the planning control unit for decision-making in the autonomous driving system, and being sent to the beautification algorithm in the mobile phone terminal for processing to obtain the beautified picture. Several exemplary application scenarios are introduced below.

[0077] Application Scenario 1: ADAS / ADS Visual Perception System

[0078] ADAS and ADS require real-time detection of multiple types of 2D objects, including dynamic obstacles (pedestrians, cyclists, tricycles, cars, trucks, and buses), static obstacles (traffic cones, traffic sticks, fire hydrants, motorcycles, and bicycles), traffic signs (traffic signs, guide signs, billboards, red / yellow / green / black traffic lights, and road signs). Furthermore, to accurately determine the area occupied by dynamic obstacles in 3D space, 3D estimation is required to output a 3D bounding box. To fuse the data with the LiDAR, it is necessary to obtain a mask for dynamic obstacles, thereby filtering out the laser point cloud that hits them. To accurately locate a parking space, it is necessary to simultaneously detect the four key points of the parking space. To perform composition positioning, it is necessary to detect the key points of static targets. The neural network model in the embodiments of this application can perform all or part of the above functions.

[0079] Application scenario 2: mobile phone beauty function

[0080] In a mobile phone, the neural network model in the embodiment of the present application can detect the mask and key points of the human body, and can zoom in and out of the corresponding parts of the human body, such as performing waist-tightening and buttock-beautifying operations, thereby outputting beauty pictures.

[0081] Application scenario 3: Image classification scenario:

[0082] When the number of images is large, manual classification is inefficient, and people are prone to fatigue when dealing with the same thing for a long time, and the classification results will have large errors.

[0083] The neural network model in the embodiments of the present application can classify images to be classified. For example, a photographer may take many photos every day, including animals, people, and plants. Using the method of the present application, photos can be quickly classified according to their content into photos containing animals, photos containing people, and photos containing plants.

[0084] Application scenario 4: Product classification:

[0085] The neural network model in the embodiment of the present application can classify images containing commodities. For a large shopping mall or supermarket with a wide variety of commodities, the neural network model can be used to quickly complete the classification of commodities.

[0086] 2. Information recommendation

[0087] The embodiments of the present application can also be applied to the field of information recommendation, which includes but is not limited to scenarios involving e-commerce product recommendations, search engine result recommendations, application market recommendations, music recommendations, video recommendations, etc. The recommended items in various application scenarios can also be called "objects" to facilitate subsequent descriptions, that is, in different recommendation scenarios, the recommended object can be an APP, or a video, or music, or a certain product (such as the presentation interface of an online shopping platform, which will display different products for presentation according to different users, which can actually be presented through the recommendation results of a recommendation model). These recommendation scenarios usually involve user behavior log collection, log data preprocessing (for example, quantization, sampling, etc.), sample set training to obtain a recommendation model, and analysis and processing of the objects involved in the scenario corresponding to the training sample items (such as APP, music, etc.) according to the recommendation model. For example, the samples selected in the recommendation model training link come from the user's operation behavior on the recommended APP in the mobile application market. The recommendation model trained thereby is applicable to the above-mentioned mobile APP application market, or can be used for the APP application market of other types of terminals to recommend terminal APPs. The recommendation model will ultimately calculate the recommendation probability or score of each object to be recommended. The recommendation system selects the recommendation results based on certain selection rules, such as sorting them by recommendation probability or score, and presents them to users through corresponding applications or terminal devices. Users operate on the objects in the recommendation results to generate user behavior logs, etc.

[0088] Referring to Figure 4, during the recommendation process, when a user interacts with the recommendation system, a recommendation request is triggered. The recommendation system inputs this request and its associated feature information into the deployed recommendation model, which then predicts the user's click-through rate for all candidate items. The candidate items are then sorted in descending order based on the predicted click-through rates and displayed in sequential order at different locations as the recommended results for the user. Users browse the displayed items and perform user actions, such as browsing, clicking, and downloading. These user actions are logged as training data, and the offline training module periodically updates the recommendation model parameters to improve the model's recommendation effectiveness.

[0089] For example, when a user opens a mobile app market, the app market's recommendation module is triggered. This module predicts the user's likelihood of downloading each candidate app based on historical download and click history, app features, and contextual information such as time and location. Based on these predictions, the app market displays apps in descending order of likelihood, increasing the probability of download. Specifically, apps more likely to be downloaded are ranked higher, while apps less likely to be downloaded are ranked lower. User behavior is also logged, and the prediction model parameters are trained and updated through an offline training module.

[0090] For example, in applications related to lifelong companions, based on the user's historical data in video, music, news and other domains, various models and algorithms can be used to imitate the human brain mechanism to build a cognitive brain and establish a user lifelong learning system framework. Lifelong companions can record past events of users based on system data and application data, understand users' current intentions, predict users' future actions or behaviors, and ultimately realize intelligent services. In the current first phase, based on music apps, video apps, browser apps, etc., user behavior data (including end-side text messages, photos, email events, etc.) is obtained. On the one hand, a user portrait system is built, and on the other hand, learning and memory modules based on user information filtering, association analysis, cross-domain recommendations, causal reasoning, etc. are implemented to build a user's personal knowledge graph.

[0091] Application Scenario 5: Natural Language Processing

[0092] Figure 6 shows a natural language processing system, which includes a user device and a data processing device. The user device includes an intelligent terminal such as a mobile phone, personal computer, or information processing center. The user device is the initiator of natural language data processing, serving as the initiator of language question and answer or query requests. Typically, users initiate requests through their user devices.

[0093] The above-mentioned data processing device can be a device or server with data processing functions such as a cloud server, a network server, an application server and a management server. The data processing device receives query statements / voice / text and other questions from the smart terminal through an interactive interface, and then performs machine learning, deep learning, search, reasoning, decision-making and other language data processing through the memory for storing data and the processor link for data processing (for example, data processing is performed through the target neural network in the embodiment of the present application), and feeds back the processing results (such as the data processing results in the embodiment of the present application) to the user device. The memory in the data processing device can be a general term, including local storage and a database for storing historical data. The database can be on the data processing device or on other network servers.

[0094] In the natural language processing system shown in FIG6 , the user device can receive the user's instructions. For example, the user device can receive a paragraph of text input by the user, and then initiate a request to the data processing device so that the data processing device executes a natural language processing application (such as text classification, text reasoning, named entity recognition, translation, etc.) for the paragraph of text obtained by the user device, thereby obtaining the processing result of the corresponding natural language processing application for the paragraph of text (such as classification result, reasoning result, named entity recognition result, translation result, etc.). For example, the user device can receive a paragraph of Chinese input by the user, and then initiate a request to the data processing device so that the data processing device performs entity classification on the paragraph of Chinese, thereby obtaining the entity classification result for the paragraph of Chinese; for example, the user device can receive a paragraph of Chinese input by the user, and then initiate a request to the data processing device so that the data processing device translates the paragraph of Chinese into English, thereby obtaining the English translation for the paragraph of Chinese.

[0095] Figure 7A shows another natural language processing system. In Figure 7A, the user device directly serves as a data processing device. The user device can directly receive input from the user and process it directly by the hardware of the user device itself. The specific process is similar to that of Figure 6. Please refer to the above description and will not be repeated here.

[0096] In the natural language processing system shown in FIG7A , the user device can receive user instructions. For example, the user device can receive a paragraph of text input by the user, and then the user device itself executes a natural language processing application (such as text classification, text reasoning, named entity recognition, translation, etc.) on the paragraph of text, thereby obtaining the processing results of the corresponding natural language processing application for the paragraph of text (such as classification results, reasoning results, named entity recognition results, translation results, etc.). For example, the user device can receive a paragraph of Chinese input by the user and perform entity classification on the paragraph of Chinese, thereby obtaining an entity classification result for the paragraph of Chinese; for example, the user device can receive a paragraph of Chinese input by the user and translate the paragraph of Chinese into English, thereby obtaining an English translation of the paragraph of Chinese.

[0097] The steps related to the model reasoning process in the embodiment of the present application involve AI-related operations. The system architecture provided in the embodiment of the present application is introduced in detail below in conjunction with Figure 5.

[0098] FIG5 is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in FIG5 , 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 .

[0099] 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.

[0100] The data acquisition device 560 is used to collect training samples. The training samples can be image data, text data, video data, etc. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.

[0101] The training device 520 can train the neural network to be trained (such as the neural network model in the embodiment of the present application) based on the training samples maintained in the database 530 to obtain the target model / rule 501.

[0102] 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.

[0103] 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.

[0104] 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 FIG5 . 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.

[0105] Specifically, the training device 520 may transfer the trained model to the execution device 510 .

[0106] In Figure 5, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with external devices. The user can input data (such as images in the embodiment of the present application) to the I / O interface 512 through the client device 540.

[0107] 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.

[0108] 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.

[0109] Finally, the I / O interface 512 provides the processed results to the client device 540 and thus to the user.

[0110] In the scenario shown in FIG5 , 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 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 from I / O interface 512 as new sample data in database 530.

[0111] It is worth noting that FIG5 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 FIG5 , 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.

[0112] From the inference side of the model:

[0113] 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.

[0114] 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.

[0115] 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.

[0116] 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.

[0117] From the training side of the model:

[0118] 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 5, 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.

[0119] 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.

[0120] 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.

[0121] In addition, the embodiments of the present application can also be applied to the architecture of federated learning.

[0122] Referring to FIG7B , FIG7B is a schematic diagram of the architecture of a model training method provided in an embodiment of the present application. As shown in FIG7B , the architecture provided in an embodiment of the present application includes: a cloud-side central node, which can be, for example, a cloud-side server. A1, A2, ... are distributed nodes of type A (referred to as terminals in this application), such as mobile phone products held by users. B1, B2, ... are distributed nodes of type B, such as personal computers held by users. After obtaining the consent of the administrator of the distributed node (such as the user of a mobile phone or computer), the administrator of the distributed node voluntarily shares the data generated during the daily use of the device while protecting privacy, adds it to the model training plan, and the device becomes a distributed node in the architecture. The system in this embodiment can also include more types of distributed nodes, such as smart watches, etc. To protect data privacy, the distributed nodes will not upload data to the central node, but only save data locally. The distributed nodes are connected to the cloud server via a communication network. The cloud-side central node can run large models, while each distributed node can only run small models due to hardware capabilities, and A and B can have different model training capabilities.

[0123] At the beginning of training, the server sends an initial model to each client. Each client then iterates the model using local data and feeds back the model changes (i.e., the gradients corresponding to the parameters) to the server. The server then takes a weighted average of the feedback gradients, uses the resulting average gradient to update the initial model, and sends the updated model to each client, restarting the next iteration.

[0124] 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.

[0125] (1) Neural Network

[0126] 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:

[0127] 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.

[0128] (2) Deep Neural Networks

[0129] 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 subscript corresponds to the output of the third layer index 2 and the input of the second layer index 4. In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as 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).

[0130] (3) Backpropagation algorithm

[0131] Convolutional neural networks can use the back propagation (BP) algorithm to correct the size of the parameters in the initial super-resolution model during training, reducing the reconstruction error loss of the super-resolution model. Specifically, the forward propagation of the input signal to the output generates an error loss. This error loss information is then backpropagated to update the parameters of the initial super-resolution model, thereby converging the error loss. The BP algorithm is a backward propagation movement dominated by the error loss, aiming to obtain the optimal super-resolution model parameters, such as the weight matrix.

[0132] (4) Loss function

[0133] 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, there is usually an initialization process before the first update, which is to pre-configure 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 as much as possible.

[0134] The following is a Chinese-English translation of some technical concepts involved in this application:

[0135] 1. First-order Optimization

[0136] 2. Stochastic Gradient Descent (SGD): Stochastic Gradient Descent

[0137] 3. Adaptive Gradient Optimization

[0138] 4. Hyper-parameters

[0139] 5. First Moment Estimation: First-order moment estimation

[0140] 6. Second Moment Estimation: Second-order moment estimation

[0141] 7. Neural Machine Translation (NMT): Statistical Machine Translation

[0142] 8. Natural Language Processing (NLP): Natural Language Processing

[0143] 9. Neural Network

[0144] 10. Deep Neural Network

[0145] 11. Deep Learning

[0146] 12. Non-negative Matrix Factorization

[0147] 13. Exponential Moving Average (EMA): Exponential Moving Average

[0148] 14. Raw Update: Raw Update

[0149] 15. Generalized Kullback-Leibler Divergence: Generalized KL divergence

[0150] 16. Confidence-based Adaptive Update: Confidence-based adaptive update

[0151] 17. Low-rank Matrix: Low-rank matrix

[0152] 18. Row Vector Factor: Row Vector Factor

[0153] 19. Column Vector Factor: Column Vector Factor

[0154] 20. Loss Function

[0155] 21. Large-scale Language Model

[0156] 22. Large-batch Training

[0157] 23. Memory-efficient Optimizer: Memory-saving optimizer

[0158] First-order optimization algorithms are an essential component of training deep neural networks and have achieved outstanding results in training numerous large-scale language models. Stochastic gradient descent (SGD) updates weights and biases using the gradient of the loss function calculated on small batches of data. Building on the stochastic gradient descent algorithm, a series of adaptive gradient optimization algorithms have been developed. Compared to SGD, which sets a global learning rate for all dimensions of model parameters, adaptive gradient optimization algorithms calculate the corresponding learning rate for each parameter in the model by dividing the gradient by the accumulated value of the square of past gradients. As the most widely used adaptive gradient algorithm, the Adam optimization algorithm has demonstrated outstanding performance in training large-scale language models, with faster convergence and less hyperparameter tuning than SGD.

[0159] However, the excellent performance of adaptive gradient optimization algorithms also comes at the cost of increased memory consumption during training. For example, Adam requires additional storage of first- and second-order moment estimates of the gradient, doubling its memory requirements compared to SGD. As neural networks continue to grow in size, memory limitations have become a major bottleneck in training large deep neural networks. To reduce the memory consumption of optimization algorithms, the current mainstream approach is to approximate the matrix used to store second-order moment estimates using vectors that occupy less memory space. Adafactor is a memory-efficient optimizer based on non-negative matrix factorization. This optimizer tracks the moving averages of the rows and columns of the squared gradient accumulator matrix and uses non-negative matrix factorization to reconstruct a low-rank approximation of the exponential smoothing accumulator. It also uses the generalized KL divergence as a loss function to ensure that the approximation is optimal relative to the generalized KL divergence. For an n*m matrix, the Adafactor optimizer can reduce the memory requirement from O(nm) to O(n+m), achieving sub-linear memory savings.

[0160] However, compared with the traditional Adam optimizer, Adafactor has problems such as slow convergence speed and loss of training results in large-scale language model training tasks.

[0161] 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.

[0162] Referring to Figure 8, Figure 8 is a flow chart of a data processing method provided in an embodiment of the present application. As shown in Figure 8, a data processing method provided in an embodiment of the present application may include steps 801 to 804, and these steps are described in detail below.

[0163] 801. Obtain first data, where the first data is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network.

[0164] In one possible implementation, the updated gradient of the target parameter can be obtained.

[0165] For example, the training device can calculate the update gradients of multiple parameters (including the update gradients of the target parameters) by the results obtained from the feedforward process of the neural network.

[0166] For example, in a federated training scenario, the training device can receive gradient information (including updated gradients of target parameters) uploaded from the client side. In other words, the feedforward process and gradient calculation can be performed by the client side.

[0167] Among them, the training samples in the model feedforward process can be image data, text data, video data or target data related to the recommendation field. The target data can be the user's attribute information, the item's attribute information and information related to the recommendation scenario. For example, it can be information related to the user's operation bias, such as information about the recommendation interface, the recommended location of the item, etc., which will affect the user's operation behavior.

[0168] In an embodiment of the present application, the execution entity of step 801 may be a terminal device, which may be a portable mobile device, such as but not limited to a mobile or portable computing device (such as a smart phone), a personal computer, a server computer, a handheld device (such as a tablet) or a laptop device, a multi-processor system, a game console or controller, a microprocessor-based system, a set-top box, a programmable consumer electronic product, a mobile phone, a mobile computing and / or communication device with a wearable or accessory form factor (such as a watch, glasses, a headset or earbuds), a network PC, a minicomputer, a mainframe computer, a distributed computing environment including any of the above systems or devices, and the like.

[0169] In the embodiment of the present application, the execution entity of step 801 may be a server on the cloud side.

[0170] For the convenience of description, the following does not distinguish the form of the execution subject and describes them all as training devices.

[0171] In one possible implementation, the neural network model can implement computer vision-related tasks such as object detection, image classification, image segmentation, etc.

[0172] In one possible implementation, the neural network model can be a recommendation model, and the tasks implemented by the recommendation model can be a variety of the following tasks: purchase behavior prediction, shopping cart behavior prediction, sharing behavior prediction, browsing behavior prediction, completion rate prediction, like prediction, collection prediction, click prediction, and click conversion prediction.

[0173] In a possible implementation, when training a recommendation model, it is necessary to obtain training samples. Taking the recommendation model as an example, the training samples may include attribute information of users and items, and the attribute information may be user operation data.

[0174] Among them, the user's operation data can be obtained based on the interaction records between the user and the items (such as the user's behavior log). The operation data may include the user's actual operation records on each item. The operation data may include the user's attribute information, the attribute information of each item, and the operation type of the user's operation on the multiple items (such as click, download, etc.).

[0175] Among them, the user's attribute information can be attributes related to the user's preference characteristics, at least one of gender, age, occupation, income, hobbies and education level, among which gender can be male or female, age can be a number between 0-100, occupation can be teacher, programmer, chef, etc., hobbies can be basketball, tennis, running, etc., and education level can be elementary school, junior high school, high school, university, etc.; this application does not limit the specific type of user attribute information.

[0176] Among them, the items can be physical items or virtual items, such as applications (APP), audio and video, web pages, and news information. The attribute information of the items can be at least one of the item name, developer, installation package size, category, and praise. Among them, taking the item as an application as an example, the category of the item can be chat, parkour games, office, etc., and the praise degree can be a score, comment, etc. for the item; this application does not limit the specific type of attribute information of the item.

[0177] In a possible implementation, the training device may determine a confidence matrix of a first-order moment estimate corresponding to the updated gradient of the target parameter based on the updated gradient of the target parameter.

[0178] In a possible implementation, the confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

[0179] Next, we will introduce how to calculate the confidence matrix of the first-order moment estimate:

[0180] In one possible implementation, fifth data and sixth data may be obtained, where the fifth data and the sixth data are respectively the first-order moment estimate and the second-order moment estimate (or may be referred to as an approximate matrix of the second-order moment estimate) corresponding to the update gradient; the update gradient is adjusted according to the sixth data to obtain seventh data (or may be referred to as the current original update); and the first data is determined based on the difference between the fifth data and the seventh data.

[0181] In this case, the second-order gradient row vector factor and the second-order gradient column vector factor corresponding to the historical (e.g., most recent) second-order moment estimate can be first obtained from the storage device, and the second-order gradient row vector factor and the second-order gradient column vector factor corresponding to the second-order moment estimate can be updated using the updated gradient corresponding to the target parameter to obtain the second-order gradient row vector factor and the second-order gradient column vector factor corresponding to the updated gradient. An outer product operation is performed on the first-order moment estimate of the second-order gradient matrix row vector factor and the first-order moment estimate of the second-order gradient matrix column vector factor to obtain an approximate matrix of the second-order moment estimate (i.e., sixth data). The approximate matrix of the second-order moment estimate can be used to update the updated gradient corresponding to the target parameter (e.g., the updated gradient corresponding to the target parameter can be divided by the root of the approximate matrix of the second-order moment estimate) to obtain seventh data (or can be referred to as the current original update). The historical (e.g., most recent) first-order moment estimate can be obtained, updated using the seventh data, and then the historical (e.g., most recent) first-order moment estimate can be used to obtain the first-order moment estimate of the updated gradient corresponding to the target parameter (i.e., fifth data). The difference between the fifth data and the seventh data can be used to determine the first data (i.e., the confidence matrix).

[0182] In a possible implementation, the difference is specifically a difference value, and the first data is the square of the difference value.

[0183] Specifically, the above process may include:

[0184] 1) Second-Order Gradient Matrix Factorization: The second-order gradient matrix is ​​approximated using non-negative matrix factorization to obtain the original update. To improve memory efficiency, two vectors are typically used as matrix factorization factors. The decomposed second-order gradient row vector factors and second-order gradient column vector factors store the sum of each row and column of the matrix, respectively, and are used to update the first-order moment estimates of the second-order gradient row vector factors and the second-order gradient column vector factors.

[0185] 2) Calculate the confidence matrix: Perform the outer product operation on the first-order moment estimates of the row vector factors of the second-order gradient matrix saved in 1) and the first-order moment estimates of the column vector factors of the second-order gradient matrix to obtain an approximate matrix of the second-order moment estimates. The current raw update is calculated using the first-order gradients and the approximate matrix of the second-order moment estimates. After obtaining the raw update, perform the residual operation and square operation on it with the first-order moment estimates of the raw update to obtain the confidence matrix of the current raw update.

[0186] 802. Read second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix.

[0187] 803. Update the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data.

[0188] In a possible implementation, the storage unit is a memory.

[0189] Similar to the second-order moment estimation, in the embodiment of the present application, the confidence matrix can be decomposed during initialization, and the confidence matrix row vector factors and the confidence matrix column vector factors can be used to approximate the confidence matrix (non-negative matrix), thereby updating the first-order moment estimation of the confidence matrix row vector factors and the first-order moment estimation of the confidence matrix column vector factors.

[0190] Specifically, the second data and the third data can be read from the storage unit; the second data corresponds to the row vector factor of the confidence matrix, and the third data corresponds to the column vector factor of the confidence matrix. That is to say, the confidence matrix can be split into row vector factors and column vector factors for storage, so as to reduce the storage occupancy of the storage unit (specifically, in terms of memory occupancy, similar to the Adafactor optimization algorithm, for a matrix of size n*m, the embodiment of the present application can reduce the memory requirement of the matrix from O(nm) to O(n+m)). In each iteration of the training process, the row vector factors and column vector factors of the confidence matrix updated historically (for example, the most recent time) can be obtained from the storage unit, and the current confidence matrix can be used to update the row vector factors and column vector factors to obtain the updated row vector factors and the updated column vector factors. Similar to the processing method of the second-order moment estimation, the updated row vector factors and the updated column vector factors can be fused (for example, performing an outer product operation) to obtain an approximation of the confidence matrix (that is, the fourth data in the embodiment of the present application).

[0191] Compared with the prior art, the embodiment of the present application introduces a confidence-based adaptive update: based on the original update, the embodiment of the present application uses the fitting matrix of the confidence matrix calculated by the confidence matrix row vector factor and the confidence matrix column vector factor as the denominator to perform a dot product operation, thereby obtaining a revised confidence-based adaptive update matrix.

[0192] In combination with the Adafactor optimizer, the embodiment of the present application can propose a confidence-based adaptive update strategy to correct each update of the optimizer based on the characteristics of the Adafactor optimizer itself (low-rank approximation is performed by non-negative matrix decomposition, that is, the matrix is ​​approximately represented by row vector factors and column vector factors, but each step of the model update often has errors compared to optimizers such as Adam). In the confidence adaptive update strategy, the residual between the original update of each step of the optimizer and its first-order moment estimate is calculated as the confidence matrix of the original update, and the row vector factors and column vector factors of the confidence matrix are updated accordingly.

[0193] 804. Adjust the first-order moment estimate according to the fourth data, and update the target parameter using the adjusted first-order moment estimate.

[0194] In an embodiment of the present application, on the one hand, the confidence matrix is ​​split into row vector factors and column vector factors for storage, thereby reducing the storage occupancy of the storage unit; on the other hand, the first-order moment estimate is corrected by the fourth data, thereby obtaining a more accurate first-order moment estimate, thereby reducing the loss of training results during the parameter update process and improving the convergence speed of the model.

[0195] In a possible implementation, the target parameter may be updated using the following formula:

[0196] in,

[0197] The X t is the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

[0198] In a possible implementation, the updated second data and the updated third data may be written to the storage unit so as to be acquired and used in a subsequent model training iteration process.

[0199] Existing memory-saving optimizers have problems such as slow convergence speed and attenuated model performance after training in the training of large-scale language models. At the same time, there are some obstacles in the application of large-scale training scenarios. The embodiment of the present application proposes a memory-saving optimizer based on the original update confidence. During the model training process, the optimizer calculates the confidence of the original update of the model parameters at each step, and performs adaptive corrections based on the original updates, thereby achieving the effect of accelerated convergence, while ensuring the stability of the training and the generalization ability of the model itself. Due to the ability to adaptively adjust the original update of the model at each step, the embodiment of the application also has excellent application effects in large-scale training scenarios.

[0200] The embodiment of the present application provides a data processing method, which includes: obtaining first data, which is a confidence matrix of the first-order moment estimate corresponding to the updated gradient of the target parameter in the neural network; reading second data and third data from a storage unit; the second data corresponds to the row vector factor of the confidence matrix, and the third data corresponds to the column vector factor of the confidence matrix; updating the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data; adjusting the first-order moment estimate according to the fourth data, and using the adjusted first-order moment estimate to update the target parameter. Through the above method, on the one hand, the confidence matrix is ​​split into row vector factors and column vector factors for storage, thereby reducing the storage occupancy of the storage unit; on the other hand, the first-order moment estimate is corrected by the fourth data, thereby obtaining a more accurate first-order moment estimate, thereby reducing the loss of training results during parameter update and improving the convergence speed of the model.

[0201] Next, an embodiment of a memory optimization algorithm is introduced.

[0202] In this embodiment, the input of the memory optimization algorithm includes the initial parameters X of the training model t , learning rate Smoothing parameters β1, β2, β3 and regularization constants ∈1, ∈2. At the same time, initialize the original update first-order moment estimate m0, the second-order gradient matrix row vector factor first-order moment estimate RV0, the second-order gradient matrix column vector factor first-order moment estimate CV0, the confidence matrix row vector factor first-order moment estimate RC0 and the confidence matrix column vector factor first-order moment estimate CC0. First, obtain the gradient matrix G of the current loss function t , using the second-order gradient matrix Update RV t and CV t As shown in Figure 9, RV t for The first moment estimate of the sum of each row of elements in , CV t for The first moment estimate of the sum of the elements in each column.

[0203] In this embodiment, as shown in FIG10 , based on the updated RV t and CV t , the second-order gradient approximation matrix can be calculated Combined with the first-order gradient matrix G t This can be obtained similar to the original update U in the Adafactor optimizer t , used to update the original updated first-order moment estimate m t . Get the updated m t , the required confidence matrix C can be effectively calculated t , which is the square of the residual between the current raw update and the corresponding first-order moment estimate.

[0204] In order to reduce the memory usage of the optimizer, similar to the second-order gradient matrix decomposition, the present invention uses the confidence matrix C t Update the confidence matrix row vector factor first-order moment estimate RC t and the confidence matrix column vector factor first-order moment estimate CC t As shown in Figure 8, after the first-order moment estimates of the two decomposition factors are updated, the confidence approximation matrix can be obtained.

[0205] Finally, the optimization algorithm can iteratively update the parameters of the model. It should be noted that the above process introduces the concept of confidence matrix compared to the Adafactor optimizer, and additionally saves the first-order moment estimate RC of the confidence matrix row vector factor t and the confidence matrix column vector factor first-order moment estimate CC t , but there is no significant difference in memory usage.

[0206] 11 , which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. As shown in FIG11 , a data processing device 1100 provided in an embodiment of the present application includes:

[0207] Processing module 1101 is used to obtain first data, where the first data is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network;

[0208] The reading and writing module 1102 is configured to read second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix;

[0209] The specific description of the read-write module 1102 can refer to the description of step 802 in the above embodiment, which will not be repeated here.

[0210] The processing module 1101 is further configured to update the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data;

[0211] The first-order moment estimate is adjusted according to the fourth data, and the target parameter is updated using the adjusted first-order moment estimate.

[0212] The specific description of the processing module 1101 can refer to the description of step 801, step 803 and step 804 in the above embodiment, which will not be repeated here.

[0213] In a possible implementation, the read / write module 1102 is further configured to:

[0214] The updated second data and the updated third data are written into the storage unit.

[0215] In a possible implementation, the confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

[0216] In a possible implementation, the processing module 1101 is further configured to:

[0217] Acquire fifth data and sixth data, where the fifth data and the sixth data are respectively a first-order moment estimate and a second-order moment estimate corresponding to the updated gradient;

[0218] Adjusting the update gradient according to the sixth data to obtain seventh data;

[0219] The first data is determined according to a difference between the fifth data and the seventh data.

[0220] In a possible implementation, the difference is specifically a difference value, and the first data is the square of the difference value.

[0221] In a possible implementation, the processing module 1101 is specifically configured to:

[0222] Update the target parameters using the following formula:

[0223] in,

[0224] The X tis the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

[0225] In a possible implementation, the storage unit is a memory.

[0226] Next, an execution device provided in an embodiment of the present application is introduced. Please refer to Figure 12. Figure 12 is a structural schematic diagram of an execution device provided in an embodiment of the present application. The execution device 1200 can be specifically manifested as a virtual reality VR device, a mobile phone, a tablet, a laptop computer, a smart wearable device, a monitoring data processing device or a server, etc., which is not limited here. Specifically, the execution device 1200 includes: a receiver 1201, a transmitter 1202, a processor 1203 and a memory 1204 (wherein the number of processors 1203 in the execution device 1200 can be one or more, and Figure 12 takes one processor as an example), wherein the processor 1203 may include an application processor 12031 and a communication processor 12032. In some embodiments of the present application, the receiver 1201, the transmitter 1202, the processor 1203 and the memory 1204 may be connected via a bus or other means.

[0227] Memory 1204 may include read-only memory and random access memory, and provides instructions and data to processor 1203. A portion of memory 1204 may also include non-volatile random access memory (NVRAM). Memory 1204 stores processor and operation instructions, executable modules, or data structures, or subsets or extensions thereof. The operation instructions may include various operation instructions for implementing various operations.

[0228] Processor 1203 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 bus systems are referred to as a bus system in the figure.

[0229] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1203. Processor 1203 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 1203. The above processor 1203 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 1203 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 1204. Processor 1203 reads information from memory 1204 and, in conjunction with its hardware, completes the steps involved in the model inference process in the above method.

[0230] Receiver 1201 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1202 can be used to output digital or character information through the first interface. Transmitter 1202 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1202 can also include a display device such as a display screen.

[0231] The present application also provides a training device. Please refer to FIG. 13 , which is a schematic diagram of the structure of a training device provided by an embodiment of the present application. Specifically, the training device 1300 is implemented by one or more servers. The training device 1300 may vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1313 (e.g., one or more processors), a memory 1332, and one or more storage media 1330 (e.g., one or more mass storage devices) storing application programs 1342 or data 1344. The memory 1332 and storage medium 1330 may be either ephemeral or persistent storage. The program stored in the storage medium 1330 may include one or more modules (not shown), each module including a series of instruction operations on the training device. Furthermore, the CPU 1313 may be configured to communicate with the storage medium 1330 to execute the series of instruction operations in the storage medium 1330 on the training device 1300.

[0232] The training device 1300 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input and output interfaces 1358; or, one or more operating systems 1341, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0233] In the embodiment of the present application, the central processing unit 1313 is used to execute actions related to model training in the above embodiment.

[0234] 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.

[0235] 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.

[0236] 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.

[0237] Specifically, see Figure 14 , 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) 1400. NPU 1400 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 1403, which is controlled by controller 1404 to extract matrix data from memory and perform multiplication operations.

[0238] In some implementations, the arithmetic circuit 1403 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1403 is a two-dimensional systolic array. The arithmetic circuit 1403 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 1403 is a general-purpose matrix processor.

[0239] For example, assume there are input matrix A, weight matrix B, and output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from weight memory 1402 and caches it on each PE in the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1401 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1408.

[0240] Unified memory 1406 is used to store input and output data. Weight data is directly transferred to weight memory 1402 through the Direct Memory Access Controller (DMAC) 1405. Input data is also transferred to unified memory 1406 through the DMAC.

[0241] BIU stands for Bus Interface Unit, i.e., bus interface unit 1410 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1409 .

[0242] The bus interface unit 1410 (BIU) is used for the instruction fetch memory 1409 to obtain instructions from the external memory, and is also used for the storage unit access controller 1405 to obtain the original data of the input matrix A or the weight matrix B from the external memory.

[0243] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1406 or transfer weight data to the weight memory 1402 or transfer input data to the input memory 1401.

[0244] The vector calculation unit 1407 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1403, 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.

[0245] In some implementations, the vector calculation unit 1407 can store the processed output vector to the unified memory 1406. For example, the vector calculation unit 1407 can apply a linear function or a nonlinear function to the output of the operation circuit 1403, 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 1407 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 1403, for example, for use in subsequent layers in a neural network.

[0246] An instruction fetch buffer 1409 connected to the controller 1404 is used to store instructions used by the controller 1404;

[0247] Unified memory 1406, input memory 1401, weight memory 1402, and instruction fetch memory 1409 are all on-chip memories. External memories are private to the NPU hardware architecture.

[0248] 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.

[0249] 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.

[0250] 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.

[0251] 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.

[0252] 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: Acquire first data, where the first data is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network; Reading second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix; updating the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data; The first-order moment estimate is adjusted according to the fourth data, and the target parameter is updated using the adjusted first-order moment estimate.

2. The method according to claim 1, characterized in that The method further comprises: The updated second data and the updated third data are written into the storage unit.

3. The method according to claim 1 or 2, characterized in that: The confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

4. The method according to any one of claims 1 to 3, characterized in that: The obtaining of the first data includes: Acquire fifth data and sixth data, where the fifth data and the sixth data are respectively a first-order moment estimate and a second-order moment estimate corresponding to the updated gradient; Adjust the update gradient according to the sixth data to obtain seventh data; The first data is determined according to a difference between the fifth data and the seventh data.

5. The method according to claim 4, characterized in that The difference is specifically a difference value, and the first data is a square of the difference value.

6. The method according to any one of claims 1 to 5, characterized in that: The adjusting the first-order moment estimate according to the fourth data, and updating the target parameter using the adjusted first-order moment estimate, comprises: The target parameters are updated by the following formula: in, The X t is the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

7. The method according to any one of claims 1 to 6, characterized in that: The storage unit is a memory.

8. A data processing device, characterized in that: The device comprises: A processing module, configured to obtain first data, wherein the first data is a confidence matrix of a first-order moment estimate corresponding to an updated gradient of a target parameter in a neural network; A read / write module, configured to read second data and third data from a storage unit; the second data corresponds to a row vector factor of the confidence matrix, and the third data corresponds to a column vector factor of the confidence matrix; The processing module is further used to update the second data and the third data respectively according to the first data to obtain updated second data and updated third data; the updated second data and the updated third data are used to fuse to obtain fourth data; The first-order moment estimate is adjusted according to the fourth data, and the target parameter is updated using the adjusted first-order moment estimate.

9. The device according to claim 8, characterized in that The read-write module is also used for: The updated second data and the updated third data are written into the storage unit.

10. The device according to claim 8 or 9, characterized in that The confidence matrix is ​​used to represent the difference between an adjustment result of adjusting the update gradient according to the second-order moment estimate corresponding to the update gradient and a first-order moment estimate corresponding to the update gradient.

11. The device according to any one of claims 8 to 10, characterized in that: The processing module is further used for: Acquire fifth data and sixth data, where the fifth data and the sixth data are respectively a first-order moment estimate and a second-order moment estimate corresponding to the updated gradient; Adjust the update gradient according to the sixth data to obtain seventh data; The first data is determined according to a difference between the fifth data and the seventh data.

12. The device according to claim 11, characterized in that The difference is specifically a difference value, and the first data is a square of the difference value.

13. The device according to any one of claims 8 to 12, characterized in that: The processing module is specifically used for: The target parameters are updated by the following formula: in, The X t is the target parameter, the η t is the preset parameter, the m t is the first-order moment estimate, the is the fourth data.

14. The device according to any one of claims 8 to 13, characterized in that The storage unit is a memory.

15. A computer storage medium, characterized in that The computer storage medium stores one or more instructions which, when executed by one or more computers, cause the one or more computers to perform the operations of the method of any one of claims 1 to 7.

16. A computer program product, characterized in that The method comprises computer-readable instructions, and when the computer-readable instructions are executed on a computer device, the computer device is caused to execute the method according to any one of claims 1 to 7.

17. 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 7.

Citation Information

Patent Citations

  • Neural network model training method and device, computer equipment and storage medium

    CN112183750A

  • Adam algorithm acceleration system and method

    CN115034373A

  • Data processing method and device

    CN117556917A

  • Training neural networks using learned optimizers

    US20220391706A1