Data processing method and apparatus using same
By semantically compressing the prompts sent by the cloud-side device to the edge device, shorter prompts are generated and processed, solving the problems of high latency and cost in deploying large models on both the edge and cloud sides, and improving computational efficiency.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2025-06-28
- Publication Date
- 2026-05-15
AI Technical Summary
When deploying large models on the edge cloud, the low computing power on the edge side leads to problems such as high inference latency and high cost.
By receiving the first prompt from the cloud-side device, semantic compression is performed to generate a shorter second prompt, which is then processed on the edge device, leveraging the edge device's strong data processing capabilities to reduce computational overhead and latency.
While ensuring computational accuracy, the computational and time overhead of edge model processing prompts is reduced, and the frequency and cost of data transmission between edge and cloud are decreased.
Smart Images

Figure CN2025105150_15052026_PF_FP_ABST
Abstract
Description
A data processing method and apparatus
[0001] This application claims priority to Chinese Patent Application No. 202411392865.7, filed with the State Intellectual Property Office of China on September 30, 2024, entitled “A Data Processing Method and Apparatus”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of artificial intelligence, and more particularly to a data processing method and apparatus thereof. Background Technology
[0003] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0004] In existing technologies, large models are often deployed on the edge, and the large models built into the edge are used first during inference. However, due to the low computing power of the edge, cloud-based models are needed to assist in inference. For example, the model can be split, with the parts of the model that do not require much computing power inferenced on the edge, and the parts of the model that require much computing power inferenced on the cloud. Specifically, the edge performs the inference process related to the shallow part of the model, and the cloud performs the inference process related to the deep part of the model.
[0005] However, this leads to frequent data transfers between the edge and the cloud, resulting in high inference latency and high costs. Summary of the Invention
[0006] In a first aspect, this application provides a data processing method applied to a first device, the method comprising: receiving a first prompt sent by a second device, the first prompt being obtained based on an input request; obtaining a second prompt based on the first prompt; the length of the second prompt being less than that of the first prompt, and the second prompt containing the semantics indicated in the first prompt; and sending the second prompt to the second device; wherein the data processing capability of the first device is greater than that of the second device.
[0007] The second prompt includes the semantics indicated in the first prompt. This can be understood as the second prompt and the first prompt having a high degree of semantic similarity; both describe the same semantic information, but the former is shorter than the latter. The semantics can be directly indicative (e.g., described through natural language) or indirectly indicative (e.g., indicated through vector representation). The semantics indicated by vector representation can be determined by a specific task network. Of course, the second prompt may not include semantics unrelated to the generation of a response to the input request in the first prompt; that is, the second prompt includes the key semantics indicated in the first prompt (i.e., semantics related to the generation of a response to the input request).
[0008] This application processes the first prompt sent from a device with low computing power into a shorter second prompt. In order to ensure the computational accuracy of the subsequent model, the second prompt still contains the semantics of the first prompt. Thus, the edge model only needs to process the shorter second prompt. In addition, processing the shorter prompt can also reduce the size of the output result. Therefore, while ensuring the accuracy of the result, the computational overhead of the edge model in processing the prompt can be reduced, thereby reducing inference latency.
[0009] The second device performs semantic-preserving compression on the prompts from the first device. Since the first device processes the compressed prompts, this significantly reduces the computational and time overhead required for processing the prompts using a machine learning model, especially for devices with lower data processing capabilities, while maintaining processing accuracy (the compression is semantic-preserving). Furthermore, compared to the second device directly processing the prompts sent by the first device, the computational resources on the second device are often more expensive than those on the first device. The process of processing prompts to obtain responses to input requests requires numerous iterations and more computational resources than simply compressing the prompts. Therefore, in this embodiment, using the second device for prompt compression while the first device performs the response based on the prompts reduces the computational overhead on the second device.
[0010] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
[0011] Here, "summarizing" can be understood as using shorter language to summarize the content of natural language, or it can be called a summary.
[0012] The first natural language description can be all or part of the first prompt.
[0013] For example, a language model can be used to summarize the first natural language description by constructing a prompt, and this second prompt can also be called a hard prompt.
[0014] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description. For example, feature extraction can be performed on the first natural language description to obtain the first vector representation.
[0015] In one possible implementation, obtaining the second prompt based on the first prompt includes: compressing the first natural language description in the first prompt to obtain a second vector representation; adjusting the dimensions of the second vector representation to obtain the first vector representation, wherein the second prompt includes the first vector representation.
[0016] Because the data processing capability of the first device is less than that of the second device, the scale of the model (first machine learning model) deployed on the first device is often smaller than that of the model (second machine learning model) deployed on the second device. For models of different scales, the supported dimensions of the vector representation of the input (e.g., the dimension of an embedded vector of the input) are often different. Therefore, the dimension of the vector representation obtained by the second device through the second machine learning model may be different from the dimension of the vector representation of the input supported by the first machine learning model on the first device. In this embodiment, a dimension adjustment module (also called a dimension adapter) can be deployed on the second device or the first device. This dimension adjustment module can adjust the dimension of the vector representation obtained by the second machine learning model to the dimension of the vector representation of the input supported by the first machine learning model. For example, when the dimension adjustment module is deployed on the second device, the second device can compress the first prompt through the second machine learning model to obtain a second vector representation. Then, the second device can adjust the dimension of the second vector representation through the dimension adjustment module to obtain a second prompt containing the dimension-adjusted vector representation (first vector representation). After that, the second device can send the second prompt containing the dimension-adjusted vector representation (first vector representation) to the first device, and the first device can process the second prompt through the first machine learning model.
[0017] In one possible implementation, the first prompt includes multiple prompt segments obtained by segmentation, and the second prompt includes a compressed result (e.g., feature representation or general description) obtained by compressing each of the multiple prompt segments.
[0018] Compression can be achieved by summarizing the natural language description in the first prompt to obtain a summary description, or by extracting features from the natural language description in the first prompt to obtain an abstract vector representation. The length of the vector representation is often much shorter than that of the natural language.
[0019] For example, a language model can be used to extract features from the first natural language description by constructing a prompt, and this second prompt can also be called a soft prompt.
[0020] In one possible implementation, obtaining the second prompt based on the first prompt includes: constructing a third prompt based on the first prompt, the third prompt indicating that each prompt segment among the plurality of prompt segments obtained by dividing the first prompt should be processed; obtaining a compression result for each of the prompt segments through a language model based on the third prompt; and obtaining the second prompt by fusing the plurality of compression results.
[0021] In one possible implementation, the data processing capability is computing power.
[0022] In one possible implementation, the first prompt includes multiple segments of natural language description, and the second prompt includes a generalized description or vector representation obtained by processing each of the segments.
[0023] In other words, each segment in the first prompt can be processed to obtain a general description or vector representation of each segment, and then fused (e.g., concatenated) to obtain the second prompt. This is equivalent to preserving the semantics of each segment. Compared to summarizing or extracting features from the whole, summarizing or extracting features from segments and then fusing them can preserve more complete semantics.
[0024] In one possible implementation, the first prompt includes the input request, the request for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the request for the output, and the context information.
[0025] A prompt can include multiple parts, including, for example, an input request, which can be user input information, such as a question. A prompt can also include contextual information, such as historical input information and output when the question is multi-turn, or environmental information for generating the result. A prompt can also include conditions that the output needs to meet, also known as constraints on the output. Of course, a prompt can also include other types of information, depending on the prompt template used to generate the prompt. The three examples above can also overlap with each other; for example, an input request can also contain some requirements for the output.
[0026] In this embodiment of the application, when the second device compresses the first prompt, it can compress one or more of the above information. For example, it can compress only all or part of the input request, while keeping other information consistent with the first information. For example, it can compress only the input request and context information, while keeping other information consistent with the first prompt.
[0027] In one possible implementation,
[0028] The first device is an edge device, and the second device is a cloud-side server; or,
[0029] The first device is an endpoint device, and the second device is an edge-side server; or,
[0030] The first device is an edge device, and the second device is a cloud server.
[0031] Secondly, this application provides a system including a first device and a second device, the first device and the second device communicating with each other, and the data processing capability of the first device being greater than that of the second device;
[0032] The first device is used to send a first prompt to the second device, wherein the first prompt is obtained based on an input request;
[0033] The second device is used to obtain a second prompt based on the first prompt; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated in the first prompt;
[0034] The second device is used to send the second prompt to the second device;
[0035] The first device is used to obtain a response to the input request based on the second prompt and through a first machine learning model.
[0036] In one possible implementation, the second device is specifically used to obtain a second prompt based on the first prompt through a second machine learning model;
[0037] The first machine learning model is obtained by compressing or knowledge distilling the second machine learning model.
[0038] In training the second machine learning model, a set compression ratio can be used as one of the training objectives, enabling the trained second machine learning model to possess compression capabilities at the set compression ratio. Multiple second machine learning models can be trained, each with different compression ratio capabilities. One of the second machine learning models can be selected to perform the compression process of the first prompt sent by the first device.
[0039] In one possible implementation, the first device may also carry information indicating the compression ratio requirement when sending the first prompt to the second device, and the second device may select from multiple second machine learning models that can meet the compression ratio requirement to process the first prompt.
[0040] In one possible implementation, for different first devices, the second device can select a second machine learning model with different compression capabilities to perform the compression process. For example, the second device can select model A to process the prompt sent by device A and model B to process the prompt sent by device B. Device A and device B are different, and model A and model B have different compression ratios.
[0041] In one possible implementation, the first machine learning model and the second machine learning model have the same training task during training.
[0042] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description;
[0043] The first device is further configured to adjust the dimensions of the first vector representation in the second prompt to obtain the adjusted second prompt;
[0044] The first device is specifically used to obtain a response to the input request based on the adjusted second prompt and through a first machine learning model.
[0045] Thirdly, this application provides a data processing method applied to a second device, the method comprising:
[0046] Send a first prompt to the first device, the first prompt being obtained based on the input request;
[0047] Receive a second prompt sent by the first device according to the first prompt, wherein the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt;
[0048] Based on the second prompt, a response to the input request is obtained through the first machine learning model; wherein, the data processing capability of the first device is greater than that of the second device.
[0049] In one possible implementation, the input request includes privacy information; the first prompt does not include the privacy information, and the first device is further configured to integrate the privacy information into the second prompt.
[0050] The first device can obtain an initial prompt based on the input request. The initial prompt may contain privacy information, which may not be included in the first prompt. To ensure the accuracy of the generated result, after receiving the second prompt from the second device, the first device can integrate the privacy information into the second prompt and generate a response to the input request based on the second prompt with integrated privacy information through a language model. In this way, while ensuring that the privacy information is not perceived by the second device and improving the processing speed of the first device for prompts, the accuracy of the first device's processing of input requests can be guaranteed.
[0051] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; the method further includes:
[0052] The dimensions of the first vector representation in the second prompt are adjusted to obtain the adjusted second prompt.
[0053] The step of obtaining a response to the input request based on the second prompt and through the first machine learning model includes:
[0054] Based on the adjusted second prompt, a response to the input request is obtained through the first machine learning model.
[0055] When the dimension adjustment module is deployed on the first device, after receiving the second prompt sent by the second device, the first device can adjust the dimension of the vector representation included in the second prompt, thereby obtaining the second prompt containing the dimension-adjusted vector representation. The second device can process the second prompt containing the dimension-adjusted vector representation through the first machine learning model.
[0056] Fourthly, this application provides a data processing apparatus applied to a first device, the apparatus comprising:
[0057] The transceiver module is used to receive a first prompt sent by the second device, which is obtained based on the input request;
[0058] A prompt compression module is used to obtain a second prompt based on the first prompt; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated in the first prompt;
[0059] The transceiver module is further configured to send the second prompt to the second device; wherein the data processing capability of the first device is greater than that of the second device.
[0060] In one possible implementation, the first prompt includes multiple prompt segments obtained by segmentation, and the second prompt includes a compressed result obtained by compressing each of the multiple prompt segments.
[0061] In one possible implementation, the prompt compression module is specifically used for:
[0062] Based on the first prompt, a third prompt is constructed, wherein the third prompt indicates how to process each of the multiple prompt segments obtained from the division of the first prompt;
[0063] Based on the third prompt, a language model is used to obtain the compression result of each prompt fragment;
[0064] The second prompt is obtained by fusing multiple compression results.
[0065] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
[0066] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description.
[0067] In one possible implementation, the prompt compression module is specifically used for:
[0068] The first natural language description in the first prompt is compressed to obtain a second vector representation;
[0069] The device further includes:
[0070] The dimension adjustment module is used to adjust the dimensions of the second vector representation to obtain the first vector representation, and the second prompt includes the first vector representation.
[0071] In one possible implementation, the processing module is specifically used for:
[0072] The first device is an edge device, and the second device is a cloud-side server; or,
[0073] The first device is an endpoint device, and the second device is an edge-side server; or,
[0074] The first device is an edge device, and the second device is a cloud server.
[0075] In one possible implementation, the data processing capability is computing power.
[0076] In one possible implementation,
[0077] The first prompt includes the input request, the requirement for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the requirement for the output, and the context information.
[0078] Fifthly, embodiments of this application provide a data processing apparatus applied to a second device, the apparatus comprising:
[0079] The transceiver module is used to send a first prompt to the second device, which is obtained based on the input request;
[0080] A prompt compression module is configured to receive a second prompt sent by the second device according to the first prompt, wherein the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt;
[0081] The model inference module is used to obtain a response to the input request based on the second prompt and through the first machine learning model.
[0082] In one possible implementation, the input request includes privacy information; the first prompt does not include the privacy information, and the first device is further configured to integrate the privacy information into the second prompt.
[0083] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; the apparatus further includes:
[0084] The dimension adjustment module is used to adjust the dimension of the first vector representation in the second prompt to obtain the adjusted second prompt.
[0085] The model inference module is specifically used for:
[0086] Based on the adjusted second prompt, a response to the input request is obtained through the first machine learning model.
[0087] In a sixth aspect, embodiments of this application provide a data processing apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect and any optional methods described in the third aspect and any optional methods described in the third aspect.
[0088] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, as well as the methods described in the third aspect and any optional methods thereof.
[0089] Eighthly, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any optional methods thereof, as well as the methods described in the third aspect and any optional methods thereof.
[0090] Ninthly, this application provides a chip system including a processor for supporting an execution data processing device in performing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. The chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description
[0091] Figure 1A is a schematic diagram of a structural framework for artificial intelligence.
[0092] Figures 1B and 1C are schematic diagrams of the application system framework of the present invention;
[0093] Figure 1D is a schematic diagram of an optional hardware structure for the terminal;
[0094] Figure 2 is a schematic diagram of a server structure;
[0095] Figures 3 to 5 are schematic diagrams of a system architecture according to this application;
[0096] Figure 6 illustrates the process of a cloud service.
[0097] Figure 7 is a flowchart illustrating a data processing method provided in an embodiment of this application;
[0098] Figure 8 is a flowchart illustrating a data processing method provided in an embodiment of this application;
[0099] Figures 9 and 10 are schematic flowcharts of a data processing method provided in an embodiment of this application;
[0100] Figure 11 is a schematic diagram of a data processing device provided in an embodiment of this application;
[0101] Figure 12 is a schematic diagram of a terminal device provided in an embodiment of this application;
[0102] Figure 13 is a schematic diagram of a server structure provided in an embodiment of this application;
[0103] Figure 14 is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation
[0104] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.
[0105] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0106] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0107] The terms “substantially,” “about,” and similar terms used herein are used as approximations rather than as terms of degree, and are intended to take into account the inherent biases of measurements or calculations known to those skilled in the art. Furthermore, the use of “may” in describing embodiments of the invention refers to “one or more possible embodiments.” The terms “use,” “using,” and “used” used herein are to be considered synonymous with the terms “utilize,” “utilizing,” and “utilized,” respectively. Additionally, the term “exemplary” is intended to refer to an instance or illustration.
[0108] First, the overall workflow of an artificial intelligence system is described, as shown in Figure 1A. Figure 1A is a structural diagram of the main framework of artificial intelligence. The framework is then elaborated from two dimensions: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed by technology) to the industrial ecosystem of the system.
[0109] (1) Infrastructure
[0110] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.
[0111] (2) Data
[0112] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0113] (3) Data processing
[0114] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.
[0115] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training on data, including symbolization and formalization.
[0116] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.
[0117] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.
[0118] (4) General ability
[0119] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0120] (5) Smart Products and Industry Applications
[0121] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, smart cities, etc.
[0122] First, we will introduce the application scenarios of this application. This application can be used, but is not limited to, applications with generative artificial intelligence (AIGC) functionality (hereinafter referred to as synthetic applications) or cloud services provided by cloud-side servers, etc., which will be introduced separately below:
[0123] I. Synthesis Applications
[0124] The product form of this application embodiment can be a synthetic application. Synthetic applications can run on terminal devices or cloud-based servers.
[0125] In one possible implementation, a compositing application can perform data generation tasks based on input data (e.g., images, text, audio, video, etc.), wherein the compositing application can perform data generation tasks in response to the input data (e.g., images, text, audio, video, etc.) to obtain a compositing result.
[0126] For example, the task of generating the above data can be, but is not limited to:
[0127] Text generation task: It can generate various types of text content, including news reports, blog posts, product descriptions, social media posts, etc. It can generate logical and coherent text based on given themes and requirements.
[0128] Image generation task: This task can generate images, including illustrations, artworks, design drafts, etc. It can generate image content related to given descriptions or keywords.
[0129] Audio generation task: This task can generate speech content, including text readings and responses from voice assistants. It can simulate human speech characteristics and intonation, making the generated speech sound more natural.
[0130] Content summarization and conclusion tasks: It can read large amounts of text content and generate summaries or conclusions. It can extract key information from the text and present it to the user in a concise manner.
[0131] Language translation task: This function performs language translation, converting text from one language to another. It can handle multiple language pairs and provide accurate translation results.
[0132] Automated replies and customer service: This can be used to automatically answer user questions and provide customer service. It can understand the user's intent and provide accurate answers or suggestions.
[0133] In one possible implementation, a user can open a synthesis application installed on a terminal device and input data (such as images, text, audio, video, etc.). The synthesis application can generate data from the input data using the methods provided in the embodiments of this application and present the synthesis result to the user (the presentation method may include, but is not limited to, displaying, saving, uploading to the cloud, etc.).
[0134] In one possible implementation, a user can open a synthesis application installed on a terminal device and input data. The synthesis application can send the input data to a cloud-based server. The cloud-based server generates data from the input data using the method provided in this application embodiment and sends the synthesis result back to the terminal device. The terminal device can then present the synthesis result to the user (the presentation method may include, but is not limited to, displaying, saving, or uploading to the cloud).
[0135] The following sections will describe the synthetic application in this application from the perspectives of functional architecture and product architecture that implements the functions.
[0136] Referring to Figure 1B, which is a schematic diagram of the functional architecture of the synthetic application in an embodiment of this application:
[0137] In one possible implementation, as shown in FIG1B, the synthesis application 102 may receive input parameters 101 (e.g., containing input data) and produce a synthesis result 103. The synthesis application 102 may execute on at least one computer system (for example) and includes computer code that, when executed by one or more computers, causes the computers to execute a natural language model trained by the methods provided in the embodiments of this application.
[0138] Referring to Figure 1C, which is a schematic diagram of the entity architecture for running a synthetic application in an embodiment of this application:
[0139] Referring to Figure 1C, which illustrates a system architecture, the system may include a terminal 100 and a server 200. The server 200 may include one or more servers (Figure 1C illustrates this using one server as an example), and the server 200 may provide synthesis function services to one or more terminals.
[0140] The terminal 100 may have a synthesis application installed or a webpage related to the synthesis function open. The application and webpage can provide an interface. The terminal 100 can receive relevant parameters input by the user on the synthesis function interface and send the parameters to the server 200. The server 200 can obtain the processing result based on the received parameters and return the processing result to the terminal 100.
[0141] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters on its own, without the need for the server to cooperate. This application embodiment is not limited to this.
[0142] The product form of terminal 100 in Figure 1C will be described next;
[0143] The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.
[0144] Figure 1D shows a schematic diagram of an optional hardware structure for terminal 100.
[0145] Referring to Figure 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 understand that Figure 1D is merely an example of a terminal or multi-functional device and does not constitute a limitation on the terminal or multi-functional device; it may include more or fewer components than illustrated, or combine certain components, or use different components.
[0146] The input unit 130 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit 130 may include a touchscreen 131 (optional) and / or other input devices 132. The touchscreen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touchscreen), and drive the corresponding connection devices according to a pre-set program. The touchscreen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touchscreen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, various types of touchscreens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used to implement the touchscreen. Besides the touchscreen 131, the input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0147] Among them, the input device 132 can receive input data, etc.
[0148] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In this embodiment, the display unit 140 can be used to display the interface of a synthesis application, the generated synthesis results, etc.
[0149] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.
[0150] The processor 170 is the control center of the terminal 100. It connects various parts of the terminal 100 via various interfaces and lines. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it performs various functions and processes data of the terminal 100, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented separately on independent chips. The processor 170 can also be used to generate corresponding operation control signals, send them to the corresponding components of the computing processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that the various functional modules therein perform corresponding functions, thereby controlling the corresponding components to act according to the instructions.
[0151] The memory 120 can be used to store software code related to the data processing method, and the processor 170 can execute the steps of the chip's data processing method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.
[0152] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0153] In this embodiment of the application, the radio frequency unit 110 can send input data to the server 200 and receive the synthesis result sent by the server 200.
[0154] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.
[0155] The terminal 100 also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0156] Terminal 100 also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect terminal 100 to other devices for communication or to connect a charger to charge terminal 100.
[0157] Although not shown, terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, and sensors with various functions, which will not be described in detail here. Some or all of the methods described below can be applied to terminal 100 as shown in Figure 1D.
[0158] The product form of server 200 in Figure 1C is described below;
[0159] Figure 2 provides a schematic diagram of the structure of a server 200. As shown in Figure 2, 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.
[0160] Bus 201 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in Figure 2, but this does not indicate that there is only one bus or one type of bus.
[0161] The processor 202 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0162] Memory 204 may include volatile memory, such as random access memory (RAM). Memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0163] The memory 204 can be used to store software code related to the data processing method, and the processor 202 can execute the steps of the chip's data processing method, and can also schedule other units to achieve corresponding functions.
[0164] It should be understood that the aforementioned terminal 100 and server 200 can be centralized or distributed devices. The processors (e.g., processor 170 and processor 202) in the aforementioned terminal 100 and server 200 can be hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the processor can be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0165] It should be understood that the steps related to the model inference process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and the server is not limited to the processor-memory architecture described above. The system architecture provided in the embodiments of this application will be described in detail below with reference to Figure 5.
[0166] Figure 5 is a schematic diagram of the system architecture provided in an embodiment of this application. As shown in Figure 5, 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 device 560.
[0167] The execution device 510 includes a calculation module 511, an I / O interface 512, a preprocessing module 513, and a preprocessing module 514. The calculation module 511 may include a target model / rule 501, while the preprocessing modules 513 and 514 are optional.
[0168] The execution device 510 can be a terminal device or a server that runs the aforementioned synthetic application.
[0169] The data acquisition device 560 is used to collect training samples. Training samples can be program files (including program code and program input data), etc. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.
[0170] The training device 520 can maintain training samples in the database 530 to obtain the target model / rule 501 from the neural network to be trained.
[0171] It should be noted that in practical applications, the training samples maintained in database 530 may not all come from the data acquisition device 560; they may also be received from other devices. Furthermore, it should be noted that training device 520 may not necessarily train the target model / rule 501 entirely based on the training samples maintained in database 530; it may also obtain training samples from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application.
[0172] The target model / rule 501 trained by the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in Figure 5. The execution device 510 can be a terminal, such as a mobile terminal, tablet computer, laptop computer, augmented reality (AR) / virtual reality (VR) device, vehicle terminal, etc., or it can be a server, etc.
[0173] Specifically, the training device 520 can transfer the trained model to the execution device 510.
[0174] In Figure 5, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with external devices. Users can input data to the I / O interface 512 through the client device 540 (e.g., input data in the embodiment of this application).
[0175] Preprocessing modules 513 and 514 are used to preprocess the input data received from the I / O interface 512. It should be understood that preprocessing modules 513 and 514 may be absent, or only one preprocessing module may be used. When preprocessing modules 513 and 514 are absent, the calculation module 511 can be used directly to process the input data.
[0176] During the preprocessing of input data by the execution device 510, or during the calculation module 511 of the execution device 510 performing calculations and other related processes, the execution device 510 can call data, code, etc. in the data storage system 550 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 550.
[0177] Finally, the I / O interface 512 provides the processing results (such as the synthesis results) to the client device 540, thereby providing them to the user.
[0178] In the scenario shown in Figure 5, the user can manually provide input data, which can be done through the interface provided by I / O interface 512. Alternatively, the client device 540 can automatically send input data to I / O interface 512. If user authorization is required for the client device 540 to automatically send input data, the user can set the corresponding permissions in the client device 540. The user can view the output results of the execution device 510 on the client device 540, which can be presented in various forms such as display, sound, or animation. The client device 540 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530. Alternatively, data can be collected directly from the I / O interface 512 without going through the client device 540, using the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530.
[0179] It is worth noting that Figure 5 is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the figure do not constitute any limitation. For example, in Figure 5, 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 aforementioned execution device 510 can be deployed in the client device 540.
[0180] From the inference side of the model:
[0181] In this embodiment, the computing module 511 of the 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 this embodiment.
[0182] In this embodiment of the application, the computing module 511 of the execution device 510 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0183] Specifically, the computing module 511 of the execution device 510 can be a hardware system with the function of executing instructions. The steps related to the model inference process provided in this application embodiment can be software code stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model inference process provided in this application embodiment.
[0184] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the model reasoning process provided in the embodiments of this application can also be implemented by the hardware system in the computing module 511 of the execution device 510 without the function of executing instructions, which is not limited here.
[0185] From the training side of the model:
[0186] In this embodiment, the training device 520 can obtain the code stored in the memory (not shown in Figure 5, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in this embodiment.
[0187] In this embodiment of the application, the training device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.
[0188] It should be understood that the training device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the training of the neutralization model provided in the embodiments of this application can also be implemented by the hardware system in the training device 520 without the function of executing instructions, which is not limited here.
[0189] II. Cloud services providing synthesis functionality provided by the server:
[0190] In one possible implementation, the server can provide composition services to the client side through an application programming interface (API).
[0191] In this process, the terminal device can send relevant parameters (such as input data) to the server through the API provided by the cloud. The server can obtain the processing result (such as the synthesis result) based on the received parameters and return the processing result to the terminal.
[0192] The descriptions of the terminal and server are the same as those in the above embodiments, and will not be repeated here.
[0193] Figure 6 illustrates the process of using a synthetic function cloud service provided by a cloud platform.
[0194] 1. Activate and purchase the synthesis function service.
[0195] 2. Users can download the software development kit (SDK) corresponding to the synthesis function service. Cloud platforms usually provide multiple development versions of the SDK for users to choose from according to their development environment needs, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.
[0196] 3. After downloading the corresponding version of the SDK to their local machine according to their needs, users can import the SDK project into their local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment, thus forming an application that integrates the capabilities of composite functional classes.
[0197] 4. When a compositing application is used, it can trigger an API call for the compositing function when needed. When the application triggers the compositing function, it sends an API request to the running instance of the compositing function service in the cloud environment. The API request carries input data, which is processed by the running instance in the cloud environment to obtain the processing result (such as the compositing result).
[0198] 5. The cloud environment returns the processing result to the application, thus completing a synthesis function service call.
[0199] In addition to applications and cloud services, the implementation of this application can also be in a large model inference acceleration library or a large model application SDK.
[0200] To better understand the solutions of the embodiments of this application, the following uses text generation as an example and combines Figures 3 and 4 to briefly introduce the possible application scenarios of the embodiments of this application.
[0201] Figure 3 illustrates a natural language processing (NLP) system, which includes user devices and data processing devices. The user devices include smart terminals such as mobile phones, personal computers, or information processing centers. The user devices are the initiators of natural language data processing, acting as the initiators of requests such as language question answering or queries; typically, users initiate requests through their user devices.
[0202] The aforementioned data processing equipment can be cloud servers, network servers, application servers, management servers, or other devices or servers with data processing capabilities. The data processing equipment receives queries / voice / text from smart terminals via an interactive interface, then performs language data processing through a storage device and a data processing processor, employing methods such as machine learning, deep learning, search, reasoning, and decision-making. The processing results are then fed back to the user device. The storage device in the data processing equipment can be a general term, including local storage and a database storing historical data. The database can be located on the data processing equipment or on other network servers.
[0203] In the natural language processing system shown in Figure 3, the user device can receive instructions from the user. For example, the user device can receive a piece of text input by the user and then send a request to the data processing device, so that the data processing device can perform natural language processing applications (such as natural language generation, text classification, text reasoning, named entity recognition, translation, etc.) on the piece of text obtained by the user device, thereby obtaining the processing results of the corresponding natural language processing applications on the piece of text (such as prediction results, classification results, reasoning results, named entity recognition results, translation results, etc.).
[0204] In this embodiment of the application, the user equipment can receive instructions from the user, such as receiving a piece of text input by the user (e.g., input data), and then sending a request to the data processing device to cause the data processing device to perform a natural language processing application (e.g., text synthesis) on the piece of text obtained by the user equipment, thereby obtaining the processing result (e.g., synthesis result) of the corresponding natural language processing application on the piece of text.
[0205] The text is shown in Figure 3. The data processing device can process the above-mentioned text data using the method provided in the embodiments of this application.
[0206] Figure 4 illustrates another natural language processing system. In Figure 4, the user equipment directly acts as a data processing device. This user equipment can directly receive input from the user and process it directly by the hardware of the user equipment itself. The specific process is similar to that in Figure 3, and can be referred to the description above, so it will not be repeated here.
[0207] Figure 4 is a schematic diagram of the natural language processing related devices provided in the embodiments of this application.
[0208] The processors in Figures 3 and 4 can perform data training / machine learning / deep learning using neural network models or other models, and use the models finally trained or learned from the data (such as the natural language models in the embodiments of this application) to perform natural language processing applications (such as program synthesis, etc.) on text data (such as the input data text described in the embodiments of this application) to obtain the corresponding processing results.
[0209] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.
[0210] (1) Neural Network
[0211] A neural network can be composed of neural units, which can be defined as a computational unit that takes xs (i.e., input data) and an intercept of 1 as input. The output of this computational unit can be:
[0212] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer, and the activation function can be the sigmoid function. A neural network is a network formed by connecting multiple of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.
[0213] (2) Natural Language Processing (NLP)
[0214] Natural language is human language, and Natural Language Processing (NLP) is the processing of human language. NLP is a systematic process of analyzing, understanding, and extracting information from text data in an intelligent and efficient manner. By using NLP and its components, we can manage very large amounts of text data, perform numerous automated tasks, and solve a wide variety of problems, such as automatic summarization, machine translation (MT), named entity recognition (NER), relation extraction (RE), information extraction (IE), sentiment analysis, speech recognition, question answering systems, and topic segmentation, among others.
[0215] (3) Pre-trained language model
[0216] A pre-trained language model is a natural language sequence encoder that encodes each word in a natural language sequence into a vector representation for prediction tasks. Its training consists of two phases. In the pre-training phase, the model is trained on a large-scale unsupervised text environment to learn word representations. In the fine-tuning phase, the model is initialized using the parameters learned in the pre-training phase and then trained on downstream tasks such as text classification and sequence labeling with fewer steps, successfully transferring the semantic information obtained in pre-training to these downstream tasks.
[0217] (4) Autoregressive language model
[0218] Autoregressive language models are models that can predict the next word that might follow (e.g., "good") based on a given context (e.g., "the phone is good"). Typically, these models predict the word in the context on the right given the preceding text on the left, but they can also predict a word in the middle given the context on both the left and right sides.
[0219] (5) Large Language Model (LLM): A large language model is a natural language processing model trained on large-scale data, typically with billions or tens of billions of parameters. These models learn the general features of language by studying a large amount of text data during the pre-training stage, and can then be fine-tuned on downstream tasks to adapt to the needs of specific tasks.
[0220] (6) token: refers to the smallest unit in the text. Typically, a token can be a word, number, punctuation mark, single letter, or any single element that can be used for text analysis.
[0221] (7) Backpropagation algorithm
[0222] Convolutional neural networks can employ backpropagation (BP) to correct the parameters in the initial super-resolution model during training, thereby reducing the reconstruction error loss. Specifically, forward propagation of the input signal to the output generates an error loss; this error loss information is then propagated back to update the parameters in the initial super-resolution model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining the optimal parameters of the super-resolution model, such as the weight matrix.
[0223] (8) Loss Function
[0224] In training a deep neural network, to ensure the output closely approximates the desired predicted value, we compare the network's prediction with the target value. Based on the difference, we update the weight vector of each layer (usually pre-configuring parameters before the initial update). For example, if the prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network predicts the target value or a value very close to it. Therefore, we need to predefine "how to compare the difference between the predicted and target values," which is the loss function or objective function. These are important equations used to measure the difference between the predicted and target values. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and training the deep neural network becomes a process of minimizing this loss.
[0225] Currently, large models are often deployed on the edge, and the built-in large models on the edge are used first during inference. However, due to the low computing power of the edge, cloud-based models are needed to assist in inference. For example, the model can be split, with the parts of the model that do not require much computing power inferenced on the edge, and the parts of the model that require much computing power inferenced on the cloud. Specifically, the edge performs the inference process related to the shallow part of the model, and the cloud performs the inference process related to the deep part of the model.
[0226] However, this leads to frequent data transfers between the edge and the cloud, resulting in high inference latency and high costs.
[0227] To address the aforementioned problems, embodiments of this application provide a data processing method. The data processing method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0228] Referring to Figure 7, which is a flowchart of a data processing method provided in an embodiment of this application, as shown in Figure 7, the data processing method provided in an embodiment of this application may include steps 701 to 703, which will be described in detail below.
[0229] 701. Receive a first prompt sent by the second device, wherein the first prompt is obtained based on the input request.
[0230] The first device can receive input requests, such as processing a long text. After receiving the input request, it can be converted into a prompt that the large model can process. The essence of the prompt is to unify the downstream tasks into pre-trained tasks and convert the data of the downstream tasks into natural language using a specific template.
[0231] In one possible implementation, the first device is an end-side device, and the second device is a cloud-side server.
[0232] In one possible implementation, the first device is an end-side device, and the second device is an edge-side server.
[0233] In one possible implementation, the first device is an edge-side device, and the second device is a cloud-side server.
[0234] 702. Based on the first prompt, a second prompt is obtained; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated in the first prompt.
[0235] The second prompt includes the semantics indicated in the first prompt. This can be understood as the second prompt and the first prompt having a high degree of semantic similarity; both describe the same semantic information, but the former is shorter than the latter. The semantics can be directly indicative (e.g., described through natural language) or indirectly indicative (e.g., indicated through vector representation). The semantics indicated by vector representation can be determined by a specific task network. Of course, the second prompt may not include semantics unrelated to the generation of a response to the input request in the first prompt; that is, the second prompt includes the key semantics indicated in the first prompt (i.e., semantics related to the generation of a response to the input request).
[0236] The idea behind this application is to process the first prompt sent from a device with low computing power and convert it into a shorter second prompt. In order to ensure the calculation accuracy of the subsequent model, the second prompt still contains the semantics of the first prompt. Thus, the edge model only needs to process the shorter second prompt. In addition, processing the shorter prompt can also reduce the size of the output result. Therefore, while ensuring the accuracy of the result, the computational overhead of the edge model in processing the prompt can be reduced, thereby reducing inference latency.
[0237] The second device performs semantic-preserving compression on the prompts from the first device. Since the first device processes the compressed prompts, this significantly reduces the computational and time overhead required for processing the prompts using a machine learning model, especially for devices with lower data processing capabilities, while maintaining processing accuracy (the compression is semantic-preserving). Furthermore, compared to the second device directly processing the prompts sent by the first device, the computational resources on the second device are often more expensive than those on the first device. The process of processing prompts to obtain responses to input requests requires numerous iterations and more computational resources than simply compressing the prompts. Therefore, in this embodiment, using the second device for prompt compression while the first device performs the response based on the prompts reduces the computational overhead on the second device.
[0238] In one possible implementation, the first prompt includes the input request, the request for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the request for the output, and the context information.
[0239] A prompt can include multiple parts, including, for example, an input request, which can be user input information, such as a question. A prompt can also include contextual information, such as historical input information and output when the question is multi-turn, or environmental information for generating the result. A prompt can also include conditions that the output needs to meet, also known as constraints on the output. Of course, a prompt can also include other types of information, depending on the prompt template used to generate the prompt. The three examples above can also overlap with each other; for example, an input request can also contain some requirements for the output.
[0240] In this embodiment of the application, when the second device compresses the first prompt, it can compress one or more of the above information. For example, it can compress only all or part of the input request, while keeping other information consistent with the first information. For example, it can compress only the input request and context information, while keeping other information consistent with the first prompt.
[0241] In one possible implementation, the client can receive a user request and determine whether the cloud needs to optimize the prompt. For example, if the length is greater than a threshold, it can determine that the cloud needs to optimize the prompt and then send the prompt to be optimized to the cloud.
[0242] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
[0243] Here, "summarizing" can be understood as using shorter language to summarize the content of natural language, or it can be called a summary.
[0244] The first natural language description can be all or part of the first prompt.
[0245] For example, a language model can be used to summarize the first natural language description by constructing a prompt, and this second prompt can also be called a hard prompt.
[0246] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a vector representation of the first natural language description.
[0247] For example, a language model can be used to extract features from the first natural language description by constructing a prompt, and this second prompt can also be called a soft prompt.
[0248] In one possible implementation, the first prompt includes multiple segments of natural language description, and the second prompt includes a generalized description or vector representation obtained by processing each of the segments.
[0249] In other words, each segment in the first prompt can be processed to obtain a general description or vector representation of each segment, and then fused (e.g., concatenated) to obtain the second prompt. This is equivalent to preserving the semantics of each segment. Compared to summarizing or extracting features from the whole, summarizing or extracting features from segments and then fusing them can preserve more complete semantics.
[0250] In one possible implementation, a third prompt can be constructed based on the first prompt, the third prompt indicating that each segment of the multiple natural language descriptions obtained from the first prompt should be processed; based on the third prompt, a general description or vector representation of each segment can be obtained through a machine learning model; and the second prompt can be obtained by concatenating multiple general descriptions or vector representations.
[0251] In one possible implementation, the first prompt can be split into multiple fragments. For example, it can be split according to the prompt's template and structure, or according to the token's index, such as splitting it into fragments of 1,000 tokens each.
[0252] Referring to Figure 8, which illustrates a method for processing prompt fragments, multiple generated soft prompts can be concatenated directly or concatenated according to a certain template format, allowing for the addition of additional privacy data on the client side.
[0253] The following is an example of optimizing a prompt:
[0254] The first prompt can be optimized using machine learning models. These models can be either autoregressive causal language models or conditional generation models. Causal language modeling involves multiple inference steps on the cloud side, focusing on generating text sequences based on a given context. In this approach, the model attempts to predict the next word in a given context, typically including all words preceding the current word. This model follows the causal principle, meaning the current word is only influenced by the words preceding it, not by those following it. Conditional generation, on the other hand, involves only one inference step, focusing on generating text sequences that satisfy specific conditions or constraints. In this approach, the model generates conditional outputs based on a given input (which could be text, an image, etc.). Unlike causal language modeling, conditional generation focuses not only on the coherence of the given context but also on meeting predetermined task requirements.
[0255] In one possible implementation, the first device is used to obtain a response to the input request based on the second prompt using a first machine learning model, and the second device is specifically used to obtain a second prompt based on the first prompt using a second machine learning model.
[0256] The first machine learning model is obtained by compressing or knowledge distilling the second machine learning model.
[0257] By compression or knowledge distillation, the first machine learning model can be made smaller in scale than the second machine learning model while having similar data processing capabilities.
[0258] In one possible implementation, the first machine learning model and the second machine learning model have the same training task during training.
[0259] For example, the training task is to fit the task output, or to fit the compressed prompt (that is, to use the compressed prompt as the task itself).
[0260] In one possible implementation, obtaining the second prompt based on the first prompt includes: compressing the first natural language description in the first prompt to obtain a second vector representation; adjusting the dimensions of the second vector representation to obtain the first vector representation, wherein the second prompt includes the first vector representation.
[0261] Because the data processing capability of the first device is less than that of the second device, the scale of the model (first machine learning model) deployed on the first device is often smaller than that of the model (second machine learning model) deployed on the second device. For models of different scales, the supported dimensions of the vector representation of the input (e.g., the dimension of an embedded vector of the input) are often different. Therefore, the dimension of the vector representation obtained by the second device through the second machine learning model may be different from the dimension of the vector representation of the input supported by the first machine learning model on the first device. In this embodiment, a dimension adjustment module (also called a dimension adapter) can be deployed on the second device or the first device. This dimension adjustment module can adjust the dimension of the vector representation obtained by the second machine learning model to the dimension of the vector representation of the input supported by the first machine learning model. For example, when the dimension adjustment module is deployed on the second device, the second device can compress the first prompt through the second machine learning model to obtain a second vector representation. Then, the second device can adjust the dimension of the second vector representation through the dimension adjustment module to obtain a second prompt containing the dimension-adjusted vector representation (first vector representation). After that, the second device can send the second prompt containing the dimension-adjusted vector representation (first vector representation) to the first device, and the first device can process the second prompt through the first machine learning model.
[0262] 703. Send the second prompt to the second device.
[0263] For example, referring to Figures 9 and 10, Figure 9 shows an exemplary process of a device being online and offline, and Figure 10 shows an exemplary process of a device being online.
[0264] Online includes:
[0265] 1. The client receives user requests;
[0266] 2. The predictor determines whether cloud-assisted terminals are needed;
[0267] 3. Perform edge-side prefix matching synchronously and reuse historical shared prefixes;
[0268] 4. Optimize the prompt sent to the cloud and compress the key-value cache;
[0269] 5. Lower end side;
[0270] 6. Edge-side inference based on optimized refine prompt;
[0271] The main offline steps include:
[0272] On the client side: It is triggered periodically to send the shared prefix and System Prompt to the cloud for optimization and updates. The cloud side returns the result, and the client side updates the KV Cache based on the cloud side's prompt.
[0273] Referring to Figure 11, which is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of this application, as shown in Figure 11, the data processing apparatus 1100 provided in this embodiment includes:
[0274] The transceiver module 1101 is used to receive a first prompt sent by the second device, wherein the first prompt is obtained based on the input request;
[0275] The prompt compression module 1102 is used to obtain a second prompt based on the first prompt; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated in the first prompt;
[0276] The transceiver module 1101 is further configured to send the second prompt to the second device; wherein the data processing capability of the first device is greater than that of the second device.
[0277] In one possible implementation, the first prompt includes multiple prompt segments obtained by segmentation, and the second prompt includes a compressed result obtained by compressing each of the multiple prompt segments.
[0278] In one possible implementation, the prompt compression module is specifically used for:
[0279] Based on the first prompt, a third prompt is constructed, wherein the third prompt indicates how to process each of the multiple prompt segments obtained from the division of the first prompt;
[0280] Based on the third prompt, a language model is used to obtain the compression result of each prompt fragment;
[0281] The second prompt is obtained by fusing multiple compression results.
[0282] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
[0283] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description.
[0284] In one possible implementation, the prompt compression module is specifically used for:
[0285] The first natural language description in the first prompt is compressed to obtain a second vector representation;
[0286] The device further includes:
[0287] The dimension adjustment module is used to adjust the dimensions of the second vector representation to obtain the first vector representation, and the second prompt includes the first vector representation.
[0288] In one possible implementation, the processing module is specifically used for:
[0289] The first device is an edge device, and the second device is a cloud-side server; or,
[0290] The first device is an endpoint device, and the second device is an edge-side server; or,
[0291] The first device is an edge device, and the second device is a cloud server.
[0292] In one possible implementation, the data processing capability is computing power.
[0293] In one possible implementation,
[0294] The first prompt includes the input request, the requirement for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the requirement for the output, and the context information.
[0295] This application embodiment also provides a data processing apparatus, applied to a second device, the apparatus comprising:
[0296] The transceiver module is used to send a first prompt to the second device, which is obtained based on the input request;
[0297] Receive a second prompt sent by the second device according to the first prompt, wherein the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt;
[0298] The model inference module is used to obtain a response to the input request based on the second prompt and through the first machine learning model.
[0299] In one possible implementation, the input request includes privacy information; the first prompt does not include the privacy information, and the first device is further configured to integrate the privacy information into the second prompt.
[0300] In one possible implementation, the first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; the apparatus further includes:
[0301] The dimension adjustment module is used to adjust the dimension of the first vector representation in the second prompt to obtain the adjusted second prompt.
[0302] The model inference module is specifically used for:
[0303] Based on the adjusted second prompt, a response to the input request is obtained through the first machine learning model.
[0304] The following describes an execution device provided in an embodiment of this application. Please refer to Figure 12, which is a schematic diagram of the structure of an execution device provided in an embodiment of this application. The execution device 1200 can specifically be a virtual reality (VR) device, a mobile phone, a tablet, a laptop, a smart wearable device, a monitoring data processing device, or a server, etc., and is not limited here. Specifically, the execution device 1200 includes: a receiver 1201, a transmitter 1202, a processor 1203, and a memory 1204 (the number of processors 1203 in the execution device 1200 can be one or more; Figure 12 shows one processor as an example). The processor 1203 may include an application processor 12031 and a communication processor 12032. In some embodiments of this application, the receiver 1201, transmitter 1202, processor 1203, and memory 1204 can be connected via a bus or other means.
[0305] Memory 1204 may include read-only memory and random access memory, and provides instructions and data to processor 1203. A portion of memory 1204 may also include non-volatile random access memory (NVRAM). Memory 1204 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0306] Processor 1203 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses in the diagram are referred to as the bus system.
[0307] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1203. The processor 1203 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuits in the hardware of the processor 1203 or by instructions in software form. The processor 1203 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1203 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1204. Processor 1203 reads the information from memory 1204 and, in conjunction with its hardware, completes the steps involved in the model inference process described above.
[0308] Receiver 1201 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1202 can be used to output digital or character information through the first interface; transmitter 1202 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1202 may also include a display device such as a display screen.
[0309] This application embodiment also provides a server device. Please refer to Figure 13. Figure 13 is a schematic diagram of a server structure provided in this application embodiment. Specifically, the server 1300 is implemented by one or more servers. The server 1300 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1313 (e.g., one or more processors) and memory 1332, and one or more storage media 1330 (e.g., one or more mass storage devices) for storing application programs 1342 or data 1344. The memory 1332 and storage media 1330 can be temporary or persistent storage. The program stored in the storage media 1330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the CPU 1313 may be configured to communicate with the storage media 1330 and execute the series of instruction operations in the storage media 1330 on the server 1300.
[0310] Server 1300 may also include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input / output interfaces 1358; or, one or more operating systems 1341, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0311] In this embodiment, the central processing unit 1313 is used to execute the data processing method described in the above embodiment.
[0312] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0313] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.
[0314] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the data processing method described in the above embodiments, or to cause the chip within the training device to execute the data processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).
[0315] Specifically, please refer to Figure 14, which is a schematic diagram of a chip structure provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1400. The NPU 1400 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1403, which is controlled by the controller 1404 to extract matrix data from the memory and perform multiplication operations.
[0316] In some implementations, the arithmetic circuit 1403 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1403 is a two-dimensional pulsating array. The arithmetic circuit 1403 can also be a one-dimensional pulsating array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1403 is a general-purpose matrix processor.
[0317] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1402 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1401 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is stored in the accumulator 1408.
[0318] Unified memory 1406 is used to store input and output data. Weight data is directly transferred to weight memory 1402 via Direct Memory Access Controller (DMAC) 1405. Input data is also transferred to unified memory 1406 via DMAC.
[0319] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1409.
[0320] The Bus Interface Unit (BIU) 1410 is used by the instruction fetch memory 1409 to fetch instructions from external memory, and also by the memory access controller 1405 to fetch the original data of the input matrix A or the weight matrix B from external memory.
[0321] The DMAC is mainly used to move input data from external memory DDR to unified memory 1406, or to weight data to weight memory 1402, or to input data to input memory 1401.
[0322] The vector computation unit 1407 includes multiple processing units that further process the output of the computation circuit 1403 when needed, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0323] In some implementations, the vector computation unit 1407 can store the processed output vector in the unified memory 1406. For example, the vector computation unit 1407 can apply a linear function, or a nonlinear function, to the output of the computation circuit 1403, such as performing linear interpolation on feature planes extracted from a convolutional layer, or, for example, accumulating a vector of values to generate activation values. In some implementations, the vector computation unit 1407 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as activation input to the computation circuit 1403, for example, for use in subsequent layers of the neural network.
[0324] The instruction fetch buffer 1409 connected to the controller 1404 is used to store the instructions used by the controller 1404;
[0325] Unified memory 1406, input memory 1401, weighted memory 1402, and instruction fetch memory 1409 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.
[0326] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.
[0327] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0328] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0329] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0330] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A data processing method, characterized in that, Applied to a first device, the method includes: Receive a first prompt sent by the second device, the first prompt being obtained based on the input request; Based on the first prompt, a second prompt is obtained; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt; Send the second prompt to the second device; wherein the data processing capability of the first device is greater than that of the second device.
2. The method according to claim 1, characterized in that, The first prompt includes multiple prompt segments obtained by segmentation, and the second prompt includes a compression result obtained by compressing each of the multiple prompt segments.
3. The method according to claim 1, characterized in that, The step of obtaining the second prompt based on the first prompt includes: Based on the first prompt, a third prompt is constructed, wherein the third prompt indicates how to process each of the multiple prompt segments obtained from the division of the first prompt; Based on the third prompt, a language model is used to obtain the compression result of each prompt fragment; The second prompt is obtained by fusing multiple compression results.
4. The method according to any one of claims 1 to 3, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
5. The method according to any one of claims 1 to 4, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description.
6. The method according to claim 5, characterized in that, The step of obtaining the second prompt based on the first prompt includes: compressing the first natural language description in the first prompt to obtain a second vector representation; The second vector representation is dimensionally adjusted to obtain the first vector representation, and the second prompt includes the first vector representation.
7. The method according to any one of claims 1 to 5, characterized in that, The first device is an edge device, and the second device is a cloud-side server; or, The first device is an end-side device, and the second device is an edge-side server; or, The first device is an edge device, and the second device is a cloud server.
8. The method according to any one of claims 1 to 7, characterized in that, The data processing capability refers to computing power.
9. The method according to any one of claims 1 to 8, characterized in that, The first prompt includes the input request, the requirement for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the requirement for the output, and the context information.
10. A system, characterized in that, It includes a first device and a second device, the first device and the second device communicate with each other, and the data processing capability of the first device is greater than that of the second device; The first device is used to send a first prompt to the second device, wherein the first prompt is obtained based on an input request; The second device is used to obtain a second prompt based on the first prompt; The second prompt is shorter than the first prompt, and the second prompt contains the semantics indicated by the first prompt; The second device is used to send the second prompt to the second device; The first device is used to obtain a response to the input request based on the second prompt and through a first machine learning model.
11. The system according to claim 10, characterized in that, The second device is specifically used to obtain a second prompt based on the first prompt through a second machine learning model; The first machine learning model is obtained by compressing or knowledge distilling the second machine learning model.
12. The system according to claim 10 or 11, characterized in that, The first machine learning model and the second machine learning model have the same training task during training.
13. The system according to any one of claims 10 to 12, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; The first device is further configured to adjust the dimensions of the first vector representation in the second prompt to obtain the adjusted second prompt; The first device is specifically used to obtain a response to the input request based on the adjusted second prompt and through a first machine learning model.
14. A data processing method, characterized in that, Applied to a second device, the method includes: Send a first prompt to the first device, the first prompt being obtained based on the input request; Receive a second prompt sent by the first device according to the first prompt, wherein the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt; Based on the second prompt, a response to the input request is obtained through the first machine learning model; wherein, the data processing capability of the first device is greater than that of the second device.
15. The method according to claim 14, characterized in that, The input request contains privacy information; the first prompt does not contain the privacy information, and the first device is further configured to integrate the privacy information into the second prompt.
16. The method according to claim 14 or 15, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; the method further includes: The dimensions of the first vector representation in the second prompt are adjusted to obtain the adjusted second prompt. The step of obtaining a response to the input request based on the second prompt and through the first machine learning model includes: Based on the adjusted second prompt, a response to the input request is obtained through the first machine learning model.
17. A data processing apparatus, characterized in that, Applied to a first device, the device includes: The transceiver module is used to receive a first prompt sent by the second device, which is obtained based on the input request; A prompt compression module is used to obtain a second prompt based on the first prompt; the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated in the first prompt; The transceiver module is further configured to send the second prompt to the second device; wherein the data processing capability of the first device is greater than that of the second device.
18. The apparatus according to claim 17, characterized in that, The first prompt includes multiple prompt segments obtained by segmentation, and the second prompt includes a compression result obtained by compressing each of the multiple prompt segments.
19. The apparatus according to claim 17, characterized in that, The prompt compression module is specifically used for: Based on the first prompt, a third prompt is constructed, wherein the third prompt indicates how to process each of the multiple prompt segments obtained from the division of the first prompt; Based on the third prompt, a language model is used to obtain the compression result of each prompt fragment; The second prompt is obtained by fusing multiple compression results.
20. The apparatus according to any one of claims 17 to 19, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a second natural language description, wherein the second natural language description is a summary description of the first natural language description.
21. The apparatus according to any one of claims 17 to 20, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description.
22. The apparatus according to any one of claims 17 to 21, characterized in that, The prompt compression module is specifically used for: The first natural language description in the first prompt is compressed to obtain a second vector representation; The device further includes: The dimension adjustment module is used to adjust the dimensions of the second vector representation to obtain the first vector representation, and the second prompt includes the first vector representation.
23. The apparatus according to any one of claims 17 to 22, characterized in that, The processing module is specifically used for: The first device is an edge device, and the second device is a cloud-side server; or, The first device is an end-side device, and the second device is an edge-side server; or, The first device is an edge device, and the second device is a cloud server.
24. The apparatus according to any one of claims 17 to 23, characterized in that, The data processing capability refers to computing power.
25. The apparatus according to any one of claims 17 to 24, characterized in that, The first prompt includes the input request, the requirement for a response to the output, and the context information that needs to be referenced; the second prompt is obtained by compressing one or more of the input request, the requirement for the output, and the context information.
26. A data processing apparatus, characterized in that, Applied to a second device, the method includes: The transceiver module is used to send a first prompt to the second device, which is obtained based on the input request; Receive a second prompt sent by the second device according to the first prompt, wherein the length of the second prompt is less than that of the first prompt, and the second prompt contains the semantics indicated by the first prompt; The model inference module is used to obtain a response to the input request based on the second prompt and through the first machine learning model.
27. The apparatus according to claim 26, characterized in that, The input request contains privacy information; the first prompt does not contain the privacy information, and the first device is further configured to integrate the privacy information into the second prompt.
28. The apparatus according to claim 26 or 27, characterized in that, The first prompt includes a first natural language description, and the second prompt includes a first vector representation of the first natural language description; the method further includes: The dimension adjustment module is used to adjust the dimension of the first vector representation in the second prompt to obtain the adjusted second prompt. The model inference module is specifically used for: Based on the adjusted second prompt, a response to the input request is obtained through the first machine learning model.
29. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions, which, when executed by one or more computers, cause the one or more computers to perform the operation of the method according to any one of claims 1-9, 14-16.
30. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1-9, 14-16.
31. A system, characterized in that, It includes at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other. The at least one memory is used to store code; The at least one processor is used to execute the code to perform the method as described in any one of claims 1-9, 14-16.
32. A chip, characterized in that, It includes at least one processing unit and an interface circuit, wherein the interface circuit is used to provide program instructions or data to the at least one processing unit, and the at least one processing unit is used to execute the program instructions to implement the method of any one of claims 1-9 and 14-16.