Data processing method and related device

By carrying compression rate information in the propt for feature representation compression, the input length limitation problem of large basic models when processing long sequences is solved, achieving more efficient long sequence processing capabilities and more flexible text input adaptability.

WO2024245343A1PCT designated stage expired Publication Date: 2024-12-05HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/096349
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-06-01
Filing Date
2024-05-30
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

Large basic models have input length limitations when processing long sequence information, and cannot effectively process long sequence data common in reality, such as papers, books and long conversation history information.

Method used

By carrying compression rate information in the prompt prompt propt, the feature representation is compressed, more accurate reply text is generated, and the large language model can adapt to longer input sequences, realizing infinite-length text input processing.

Benefits of technology

It improves the long sequence processing capability of large models, supports dynamic-length text compression, controls training and inference time and memory consumption, and avoids retraining. Large models can adapt to longer inputs without retraining.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024096349_05122024_PF_FP_ABST
    Figure CN2024096349_05122024_PF_FP_ABST
Patent Text Reader

Abstract

A data processing method, which relates to the field of artificial intelligence. The method comprises: acquiring a first feature representation and a second feature representation, wherein the first feature representation is obtained after feature extraction is performed on first text, the second feature representation is obtained after feature extraction is performed on a prompt, and the prompt instructs to perform compression according to a target compression rate; compressing the first feature representation and the second feature representation at the target compression rate, so as to obtain a compressed feature representation; and obtaining second text according to the compressed feature representation and by means of a large language model, wherein the second text is used as reply text of the first text. In the present application, a compression rate is carried in a prompt, such that apriority of compression information can be provided for a large model, and thus the large model can generate more accurate reply text when there is a loss in an input.
Need to check novelty before this filing date? Find Prior Art

Description

A data processing method and related equipment

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on June 1, 2023, with application number 202310646933.7 and invention name “A data processing method and related equipment”, 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 related equipment. Background Art

[0003] Artificial intelligence (AI) refers to the theories, methods, technologies, 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] Since the release of ChatGPT, the capabilities and future potential of large-scale foundational models, such as large language models (LLMs), have garnered widespread attention. Large models often have limitations on input length. For example, ChatGPT can only process a maximum of 4,096 tokens, and GPT-4 can only process a maximum of 30,000 tokens. However, in reality, there is a vast amount of long sequence information, such as papers, books, multi-documents, long meeting messages, and long code snippets. Furthermore, when large models communicate with users, they also involve processing long conversation histories.

[0005] Therefore, we continue with a method that can improve the long sequence processing ability of large models.

[0006] Summary of the Invention

[0007] This application provides a data processing method that can improve the long sequence processing capability of large models.

[0008] In a first aspect, the present application provides a data processing method, comprising: obtaining a first feature representation and a second feature representation; the first feature representation is obtained after feature extraction of a first text, and the second feature representation is obtained after feature extraction of a prompt, wherein the prompt indicates compression according to a target compression rate; compressing the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation; obtaining a second text based on the compressed feature representation through a large language model; the second text is used as a reply text to the first text.

[0009] First, carrying the compression ratio in the prompt can provide a priori information about compression to the large model, allowing it to generate more accurate response text when there is input loss.

[0010] Second, this solution allows large language models that have already set a maximum length and completed pre-training to adapt to continued pre-training, fine-tuning, and inference on longer input sequences without retraining;

[0011] Third, it can theoretically support unlimited text input and support dynamic text compression to accommodate user input of varying lengths.

[0012] Fourth, arbitrary-length input can be mapped to a fixed-length input, and the theoretical inference latency can be controlled within the complexity of O(1). This allows for good control over the training and inference time and memory consumption for long sequences.

[0013] In one possible implementation, the large language model is used to perform a target task, which is one of the following: reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, text automatic question answering, text intent recognition, text classification, text simplification, and text story generation.

[0014] In a possible implementation, the compression method includes: a mean pooling operation, or compression based on a text encoder.

[0015] The reason for defining the compression ratio in the prompt is, on the one hand, because the compressed feature representation has a certain amount of information loss in size and content compared to the uncompressed feature representation. Therefore, carrying the compression ratio in the prompt can provide a priori information about the compression to the large model, allowing the large model to generate more accurate response text when there is input loss. On the other hand, when the compression method is compression through a neural network (which can be simply called a compression model), carrying the compression ratio in the prompt can also provide a priori information about the compression to the compression model, allowing the compression model to retain more effective information in the compressed feature representation.

[0016] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

[0017] The compression method may be pooling mean or compression based on a neural network.

[0018] Similarly, the compression method that carries compression in the prompt can provide the large model with richer compression information prior, so that the large model can generate more accurate reply text when there is input loss.

[0019] In one possible implementation, compressing the first feature representation and the second feature representation to the target compression rate includes: dividing the first feature representation and the second feature representation to obtain multiple sub-feature representations; and compressing each sub-feature representation of the multiple sub-feature representations to the target compression rate.

[0020] In a possible implementation, the method further includes: determining the target compression rate based on a relationship between a length of the first text and a maximum text length supported by the large language model for input.

[0021] In one possible implementation, the compression method is compression based on a text encoder; the compressing the first feature representation and the second feature representation to the target compression rate includes: encoding the first feature representation and the second feature representation through the text encoder to obtain an encoding result; using part of the encoding result as the compressed feature representation, and the part of the encoding result is the encoding result of extracting the proportion of the target compression rate in the encoding result.

[0022] In a possible implementation, obtaining the second text according to the compressed feature representation through a large language model includes: obtaining the second text according to the compressed feature representation and the second feature representation through a large language model.

[0023] In one possible implementation, obtaining the second text according to the compressed feature representation through a large language model includes: obtaining, according to the compressed feature representation, through a large language model, a feature representation of a hidden layer output of the large language model; and obtaining the second text according to the feature representation of the hidden layer output through a text decoder.

[0024] In a second aspect, the present application provides a data processing method, the method comprising:

[0025] Obtaining a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio;

[0026] compressing the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0027] Obtaining a second text through a large language model based on the compressed feature representation;

[0028] The large language model is updated according to the second text and the corresponding true value.

[0029] In one possible implementation, the large language model is used to perform a target task, which is one of the following:

[0030] Reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, text automatic question answering, text intent recognition, text classification, text simplification, and text story generation.

[0031] In a possible implementation, the compression method includes:

[0032] Mean pooling operation, or compression based on text encoder.

[0033] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

[0034] In a possible implementation, compressing the first feature representation and the second feature representation to the target compression rate includes:

[0035] Splitting the first feature representation and the second feature representation to obtain multiple sub-feature representations;

[0036] Compress each of the plurality of sub-feature representations at the target compression rate.

[0037] In a possible implementation, the compression method is compression based on a text encoder; and the processing module is further configured to:

[0038] Obtaining predicted values ​​of the first text and the prompt through a text decoder according to the compressed feature representation;

[0039] The text encoder is updated according to the first text, the prompt and the predicted value.

[0040] In one possible implementation, the method further includes:

[0041] The target compression rate is determined according to a relationship between the length of the first text and a maximum text length supported by the large language model.

[0042] In a possible implementation, the compression method is compression based on a text encoder;

[0043] The compressing the first feature representation and the second feature representation to the target compression rate includes:

[0044] Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result;

[0045] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

[0046] In a possible implementation, obtaining the second text based on the compressed feature representation using a large language model includes:

[0047] A second text is obtained based on the compressed feature representation and the second feature representation through a large language model.

[0048] In a possible implementation, obtaining the second text based on the compressed feature representation using a large language model includes:

[0049] Obtaining, through a large language model, a feature representation of a hidden layer output of the large language model according to the compressed feature representation;

[0050] The second text is obtained through a text decoder according to the feature representation of the hidden layer output.

[0051] In a third aspect, the present application provides a data processing device, comprising:

[0052] an acquisition module, configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio;

[0053] a processing module, configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0054] A second text is obtained based on the compressed feature representation through a large language model; the second text is used as a reply text to the first text.

[0055] In a possible implementation, the compression method includes:

[0056] Mean pooling operation, or compression based on text encoder.

[0057] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

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

[0059] Splitting the first feature representation and the second feature representation to obtain multiple sub-feature representations;

[0060] Compress each of the plurality of sub-feature representations at the target compression rate.

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

[0062] The target compression rate is determined according to a relationship between the length of the first text and a maximum text length supported by the large language model.

[0063] In a possible implementation, the compression method is compression based on a text encoder;

[0064] The processing module is specifically used to:

[0065] Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result;

[0066] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

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

[0068] A second text is obtained based on the compressed feature representation and the second feature representation through a large language model.

[0069] In a fourth aspect, the present application provides a data processing device, comprising:

[0070] an acquisition module, configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio;

[0071] a processing module, configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0072] Obtaining a second text through a large language model based on the compressed feature representation;

[0073] The large language model is updated according to the second text and the corresponding true value.

[0074] In one possible implementation, the large language model is used to perform a target task, which is one of the following:

[0075] Reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, text automatic question answering, text intent recognition, text classification, text simplification, and text story generation.

[0076] In a possible implementation, the compression method includes:

[0077] Mean pooling operation, or compression based on text encoder.

[0078] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

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

[0080] Splitting the first feature representation and the second feature representation to obtain multiple sub-feature representations;

[0081] Compress each of the plurality of sub-feature representations at the target compression rate.

[0082] In a possible implementation, the compression method is compression based on a text encoder; and the processing module is further configured to:

[0083] Obtaining predicted values ​​of the first text and the prompt through a text decoder according to the compressed feature representation;

[0084] The text encoder is updated according to the first text, the prompt and the predicted value.

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

[0086] The target compression rate is determined according to a relationship between the length of the first text and a maximum text length supported by the large language model.

[0087] In a possible implementation, the compression method is compression based on a text encoder;

[0088] The processing module is specifically used to:

[0089] Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result;

[0090] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

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

[0092] A second text is obtained based on the compressed feature representation and the second feature representation through a large language model.

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

[0094] Obtaining, through a large language model, a feature representation of a hidden layer output of the large language model according to the compressed feature representation;

[0095] The second text is obtained through a text decoder according to the feature representation of the hidden layer output.

[0096] In a fifth aspect, an embodiment of the present application provides an execution device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to execute the first aspect and any optional method thereof.

[0097] In a sixth aspect, an embodiment of the present application provides a training device, which may include a memory, a processor, and a bus system, wherein the memory is used to store programs, and the processor is used to execute the programs in the memory to perform the second aspect and any optional method thereof.

[0098] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer-readable storage medium is run on a computer, it enables the computer to execute the above-mentioned first aspect and any optional method thereof, or the above-mentioned second aspect and any optional method thereof.

[0099] In an eighth 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, or the above-mentioned second aspect and any optional method thereof.

[0100] In a ninth aspect, the present application provides a chip system comprising a processor for supporting an execution device or a training device in implementing the functions described in the aforementioned aspects, such as transmitting or processing data or information involved in the aforementioned methods. In one possible design, the chip system further comprises a memory for storing program instructions and data necessary for the execution device or the training device. The chip system may consist of a single chip or may include a chip and other discrete components. BRIEF DESCRIPTION OF THE DRAWINGS

[0101] FIG1A is a schematic diagram of a structure of an artificial intelligence main framework;

[0102] FIG1B is a schematic diagram of the functional architecture of a natural language synthesis application in an embodiment of the present application;

[0103] FIG1C is a schematic diagram of the physical architecture for running a natural language synthesis application in an embodiment of the present application;

[0104] FIG1D is a schematic diagram showing an optional hardware structure of the terminal 100;

[0105] Figure 2 is a natural language processing system;

[0106] Figure 3 shows another natural language processing system;

[0107] FIG4 is a schematic diagram of a natural language processing device according to an embodiment of the present application;

[0108] FIG5 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0109] FIG6 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0110] FIG7 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0111] FIG8 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0112] FIG9A is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0113] FIG9B is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0114] FIG9C is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0115] FIG9D is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0116] FIG9E is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

[0117] FIG9F is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application;

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

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

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

[0121] FIG13 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

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

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

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

[0125] First, let's describe the overall workflow of an AI system. See Figure 1A, which shows a schematic diagram of the main AI framework. This AI framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.

[0126] (1) Infrastructure

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

[0128] (2) Data

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

[0130] (3) Data processing

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

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

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

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

[0135] (4) General ability

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

[0137] (5) Smart products and industry applications

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

[0139] This application can be applied to the field of natural language processing in the field of artificial intelligence. Taking natural language processing as an example, the following will introduce multiple application scenarios that have been implemented in products.

[0140] First, we will introduce the application scenarios of this application. This application can be applied to, but is not limited to, applications with natural language synthesis functions (hereinafter referred to as natural language synthesis applications) or cloud services provided by cloud-side servers. The following are introduced respectively:

[0141] 1. Natural Language Synthesis Applications

[0142] The product form of the embodiment of the present application can be a natural language synthesis application. The natural language synthesis application can be run on a terminal device or a cloud-side server.

[0143] Natural language generation (NLG), also known as text prediction or natural language synthesis, refers to the task of generating missing or subsequent text in a given text.

[0144] This application can be applied to natural language synthesis in long sequence scenarios. The so-called long sequence scenario can be understood as a scenario where the length of the text input to the model (or the model output) is very long. For example, specific long sequence scenarios include long text summaries, long text question and answer, multi-document summaries and question and answer, conference summaries and question and answer, multi-round dialogues, multi-round teaching question and answer, multi-round code generation, video summaries, mathematical proof verification and error correction, etc., where the input of the model can involve very long sequences such as books, long papers, long videos, automatic speech recognition in conferences, multiple code files, multiple documents, high-definition pictures, and long mathematical proofs.

[0145] In one possible implementation, a user can open a natural language synthesis application installed on a terminal device and input text data (the text may be triggered by an instruction and not necessarily actively input by the user). The natural language synthesis application can process the text using a model trained by the method provided in the embodiment of the present application, or using the method provided in the embodiment of the present application, and present the processing results to the user (the presentation method may be, but is not limited to, display, playback, saving, uploading to the cloud, etc.).

[0146] In one possible implementation, a user can open a natural language synthesis application installed on a terminal device and input text data. The natural language synthesis application can send the text data to a cloud-side server. The cloud-side server processes the text using a model trained using the method provided in an embodiment of the present application, and transmits the processing results back to the terminal device. The terminal device can present the processing results to the user (the presentation method can be, but is not limited to, display, playback, saving, uploading to the cloud side, etc.).

[0147] Next, the natural language synthesis application in the embodiment of this application is introduced from the functional architecture and the product architecture that implements the function.

[0148] Referring to FIG. 1B , FIG. 1B is a schematic diagram of the functional architecture of a natural language synthesis application in an embodiment of the present application:

[0149] In one possible implementation, as shown in FIG1B , a natural language synthesis application 102 may receive input parameters 101 (e.g., including text) and generate processing results 103. The natural language synthesis application 102 may be executed on (for example) at least one computer system and include computer code that, when executed by one or more computers, causes the computers to execute a model trained using the method provided in the embodiments of the present application.

[0150] Referring to FIG. 1C , FIG. 1C is a schematic diagram of the physical architecture for running a natural language synthesis application in an embodiment of the present application:

[0151] Referring to FIG1C , FIG1C shows a schematic diagram of a system architecture. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( FIG1C illustrates one server as an example), and the server 200 may provide a natural language synthesis function for one or more terminals.

[0152] Among them, a natural language synthesis application can be installed on the terminal 100, or a web page related to the natural language synthesis function can be opened. The above application and web page can provide an interface. The terminal 100 can receive the relevant parameters entered by the user on the natural language synthesis function interface and send the above parameters to the server 200. The server 200 can obtain the processing results based on the received parameters and return the processing results to the terminal 100.

[0153] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters by itself without the need for the cooperation of the server, and the embodiments of the present application are not limited to this.

[0154] Next, the product form of the terminal 100 in FIG1C is described;

[0155] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.

[0156] FIG1D shows a schematic diagram of an optional hardware structure of the terminal 100 .

[0157] 1D , terminal 100 may include components such as a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a processor 170, an external interface 180, and a power supply 190. Those skilled in the art will appreciate that FIG1D is merely an example of a terminal or multi-function device and does not limit the terminal or multi-function device. The terminal or multi-function device may include more or fewer components than shown, or may combine certain components or have different components.

[0158] The input unit 130 can be used to receive input digital or character information and generate key signal input related to user settings and function control of the portable multifunction device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can detect user touch operations on or near it (for example, operations performed on or near the touch screen using a finger, joint, stylus, or any other suitable object) and drive corresponding connected devices according to pre-set programs. The touch screen can detect user touch actions on the touch screen, convert the touch actions into touch signals and transmit them to the processor 170. It can also receive and execute commands sent by the processor 170; the touch signals include at least touch point coordinate information. The touch screen 131 provides an input interface and an output interface between the terminal 100 and the user. Touch screens can be implemented using various types, including resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch screen 131, the input unit 130 may also include other input devices. Specifically, the other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0159] Among them, other input devices 132 can receive input image data or text data.

[0160] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In an embodiment of the present application, the display unit 140 may be used to display the interface of a natural language synthesis application, processing results, etc.

[0161] Memory 120 can be used to store instructions and data. It primarily includes an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files and text. The instruction storage area can store software units such as the operating system, applications, and instructions required for at least one function, or subsets or extensions thereof. It may also include non-volatile random access memory (RAM). It provides processor 170 with management functions for the hardware, software, and data resources within the computing and processing device, supporting control software and applications. It is also used to store multimedia files and running programs and applications.

[0162] The processor 170 is the control center of the terminal 100. It connects all components of the terminal 100 using various interfaces and circuits. By executing instructions stored in the memory 120 and accessing data stored therein, it executes various functions of the terminal 100 and processes data, thereby providing overall control of the terminal device. Optionally, the processor 170 may include one or more processing units. Preferably, the processor 170 may integrate an application processor and a modem processor, with the application processor primarily processing the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory may be implemented on a single chip; in other embodiments, they may be implemented on separate chips. The processor 170 may also generate corresponding operational control signals and send them to the corresponding components of the computing and processing device. It may also read and process data in the software, particularly the data and programs in the memory 120, to enable the various functional modules therein to perform their corresponding functions, thereby controlling the corresponding components to operate as instructed.

[0163] Among them, the memory 120 can be used to store software codes related to the data processing method, the processor 170 can execute the steps of the chip's data processing method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.

[0164] The RF unit 110 (optional) can be used to send and receive information or receive and send signals during a call. For example, after receiving downlink information from the base station, it is passed to the processor 170 for processing; in addition, it sends the designed uplink data to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF unit 110 can also communicate with network devices and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0165] In this embodiment of the present application, the RF unit 110 can send image data or text data to the server 200 and receive a processing result sent by the server 200.

[0166] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.

[0167] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.

[0168] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to other devices for communication, or to connect a charger to charge the terminal 100 .

[0169] Although not shown, the terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied to the terminal 100 shown in FIG1D .

[0170] Next, the product form of the server 200 in FIG1C is described;

[0171] FIG2 provides a schematic diagram of the structure of a server 200. As shown in FIG2, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0172] Bus 201 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, FIG2 shows only one thick line, but this does not imply that there is only one bus or only one type of bus.

[0173] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0174] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard drive (HDD), or solid state drive (SSD).

[0175] The memory 204 may be used to store software codes related to the data processing method, and the processor 202 may execute the steps of the data processing method of the chip, and may also schedule other units to implement corresponding functions.

[0176] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0177] It should be understood that the steps related to the model reasoning process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and server is not limited to the processor-memory architecture described above. The system architecture provided in the embodiments of this application is described in detail below with reference to Figure 3.

[0178] FIG3 is a schematic diagram of the system architecture provided by an embodiment of the present application. As shown in FIG3 , the system architecture 500 includes an execution device 510 , a training device 520 , a database 530 , a client device 540 , a data storage system 550 , and a data acquisition system 560 .

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

[0180] The execution device 510 may be a terminal device or a server that runs the above-mentioned natural language synthesis application.

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

[0182] 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 (such as a text encoder, diffusion model, etc.)) based on the training samples maintained in the database 530 to obtain the target model / rule 501.

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

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

[0185] The target model / rule 501 obtained through training with the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in FIG3 . The execution device 510 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR) device, an in-vehicle terminal, etc., or a server, etc.

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

[0187] In Figure 3, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with an external device. The user can input data (such as image data or text data in the embodiment of the present application) into the I / O interface 512 through the client device 540.

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

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

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

[0191] In the scenario shown in FIG3 , the user can manually input data, and this "manual input data" can be operated through the interface provided by I / O interface 512. In another scenario, client device 540 can automatically send input data to I / O interface 512. If user authorization is required for client device 540 to automatically send input data, the user can set the corresponding permissions in client device 540. The user can view the results output by execution device 510 on client device 540, and the specific presentation form can be a display, sound, action, or other specific method. Client device 540 can also serve as a data acquisition terminal, collecting input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data, and storing them in database 530. Of course, collection can also be performed without client device 540, and instead the I / O interface 512 directly stores the input data input into I / O interface 512 and output results output from I / O interface 512 as new sample data in database 530.

[0192] It is worth noting that FIG3 is merely a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationships between the devices, components, modules, etc. shown in the figure do not constitute any limitation. For example, in FIG3 , the data storage system 550 is an external memory relative to the execution device 510. In other cases, the data storage system 550 can also be placed in the execution device 510. It should be understood that the execution device 510 can be deployed in the client device 540.

[0193] From the inference side of the model:

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

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

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

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

[0198] From the training side of the model:

[0199] In an embodiment of the present application, the above-mentioned training device 520 can obtain the code stored in the memory (not shown in Figure 3, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in the embodiment of the present application.

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

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

[0202] 2. Natural language synthesis cloud services provided by the server:

[0203] In a possible implementation, the server may provide a natural language synthesis service to the terminal side through an application programming interface (API).

[0204] Among them, the terminal device can send relevant parameters (such as text and other data) to the server through the API provided by the cloud. The server can obtain processing results based on the received parameters, etc., and return the processing results to the terminal.

[0205] The description of the terminal and the server can be the same as that of the above embodiments, and will not be repeated here.

[0206] FIG4 shows a process of using a natural language synthesis cloud service provided by a cloud platform.

[0207] 1. Activate and purchase content review services.

[0208] 2. Users can download the software development kit (SDK) corresponding to the content review service. Usually, the cloud platform provides multiple development versions of the SDK for users to choose according to the requirements of the development environment, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.

[0209] 3. After downloading the corresponding version of the SDK locally as needed, the user imports the SDK project into the local development environment, configures and debugs it, and can also develop other functions in the local development environment, forming an application that integrates natural language synthesis capabilities.

[0210] 4. When using a natural language synthesis application, if natural language synthesis is needed, it can trigger an API call for this function. When the application triggers the natural language synthesis function, it initiates an API request to a running instance of the natural language synthesis service in the cloud environment. The API request includes text, which is then processed by the running instance in the cloud environment to obtain the result.

[0211] 5. The cloud environment returns the processing results to the application, thus completing a natural language synthesis function call.

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

[0213] (1) Neural Network

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

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

[0216] (2) Transformer layer

[0217] The neural network includes an embedding layer and at least one transformer layer, and the at least one transformer layer can be N transformer layers (N is an integer greater than 0), wherein each transformer layer includes an attention layer, an add&norm layer, a feed forward layer, and an add&norm layer that are adjacent in sequence. In the embedding layer, the current input is embedded to obtain multiple embedding vectors; in the attention layer, P input vectors are obtained from the previous layer of the first transformer layer, and with any first input vector among the P input vectors as the center, based on the correlation between each input vector within a preset attention window and the first input vector, the intermediate vector corresponding to the first input vector is obtained, thereby determining the P intermediate vectors corresponding to the P input vectors; in the pooling layer, the P intermediate vectors are merged into Q output vectors, wherein the multiple output vectors obtained by the last transformer layer in the transformer layer are used as feature representations of the current input.

[0218] (3) Attention mechanism

[0219] The attention mechanism mimics the internal process of biological observation behavior, namely, a mechanism that aligns internal experience and external sensations to increase the observation precision of certain areas. It can quickly filter out high-value information from a large amount of information using limited attention resources. The attention mechanism can quickly extract important features from sparse data and is therefore widely used in natural language processing tasks, especially machine translation. The self-attention mechanism is an improvement on the attention mechanism, which reduces dependence on external information and is better at capturing the internal correlation of data or features. The essential idea of ​​the attention mechanism can be rewritten as the following formula:

[0220] Here, Lx = ||Source|| represents the length of the Source. This formula implies that the elements in the Source are imagined to consist of a series of data pairs. Given a Query element in the target, the similarity or correlation between the Query and each Key is calculated to obtain the weight coefficient for each Key's corresponding Value. The weighted sum of the Values ​​is then taken to obtain the final Attention value. Essentially, the Attention mechanism performs a weighted sum of the Values ​​of the Source elements, with the Query and Key used to calculate the weight coefficient for the corresponding Value. Conceptually, Attention can be understood as selectively filtering out a small amount of important information from a large amount of information and focusing on this important information, while ignoring the majority of less important information. This focusing process is reflected in the calculation of the weight coefficients: the larger the weight, the more focus is placed on the corresponding Value. In other words, the weight represents the importance of the information, while the Value represents the corresponding information. The self-attention mechanism can be understood as internal attention. The attention mechanism occurs between the Query element of the Target and all elements of the Source. The self-attention mechanism refers to the attention mechanism that occurs between the internal elements of the Source or the internal elements of the Target. It can also be understood as the attention calculation mechanism in the special case of Target = Source. The specific calculation process is the same, only the calculation object has changed.

[0221] (4) Natural language processing (NLP)

[0222] Natural language refers to human language, and natural language processing (NLP) is the processing of human language. Natural language processing is the process of systematically analyzing, understanding, and extracting information from text data in an intelligent and efficient manner. By using NLP and its components, we can manage very large amounts of text data, perform a large number of automated tasks, and solve a wide variety of problems, such as automatic summarization, machine translation (MT), named entity recognition (NER), relation extraction (RE), information extraction (IE), sentiment analysis, speech recognition, question answering, and topic segmentation.

[0223] (5) Backpropagation algorithm

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

[0225] (6) Loss function

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

[0227] (7) Pre-trained language model

[0228] A pretrained language model is a natural language sequence encoder that encodes each word in a natural language sequence into a vector representation for prediction. Its training consists of two phases. In the pre-training phase, the model is trained on a large amount of unsupervised text for language modeling tasks, thereby learning a word representation. In the fine-tuning phase, the model is initialized using the parameters learned in the pre-training phase and trained in a relatively short number of steps on downstream tasks such as text classification and sequence labeling. This allows the semantic information gained from pre-training to be successfully transferred to downstream tasks.

[0229] It should be understood that the above architecture can also be applied to other natural language processing tasks, such as natural language synthesis, semantic understanding, summary generation, etc.

[0230] (8)Average Pooling

[0231] Average pooling is the process of using the average value of all representations in a representation set as the representation of the representation set in the forward propagation of the model.

[0232] Since the release of ChatGPT, the capabilities and future potential of large-scale foundational models, such as large language models (LLMs), have garnered widespread attention. Large models often have limitations on input length. For example, ChatGPT can only process a maximum of 4,096 tokens, and GPT-4 can only process a maximum of 30,000 tokens. However, in reality, there is a vast amount of long sequence information, such as papers, books, multi-documents, long meeting messages, and long code snippets. Furthermore, when large models communicate with users, they also involve processing long conversation histories.

[0233] Therefore, we continue with a method that can improve the long sequence processing ability of large models.

[0234] First, the data processing method provided in the embodiment of the present application is explained by taking the model training stage as an example.

[0235] Referring to FIG5 , FIG5 is a schematic diagram of an embodiment of a data processing method provided in an embodiment of the present application. The data processing method provided in an embodiment of the present application can be applied to terminal devices such as mobile phones, tablets, laptops, smart wearable devices, and can also be applied to servers. As shown in FIG5 , the data processing method provided in an embodiment of the present application includes:

[0236] 501. Obtain a first feature representation and a second feature representation; the first feature representation is obtained after feature extraction of the first text, and the second feature representation is obtained after feature extraction of a prompt, wherein the prompt indicates compression according to a target compression ratio.

[0237] In one possible implementation, the first text may be a training sample for a large language model, wherein the training sample may include the first text and a true value corresponding to the first text, the first text may be obtained based on a source corpus, and the true value corresponding to the first text may be obtained based on a target corpus, and the large language model needs to predict and generate a target corpus based on the source corpus.

[0238] For example, the first text you can write is: "Please generate a summary of the following text: "XXXX"".

[0239] The first text may be a long sequence text. For example, the first text may include book content, long papers, long videos, multiple code files, multiple documents, high-definition pictures, long mathematical proofs, multi-round dialogue content, etc.

[0240] In one possible implementation, a large language model can be used to implement sequence conversion tasks between different language types, such as text translation tasks, summary generation tasks between different languages, etc., in which case the first text and the truth value corresponding to the first text can be texts of different language types (it is not limited to each data unit in the first text being of a different language type from the data unit in the truth value corresponding to the first text; for example, some data units in the first text and the data units (part or all data units) in the truth value corresponding to the first text are of the same language type). The language type can also be referred to as a language.

[0241] For example, in a Chinese-English translation task, the original text is "This trip requires careful planning", and its parallel English text is "The trip needs careful planning". Then "This trip requires careful planning" and "The trip needs careful planning" can be regarded as a set of parallel corpora. This set of parallel corpora is a Chinese-English parallel language pair. The original text "This trip requires careful planning" can be regarded as the source corpus of this set of parallel corpora, and the translated text "The trip needs careful planning" can be regarded as the target corpus of this set of parallel corpora.

[0242] For example, in an English-German translation task, the original text is "We danse on the grass" and its parallel German text is "Wir tanzen auf dem gras". Then "We danse on the grass" and "Wir tanzen auf dem gras" can be regarded as a set of parallel corpora, which is an English-German parallel language pair. The original text "We danse on the grass" can be regarded as the source corpus of this set of parallel corpora, and the translated text "Wir tanzen auf dem gras" can be regarded as the target corpus of this set of parallel corpora.

[0243] In a possible implementation, a large language model can be used to implement a text summary generation task, where the source corpus can be the source corpus from which a summary needs to be extracted, and the target corpus can be the summary text to be generated.

[0244] In one possible implementation, a large language model can be used to implement a text reply task, in which case the source corpus can be the source corpus that needs a reply, and the target corpus can be the reply content for the source corpus.

[0245] Alternatively, the original source corpus and the original target corpus can be obtained from an external database.

[0246] In one possible implementation, feature extraction can be performed on the first text to obtain a first feature representation. The first feature representation can be obtained by extracting features from the first text using an embedding layer of a large language model, or by extracting features from the first text using an embedding layer in a text encoder (the text encoder will be described in subsequent embodiments).

[0247] Optionally, the embedding layer can obtain a token embedding, a position embedding, and a segment embedding (text embedding is optional) for each data unit of the first text.

[0248] In one possible implementation, the embedding layer may include an input embedding layer and a positional encoding layer. In the input embedding layer, word embedding processing may be performed on each data unit in the unmasked data units in the current input, thereby obtaining a word vector (e.g., which may represent semantic information) for each data unit in the unmasked data units. In the positional encoding layer, the position of each data unit in the unmasked data units in the current input may be obtained, thereby generating a position vector for the position of each data unit in the unmasked data units.

[0249] In some examples, the position information of each data unit in the unmasked data units in the data sequence can be the absolute position of each data unit in the unmasked data units in the data sequence. Taking the current input of "Which number should I repay Huabei" as an example, the position of "how many" can be represented as the first digit, the position of "number" can be represented as the second digit, and so on. In some examples, the position of each data unit in the unmasked data units in the data sequence can be the relative position of each data unit in the unmasked data units in the data sequence. Still taking the current input of "Which number should I repay Huabei" as an example, the position of "how many" can be represented as before "number", the position of "number" can be represented as after "how many" and before "should", and so on. When the word vector and position vector of each data unit in the unmasked data units in the current input are obtained, the position vector and the corresponding word vector of each data unit in the unmasked data units can be fused to obtain the embedding vector of each data unit in the unmasked data units. It should be understood that the fusion method can be to add the position vector and the corresponding word vector, or through other operations, and the specific fusion method is not limited here. The embedding vector can be represented as an embedding matrix with a preset dimension. The number of embedding vectors can be set to M and the preset dimension is H, so the embedding vector can be represented as an M×H embedding matrix.

[0250] When the first text is a long sequence, especially when it exceeds the maximum input length supported by the large language model, it is necessary to compress the feature representation of the first text so that the compressed feature representation can fall within the processing range of the large language model.

[0251] In a possible implementation, in addition to the first text, a prompt may be obtained, which may indicate to perform compression according to a target compression ratio, wherein the compression ratio may be the ratio of the size of the data after compression to the size before compression.

[0252] The reason for defining the compression ratio in the prompt is, on the one hand, because the compressed feature representation has a certain amount of information loss in size and content compared to the uncompressed feature representation. Therefore, carrying the compression ratio in the prompt can provide a priori information about the compression to the large model, allowing the large model to generate more accurate response text when there is input loss. On the other hand, when the compression method is compression through a neural network (which can be simply called a compression model), carrying the compression ratio in the prompt can also provide a priori information about the compression to the compression model, allowing the compression model to retain more effective information in the compressed feature representation.

[0253] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

[0254] The compression method may be pooling mean or compression based on a neural network.

[0255] Similarly, the compression method that carries compression in the prompt can provide the large model with richer compression information prior, so that the large model can generate more accurate reply text when there is input loss.

[0256] For example, the prompt can be: "This is a representation sequence compressed to 20% of its length by the average pooling method. Please answer based on its original text: ". For another example, the prompt can be: "This is a representation sequence compressed to 20% of its length by the average pooling method. Please reconstruct the original text: ".

[0257] Next, we will describe how to determine the target compression ratio.

[0258] In one possible implementation, the target compression ratio may be user-specified or system-determined based on the relationship between the first text and the maximum input length supported by the large language model. For example, the target compression ratio may be determined based on the ratio (X / Y) between the maximum input length X supported by the large language model and the length Y of the first text. The target compression ratio may be less than or equal to the ratio (X / Y).

[0259] It should be understood that the prompt carrying the compressed information can be information input by the user or automatically generated by the system, and this application does not limit this.

[0260] It should be understood that long sequences may also contain prompts related to specific tasks, which may lead to a nested relationship between the two layers of prompts. Because the prompt representing the task is more important, when the prompt is short, a parallel approach can be adopted, that is, the prompt related to the task and the prompt representing the compression ratio are placed together.

[0261] Example 1: (Nested mode): "This is a representation sequence compressed to 20% of its length by the average pooling method. Please answer based on its original text: [Please generate a summary of less than 100 words based on the following:]";

[0262] Example 2: (Parallel mode): "Please generate a summary of less than 100 words based on the following representation sequence compressed to 20% of its length by the average pooling method: "

[0263] 502. Compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0264] In a possible implementation, the first feature representation and the second feature representation may be compressed to the target compression rate through a mean pooling operation to obtain a compressed feature representation.

[0265] Refer to Figure 6, which shows a schematic diagram of feature representation compression and large model generation based on Average Pooling, as well as the inference process. In one possible implementation, the input text or other type of sequence can be converted into token IDs, and a representation of the original sequence can be generated through an embedding layer. This representation sequence is divided into blocks according to a certain window size. The representation sequence of each small block is averaged to form the representation vector of the small block. These average representation vectors are then concatenated in sequence to form the compressed representation vector of the original sequence.

[0266] In a possible implementation, the first feature representation and the second feature representation may be compressed at the target compression rate based on a text encoder to obtain a compressed feature representation.

[0267] In one possible implementation, the compression method is compression based on a text encoder (or it can be called a compression model); the first feature representation and the second feature representation can be encoded by the text encoder to obtain an encoding result; part of the encoding result is used as the compressed feature representation, and the part of the encoding result is the encoding result of extracting the proportion of the target compression rate in the encoding result.

[0268] For example, if the target compression ratio is 0.3, 30 percent of the feature representations in the encoding result can be used as the compressed feature representations. For example, the first 30 percent of the feature representations can be used as the compressed feature representations.

[0269] Referring to Figure 7, Figure 7 is a schematic diagram of the compression and large model generation of the feature representation of the compression model and the reasoning process. In one possible implementation, the compression model can adopt a compression model pre-trained with an autoencoder structure, and the compression model can compress the original long text into a shorter representation sequence. Optionally, when the input sequence is too long or there are multiple documents, the sequence can be split (or can be described as segmented) and compressed separately. That is, in one possible implementation, the first feature representation and the second feature representation can be segmented to obtain multiple sub-feature representations; each of the multiple sub-feature representations is compressed to the target compression rate.

[0270] After compressing each sub-feature representation at the target compression rate, multiple compressed sub-feature representations can be obtained. The multiple compressed sub-feature representations can be fused (eg, concat) to obtain a compressed feature representation.

[0271] In one possible implementation, the compression method is compression based on a text encoder; when training the text encoder, the first text and the predicted value of the prompt can be obtained through a text decoder based on the compressed feature representation (for example, part of the feature representation obtained by the text encoder is taken, and the other part can be masked); and the text encoder is updated based on the first text, the prompt and the predicted value.

[0272] Among them, the first text and the prompt are equivalent to the true value, so the loss can be determined based on the difference between the predicted value and the true value, and the text encoder can be updated according to the loss. Of course, the text decoder can also be updated. When the text decoder is a pre-trained decoder, the text decoder may not be updated.

[0273] Through the above training of the compression model, the text decoder can accurately obtain the original text based on the compressed feature representation obtained by the text encoder. Moreover, only when the compressed feature representation obtained by the text encoder carries rich information (that is, the compression process does not lose much effective information) can the text decoder still restore the original sequence based on the compressed feature representation. Therefore, the above training process can enable the text encoder to have the ability to compress without losing much effective information, which in turn allows the subsequent large language model to obtain more accurate response text.

[0274] It should be understood that the above-mentioned training process of the compression model can be performed before the training process of the large language model (that is, the compression used in step 502 is a pre-trained model and does not need to be updated during the training process of the large language model), or it can be end-to-end trained together with the large language model (that is, the compression model also needs to be updated during the training process of the large language model). This application is not limited to this.

[0275] For example, the training method of the compression model can be the following schematic process:

[0276] Referring to Figure 8, Figure 8 is a schematic diagram of the processing flow in which both the Encoder and Decoder ends are BERT structures. As shown in Figure 8, a prompt based on compression rate information (such as the target compression rate in the embodiment of the present application) can be constructed, which can be represented by text; the information and the input text (such as the first text in the embodiment of the present application) are spliced, and the token ids of the input overall sequence are generated through the tokenizer layer; the token ids of the input overall sequence are input as input ids into the encoder model; the top vectors of the encoder model are taken as the top representation sequence of the corresponding input information (such as the compressed feature representation in the embodiment of the present application); according to the compression ratio, only the front part of the top representation sequence output by the encoder is taken, and a masking method can be used; the selected top representation sequence is used as the input embedding, input into the decoder part of the compression model, and the output representation sequence is converted into logits to fit the token ids information of the original text. If GPT is used as the decoder module, the teaching forcing method can be used for training. Training is performed by minimizing the reconstruction loss to ensure that the first part of the top representation sequence given by the encoder (determined by the compression rate) can be reconstructed into the original text by the decoder.

[0277] The main function of the compression model is to compress long sequences into representation sequences of different lengths according to the specified compression ratio, and the compressed representation sequences can be well reconstructed into the original input sequence through the Decoder model.

[0278] Among them, the compression model-based method can adopt different autoencoder structures, including using Transformer Encoder structures such as BERT, Longformer, Bigbird, XLNet on the encoder side, and using Transformer Encoder or Decoder structures such as BERT, GPT on the decoder side.

[0279] In addition, in order to adapt to long sequences, a feedforward propagation method of splitting-encoding-decoding-splicing can be adopted, or a sparse Transformer structure can be used as the Encoder, such as Longformer, Bigbird, XLNet, etc.

[0280] 503. Obtain a second text using a large language model based on the compressed feature representation.

[0281] 504. Update the large language model according to the second text and the corresponding true value.

[0282] In a possible implementation, the compressed feature representation may be input into a large language model, and the large language model may process the compressed feature representation to obtain the second text.

[0283] It should be understood that when the compressed feature representation is input into the large model, a representation containing a prompt corresponding to the target compression ratio can be added to the input sequence at the prefix or other position. When a compression model is used to compress the feature representation, the input content of the compression model itself can include prompt information, and the compressed feature representation does not strictly distinguish between the prompt information and the corresponding part of the text content (because they both serve as the input of the compression model).

[0284] In one possible implementation, the second text can be obtained using the large language model based on the compressed feature representation and the second feature representation. That is, the second feature representation can be input into the large language model along with the compressed feature representation, or it can be input without the second feature representation.

[0285] In the case of end-to-end training of the large language model and the compressed model, since the large language model can spontaneously learn to use the prompt information in the compressed representation, it is possible to choose not to input the second feature representation into the large model, and instead use the corresponding prompt information in the encoding result obtained by the compressed model.

[0286] In a possible implementation, the feature representation of the hidden layer output of the large language model can be obtained through a large language model based on the compressed feature representation; and the second text can be obtained through a text decoder based on the feature representation of the hidden layer output.

[0287] Among them, the text finally output by the large model can be directly used as the reply text (that is, tokens are generated using an uncompressed sequence). This situation is suitable for scenarios with long input and short output. The embodiment of the present application can also be extended to the compressed representation space processing of the entire sequence (that is, it is applicable to long output). Referring to Figure 9B, the feature representation after compression of the large language model input is used to train the language model using the translation relationship between the input-output hidden layer representation. Among them, each representation vector does not directly correspond to a token in the original vocabulary. The hidden layer representation at the output end can be used to restore the output text information using the decoder of the compression model. In addition, when training in the representation space, since it does not directly correspond to the one-hot vector of the original vocabulary, the cosine similarity or mean squared error (MSE) between the predicted representation vector and the actual representation vector can be used as the loss function.

[0288] In one possible implementation, the embodiment corresponding to FIG5 can be applied to the process of continuing pre-training of a large language model. That is, the large language model itself is already a pre-trained large model, and there is an upper limit to the length it can process, such as 2048 tokens. The embodiment of the present application can continue pre-training of long sequences based on this model, so that the model can process longer input sequences. As shown in FIG9A , FIG9A is a schematic diagram of continuing pre-training of a large model based on a compressed sequence. The main process is as follows: the sequence compression ratio is determined based on information such as the length of the original sequence. The sequence compression ratio is written into the prompt. The prompt text is passed through the embedding layer of the large model to obtain the corresponding embedding. The compressed representation of the original sequence is obtained using the average pooling or compression model method. The embedding of the prompt and the sequence representation after compression of the 1st to i-1th tokens of the original sequence, and the representation of the i-th token of the original sequence are spliced ​​and input into the part after the embedding layer of the large model, and the last position of the output predicts the i+1th token of the original sequence. The model is trained based on a certain amount of data with different lengths and compression ratios. Alternatively, a compressed representation of the prompt's embedding and the original sequence's tokens 1 to i can be used as input, with the last position of the output used to predict the original sequence's token i+1. Furthermore, when using a compressed model, it can be cascaded with the larger model for end-to-end training.

[0289] In one possible implementation, the embodiment corresponding to Figure 5 can be applied to the fine-tuning process of the large language model. That is to say, the large language model itself is already a pre-trained large model, and there is an upper limit to the length it can process, such as 2048 tokens. The embodiment of the present application can fine-tune long sequences based on this model, so that the model can process longer input sequences. As shown in Figure 9C, Figure 9C is a schematic diagram of the large model Finetune based on compressed representation. The main steps are to use the average pooling or compression model method to compress the original input sequence into a shorter representation sequence, and inform the model of the compression ratio used for the sequence through prompt, so that the large model can learn to give a text reply based on the content before compression.

[0290] Referring to Figure 9E, the training process is as follows: Use a compression model or Average Pooling to compress the original sequence or the representation sequence of the original sequence after passing through the embedding layer of the large model into a shorter compressed representation sequence. Write information such as the compression ratio into a prompt, and obtain the representation sequence of the prompt information through the embedding layer. The representation sequence of the prompt and the representation sequence after compression of the original input are concatenated as the input representation of the large language model. The expected answer is used as the output of the large language model, and training is performed using a teacher forcing method. Use input data of different lengths and different compression ratios for training on multiple different tasks to enhance the generalization of the model.

[0291] Alternatively, when using a compressed model for supervised fine-tuning (SFT), two approaches are considered: one is to use the encoder portion of a compressed model that has been pre-trained on a large amount of data for encoding, and then input it into a large language model for SFT. The other is to use both the pre-trained encoder and the large language model for end-to-end SFT. If the original input is too long, segmented compression and then merging can be used.

[0292] Furthermore, an end-to-end model training approach can be used during both pre-training and supervised fine-tuning. Compared to independently training a compressed model, end-to-end training of a large model allows gradients to be propagated back to the compressed model via the compressed representation sequence, thereby updating the parameters in the compressed model. Figure 9D illustrates this using SFT as an example. This overall structure can also be used during inference.

[0293] The beneficial effects of the embodiments of the present application mainly include the following points:

[0294] First, carrying the compression ratio in the prompt can provide a priori information about compression to the large model, allowing it to generate more accurate response text when there is input loss.

[0295] Second, this solution allows large language models that have already set a maximum length and completed pre-training to adapt to continued pre-training, fine-tuning, and inference on longer input sequences without retraining;

[0296] Third, it can theoretically support unlimited text input and support dynamic text compression to accommodate user input of varying lengths.

[0297] Fourth, arbitrary-length input can be mapped to a fixed-length input, and the theoretical inference latency can be controlled within the complexity of O(1). This allows for good control over the training and inference time and memory consumption for long sequences.

[0298] Next, the data processing method in the embodiment of the present application is introduced from the perspective of model reasoning:

[0299] An embodiment of the present application provides a data processing method, including:

[0300] Obtain a first feature representation and a second feature representation; the first feature representation is obtained after feature extraction of the first text, and the second feature representation is obtained after feature extraction of a prompt, wherein the prompt indicates compression according to a target compression ratio; compress the first feature representation and the second feature representation at the target compression ratio to obtain a compressed feature representation; obtain a second text based on the compressed feature representation through a large language model; the second text is used as a reply text to the first text.

[0301] In one possible implementation, the large language model is used to perform a target task, which is one of the following: reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, text automatic question answering, text intent recognition, text classification, text simplification, and text story generation.

[0302] In a possible implementation, the compression method includes: a mean pooling operation, or compression based on a text encoder.

[0303] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

[0304] In a possible implementation, the first feature representation and the second feature representation may be divided to obtain a plurality of sub-feature representations; and each of the plurality of sub-feature representations may be compressed at the target compression rate.

[0305] In a possible implementation, the target compression rate may also be determined based on a relationship between the length of the first text and a maximum text length supported by the large language model for input.

[0306] In a possible implementation, the compression method is compression based on a text encoder; the first feature representation and the second feature representation can be encoded by the text encoder to obtain an encoding result;

[0307] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

[0308] In a possible implementation, the second text may be obtained through a large language model according to the compressed feature representation and the second feature representation.

[0309] In a possible implementation, the feature representation of the hidden layer output of the large language model can be obtained through a large language model based on the compressed feature representation; and the second text can be obtained through a text decoder based on the feature representation of the hidden layer output.

[0310] Among them, the steps performed in the model inference process can refer to the steps performed in the feedforward process of the training process, and the similarities are not repeated here.

[0311] During the inference phase, appropriate processing methods can be adopted based on the different lengths of user input. When the user input is less than the maximum input length of the original large model, the input sequence can be directly input into the large model without passing through the compression module. When the user input length is greater than the maximum input length of the original large model, the input sequence must pass through the compression module (for example, including mean pooling operations or compression models), and use an appropriate compression ratio to compress the original sequence length to within the maximum input length of the large model. Optionally, when the user input length exceeds the processing length of the compression model, the input sequence can be segmented and input into the compression model, and the compressed representations are then spliced ​​together before being input into the large model.

[0312] Next, two application scenarios of the reasoning stage of the embodiment of this application are introduced.

[0313] One application scenario of the embodiment of the present application is an inference scenario for multi-document summarization. The content of each document passes through the compression module respectively to obtain the compressed representation corresponding to the document, and after merging, the representation task prompt is added to the prefix or other position and then input into the model, and the output is the generated summary. Referring to Figure 9F, Figure 9F is an SFT and reasoning diagram of multi-document summarization, wherein the specific process may include: selecting a suitable compression ratio and truncation length according to the length distribution of the document, using a unified compression ratio prompt and truncation length to compress each document, and then splicing to obtain a compressed representation sequence, and each document representation sequence can be divided by the large model representation corresponding to tokens such as [SEP]. The representation sequence obtained by passing the prompt of the multi-document summary task through the embedding layer is spliced ​​into the original multi-document compressed representation sequence in a prefix or other form to obtain an input representation sequence. The input representation sequence passes through the large model to obtain the output summary content.

[0314] One application scenario of the embodiment of the present application is for processing long sequences in multi-round conversations. Although in most cases, the length of the sequence input and output of each large model will not be too long. However, in actual applications, due to the interaction between the user and the model, a long historical conversation record may be formed during the conversation process, such as some educational scenarios and code iteration generation scenarios. In order to maintain the consistency of the conversation content, it is often necessary to process the historical conversation information. In this case, it can be considered to compress the representation sequence of the historical information after the length of the conversation history exceeds the model input length limit, and then merge it with the representation of the content of the recent conversation and input it into the model to finally generate the next reply. This embodiment can increase the multi-round conversation capability of the large model and can be used in scenarios such as education and code generation.

[0315] Based on the embodiments corresponding to Figures 1A to 9F , in order to better implement the above-mentioned solutions of the embodiments of the present application, the following also provides related devices for implementing the above-mentioned solutions. Specifically, refer to Figure 10 , which is a structural diagram of a data processing device 1000 provided in an embodiment of the present application. The data processing device 1000 includes:

[0316] An acquisition module 1001 is configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio;

[0317] For a detailed description of the acquisition module 1001 , reference may be made to the description of step 501 in the above embodiment, which will not be repeated here.

[0318] A processing module 1002 is configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0319] Obtaining a second text through a large language model based on the compressed feature representation;

[0320] The large language model is updated according to the second text and the corresponding true value.

[0321] For a detailed description of the processing module 1002 , reference may be made to the description of steps 502 to 504 in the above embodiment, which will not be repeated here.

[0322] In one possible implementation, the large language model is used to perform a target task, which is one of the following:

[0323] Reading comprehension, text translation, paraphrase recognition, named entity recognition, text sentiment analysis, natural language reasoning, text automatic question answering, text intent recognition, text classification, text simplification, and text story generation.

[0324] In a possible implementation, the compression method includes:

[0325] Mean pooling operation, or compression based on text encoder.

[0326] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

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

[0328] Splitting the first feature representation and the second feature representation to obtain multiple sub-feature representations;

[0329] Compress each of the plurality of sub-feature representations at the target compression rate.

[0330] In a possible implementation, the compression method is compression based on a text encoder; and the processing module is further configured to:

[0331] Obtaining predicted values ​​of the first text and the prompt through a text decoder according to the compressed feature representation;

[0332] The text encoder is updated according to the first text, the prompt and the predicted value.

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

[0334] The target compression rate is determined according to a relationship between the length of the first text and a maximum text length supported by the large language model.

[0335] In a possible implementation, the compression method is compression based on a text encoder;

[0336] The processing module is specifically used to:

[0337] Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result;

[0338] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

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

[0340] A second text is obtained based on the compressed feature representation and the second feature representation through a large language model.

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

[0342] Obtaining, through a large language model, a feature representation of a hidden layer output of the large language model according to the compressed feature representation;

[0343] The second text is obtained through a text decoder according to the feature representation of the hidden layer output.

[0344] In addition, the present application also provides a data processing device. For details, please refer to the introduction of the model inference process in the above embodiment. The device includes:

[0345] an acquisition module, configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio;

[0346] a processing module, configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation;

[0347] A second text is obtained based on the compressed feature representation through a large language model; the second text is used as a reply text to the first text.

[0348] In a possible implementation, the compression method includes:

[0349] Mean pooling operation, or compression based on text encoder.

[0350] In a possible implementation, the prompt is further used to indicate a compression method of the compression.

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

[0352] Splitting the first feature representation and the second feature representation to obtain multiple sub-feature representations;

[0353] Compress each of the plurality of sub-feature representations at the target compression rate.

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

[0355] The target compression rate is determined according to a relationship between the length of the first text and a maximum text length supported by the large language model.

[0356] In a possible implementation, the compression method is compression based on a text encoder;

[0357] The processing module is specifically used to:

[0358] Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result;

[0359] Part of the encoding results is used as the compressed feature representation, wherein the part of the encoding results is the encoding result obtained by extracting the proportion of the target compression rate from the encoding results.

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

[0361] A second text is obtained based on the compressed feature representation and the second feature representation through a large language model.

[0362] Next, a terminal device provided in an embodiment of the present application is introduced. Please refer to Figure 11. Figure 11 is a structural schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 1100 can be specifically manifested as a mobile phone, a tablet, a laptop computer, a smart wearable device, etc., which is not limited here. Among them, the terminal device 1100 can be used as a training device to implement the function of the data processing method in the embodiment corresponding to Figure 5, or as an execution device to execute the trained model obtained based on the data processing method in the embodiment corresponding to Figure 5. Specifically, the terminal device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103 and a memory 1104 (wherein the number of processors 1103 in the terminal device 1100 can be one or more), wherein the processor 1103 may include an application processor 11031 and a communication processor 11032. In some embodiments of the present application, the receiver 1101, the transmitter 1102, the processor 1103 and the memory 1104 may be connected via a bus or other means.

[0363] The memory 1104 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1103. A portion of the memory 1104 may also include non-volatile random access memory (NVRAM). The memory 1104 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.

[0364] Processor 1103 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all of these buses are referred to as a bus system in the figure.

[0365] The method disclosed in the above embodiment of the present application can be applied to the processor 1103, or implemented by the processor 1103. The processor 1103 can be an integrated circuit chip with signal processing capabilities. During the implementation process, the steps of the above method can be completed by the integrated logic circuit of the hardware in the processor 1103 or the instructions in the form of software. The above-mentioned processor 1103 can be a general-purpose processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and a vision processor (vision processing unit, VPU), a tensor processor (tensor processing unit, TPU) and other processors suitable for AI computing, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1103 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules within 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. The storage medium is located in memory 1104. Processor 1103 reads information from memory 1104 and, in conjunction with its hardware, performs steps 501 to 504 in the above embodiment.

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

[0367] The present application also provides a server. Please refer to FIG. 12 , which is a schematic diagram of a server structure provided by an embodiment of the present application. Specifically, server 1200 is implemented by one or more servers. Server 1200 may vary significantly due to configuration or performance differences. It may include one or more central processing units (CPUs) 1212 (e.g., one or more processors) and memory 1232, and one or more storage media 1230 (e.g., one or more mass storage devices) storing application programs 1242 or data 1244. The memory 1232 and storage medium 1230 may be either transient or persistent storage. The program stored in storage medium 1230 may include one or more modules (not shown), each of which may include a series of instruction operations on the training device. Furthermore, CPU 1212 may be configured to communicate with storage medium 1230 to execute the series of instruction operations in storage medium 1230 on server 1200.

[0368] The server 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1258; or one or more operating systems 1241, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0369] Specifically, the server can be used as a training device to execute steps 501 to 504 in the above embodiment, or as an execution device to execute the trained model obtained based on the data processing method in the embodiment corresponding to Figure 5.

[0370] In one possible implementation, the terminal device 1100 or the server 1200 can serve as a training device to execute steps 501 to 504 in the above embodiment to obtain a trained model, and deploy the trained model to an execution device, which can also be in the form of the terminal device 1100 or the server 1200. When the execution device executes the trained model, reference can be made to the model feedforward process in the embodiment corresponding to FIG. 5 .

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

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

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

[0374] Specifically, see Figure 13, which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip can be represented as a neural network processor NPU 1300. NPU 1300 is mounted on the host CPU (host CPU) as a coprocessor and is assigned tasks by the host CPU. The core of the NPU is the arithmetic circuit 1303, which is controlled by the controller 1304 to extract matrix data from the memory and perform multiplication operations.

[0375] The NPU 1300 can implement the data processing method and steps related to the model inference process provided in the embodiment described in FIG. 5 through the mutual cooperation between various internal components.

[0376] More specifically, in some implementations, the arithmetic circuit 1303 in the NPU 1300 includes multiple processing units (PEs). In some implementations, the arithmetic circuit 1303 is a two-dimensional systolic array. The arithmetic circuit 1303 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1303 is a general-purpose matrix processor.

[0377] For example, assume there are input matrix A, weight matrix B, and output matrix C. The computation circuit retrieves the corresponding data of matrix B from weight memory 1302 and caches it on each PE in the computation circuit. The computation circuit then retrieves the data of matrix A from input memory 1301 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1308.

[0378] Unified memory 1306 is used to store input and output data. Weight data is directly transferred to weight memory 1302 through the Direct Memory Access Controller (DMAC) 1305. Input data is also transferred to unified memory 1306 through the DMAC.

[0379] BIU stands for Bus Interface Unit 1310 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1309 .

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

[0381] DMAC is mainly used to move input data in the external memory DDR to the unified memory 1306 or to move weight data to the weight memory 1302 or to move input data to the input memory 1301.

[0382] The vector calculation unit 1307 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1303, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.

[0383] In some implementations, the vector calculation unit 1307 can store the processed output vector in the unified memory 1306. For example, the vector calculation unit 1307 can apply a linear function or a nonlinear function to the output of the operation circuit 1303, such as linear interpolation of the feature plane extracted by the convolution layer, or accumulate a vector of values ​​to generate an activation value. In some implementations, the vector calculation unit 1307 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1303, for example, for use in subsequent layers in a neural network.

[0384] An instruction fetch buffer 1309 connected to the controller 1304 is used to store instructions used by the controller 1304;

[0385] Unified memory 1306, input memory 1301, weight memory 1302, and instruction fetch memory 1309 are all on-chip memories. External memories are private to the NPU hardware architecture.

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

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

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

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

[0390] 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 (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website, computer, training device or 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 that includes one or more available media integrations. The available medium can be a magnetic medium, (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive (SSD)).

Claims

1. A data processing method, characterized in that: The method comprises: Obtaining a first feature representation and a second feature representation; the first feature representation is obtained after feature extraction of the first text, and the second feature representation is obtained after feature extraction of a prompt, wherein the prompt indicates compression according to a target compression rate; Compressing the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation; According to the compressed feature representation, a second text is obtained through a large language model; the second text is used as a reply text for the first text.

2. The method according to claim 1, characterized in that: The compression method of the compression includes: Mean pooling operation, or compression based on text encoder.

3. The method according to claim 1 or 2, characterized in that: The prompt is also used to indicate the compression method of the compression.

4. The method according to any one of claims 1 to 3, characterized in that: The compressing the first feature representation and the second feature representation to the target compression rate includes: Splitting the first feature representation and the second feature representation to obtain a plurality of sub-feature representations; Each of the plurality of sub-feature representations is compressed at the target compression rate.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: The target compression rate is determined according to the relationship between the length of the first text and the maximum text length supported by the large language model for input.

6. The method according to any one of claims 1 to 5, characterized in that: The compression method of the compression is compression based on a text encoder; The compressing the first feature representation and the second feature representation to the target compression rate includes: Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result; A partial encoding result in the encoding result is used as the compressed feature representation, and the partial encoding result is an encoding result obtained by extracting a proportion of the target compression rate in the encoding result.

7. The method according to any one of claims 1 to 6, characterized in that: The step of obtaining a second text according to the compressed feature representation through a large language model includes: A second text is obtained according to the compressed feature representation and the second feature representation through a large language model.

8. The method according to any one of claims 1 to 7, characterized in that: The step of obtaining a second text according to the compressed feature representation through a large language model includes: According to the compressed feature representation, a feature representation of a hidden layer output of the large language model is obtained through a large language model; The second text is obtained through a text decoder according to the feature representation of the hidden layer output.

9. A data processing method, characterized in that: The method comprises: Obtaining a first feature representation and a second feature representation; the first feature representation is obtained after feature extraction of the first text, and the second feature representation is obtained after feature extraction of a prompt, wherein the prompt indicates compression according to a target compression rate; Compressing the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation; Obtaining a second text through a large language model according to the compressed feature representation; The large language model is updated according to the second text and the corresponding true value.

10. The method according to claim 9, characterized in that The compression method of the compression includes: Mean pooling operation, or compression based on text encoder.

11. The method according to claim 9 or 10, characterized in that: The compression method of the compression is compression based on a text encoder; the method also includes: Obtaining predicted values ​​of the first text and the prompt through a text decoder according to the compressed feature representation; Update the text encoder according to the first text, the prompt and the predicted value.

12. A data processing device, characterized in that: The device comprises: an acquisition module, configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio; a processing module, configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation; According to the compressed feature representation, a second text is obtained through a large language model; the second text is used as a reply text for the first text.

13. The device according to claim 12, characterized in that The compression method of the compression includes: Mean pooling operation, or compression based on text encoder.

14. The device according to claim 12 or 13, characterized in that The prompt is also used to indicate the compression method of the compression.

15. The device according to any one of claims 12 to 14, characterized in that: The processing module is further used for: The target compression rate is determined according to the relationship between the length of the first text and the maximum text length supported by the large language model for input.

16. The device according to claim 15, characterized in that The compression method of the compression is compression based on a text encoder; The processing module is specifically used for: Encoding the first feature representation and the second feature representation by the text encoder to obtain an encoding result; A partial encoding result in the encoding result is used as the compressed feature representation, and the partial encoding result is an encoding result obtained by extracting a proportion of the target compression rate in the encoding result.

17. The device according to any one of claims 12 to 16, characterized in that The processing module is specifically used for: A second text is obtained according to the compressed feature representation and the second feature representation through a large language model.

18. A data processing device, characterized in that: The device comprises: an acquisition module, configured to acquire a first feature representation and a second feature representation; the first feature representation is obtained by extracting features from the first text, and the second feature representation is obtained by extracting features from a prompt, wherein the prompt indicates compression according to a target compression ratio; a processing module, configured to compress the first feature representation and the second feature representation at the target compression rate to obtain a compressed feature representation; Obtaining a second text through a large language model according to the compressed feature representation; The large language model is updated according to the second text and the corresponding true value.

19. The device according to claim 18, characterized in that The compression method of the compression includes: Mean pooling operation, or compression based on text encoder.

20. The device according to any one of claims 12 to 19, characterized in that The compression method of the compression is compression based on a text encoder; the processing module is also used for: Obtaining predicted values ​​of the first text and the prompt through a text decoder according to the compressed feature representation; Update the text encoder according to the first text, the prompt and the predicted value.

21. A data processing device, characterized in that: The device includes a memory and a processor; the memory stores codes, and the processor is configured to obtain the codes and execute the method according to any one of claims 1 to 11.

22. A computer storage medium, characterized in that The computer storage medium stores one or more instructions, which, when executed by one or more computers, enable the one or more computers to implement the method of any one of claims 1 to 11.

23. 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 11.

24. A chip, comprising a processor, characterized in that: The processor is used to support a data processing device to implement the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Language model training method and device, equipment and storage medium

    CN115114433A

  • Text generation method, device and equipment and readable storage medium

    CN115146050A

  • Language processing method and device and storage medium

    CN115712701A

  • Data processing method and related equipment

    CN116737895A

  • Data generation method using language model, computer device, and computer program

    JP2023018624A

Cited By

  • Large model-based data processing method, apparatus and device, and storage medium

    CN119851661A