Data processing method and related equipment
By identifying and compressing non-critical information in long documents while retaining critical information, the problem of inference cost and latency when large language models process long documents is solved, achieving more efficient text processing.
Patent Information
- Application Number
- CN202411068848.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2026-02-10
AI Technical Summary
Large language models incur increased inference costs and computational latency when processing long input content. Existing technologies cannot effectively handle both critical and non-critical information in long documents, leading to performance degradation.
By identifying and compressing non-critical information in long documents while retaining critical information, compressed text blocks are generated, fused, and input into a large language model for inference.
It reduces the inference cost and computational latency of large language models while maintaining task performance, supports the processing of longer content, and dynamically adjusts the compression ratio to avoid information loss.
Smart Images

Figure CN121503632A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a data processing method and related equipment. Background Technology
[0002] With the development of artificial intelligence, natural language processing (NLP) technology has been widely applied in numerous scenarios, and the capabilities of large language models (LLMs) are receiving increasing attention. More and more users are demanding that large language models be able to accept longer input content in their actual business operations.
[0003] However, excessively long input content may increase the inference cost, computational latency, and performance degradation of large language models.
[0004] Therefore, a solution to the above problems is urgently needed. Summary of the Invention
[0005] This application provides a data processing method and related equipment that can input longer content into a large language model at once, reducing inference costs and computational latency.
[0006] In a first aspect, embodiments of this application provide a data processing method, the method comprising: an electronic device acquiring first text; the electronic device dividing the first text into multiple text blocks, the multiple text blocks including a first text block and a second text block, the first text block being a text block containing key information, and the second text block being a text block containing non-key information; the electronic device compressing the second text block to generate a compressed second text block; the electronic device fusing the first text block and the compressed second text block to generate a second text; and the electronic device performing inference operations on the second text using a large language model.
[0007] The first text mentioned above may be, for example, long document 1 or long document 2 in the embodiment, and the second text mentioned above may be, for example, compressed document 1 or compressed document 2 in the embodiment.
[0008] By implementing the method provided in the first aspect, non-critical information (i.e. highly redundant information) in long documents can be identified, and only the content containing non-critical information can be compressed without compressing the content containing critical information. In this way, longer content can be input into a large language model at once, reducing inference costs and computational latency, and the performance of the task will not be significantly reduced due to the compression of document content.
[0009] In one possible implementation, the electronic device compresses the second text block by converting the second text block into a latent vector.
[0010] In this way, text blocks can be converted into low-dimensional numerical vectors that electronic devices can process, thereby compressing data and compressing non-critical information.
[0011] In one possible implementation, before the electronic device merges the first text block and the compressed second text block, the method further includes: the electronic device converting the first text block into a word embedding vector.
[0012] This allows text blocks to be converted into numerical vectors that electronic devices can process without compressing the data, thus preserving key information.
[0013] In one possible implementation, the electronic device merges the first text block and the compressed second text block, specifically by concatenating the word embedding vector and the latent vector in the order of the first and second text blocks in the first text.
[0014] In one possible implementation, where the first text is code text, the key information includes one or more of the function name and parameter names.
[0015] The code text mentioned above may be, for example, long document 1 in the embodiment (e.g., tool description document).
[0016] In one possible implementation, when the first text is the text to be summarized, the text to be summarized includes a main title, subheadings, and quotes, and the key information includes one or more of the main title, subheadings, and quotes.
[0017] The text to be summarized can be, for example, long document 2 in the embodiment.
[0018] In one possible implementation, the method further includes: an electronic device training a large language model using a training sample set, wherein the training sample set includes multiple texts, each converted into an input vector, and multiple texts, each corresponding to a reliable inference result, wherein the input vector corresponding to a text includes a latent vector converted from non-key information in the text and a word embedding vector converted from key information.
[0019] This allows large language models to understand both natural language and compressed language simultaneously.
[0020] In one possible implementation, before the electronic device compresses the second text block, the method further includes: the electronic device determining the compression ratio of non-critical information based on the length of the first text and the maximum input length supported by the large language model.
[0021] In other words, electronic devices can compress the length of the first text to less than or equal to the maximum input length supported by the large language model, thereby speeding up the inference speed of the large language model.
[0022] In one possible implementation, before the electronic device segments the first text into multiple text blocks, the method further includes: the electronic device determining key information based on prior knowledge; or, the electronic device calculating the perplexity of the first information, and when the perplexity is higher than a first threshold, the electronic device determining the first information as key information.
[0023] In other words, electronic devices can determine which information in the first text is critical and which is non-critical in a variety of ways.
[0024] In one possible implementation, the method further includes: the electronic device receiving a user request; and in response to the user request, the electronic device acquiring first text.
[0025] The aforementioned user request can be used to instruct an electronic device to perform a corresponding task (such as a tool invocation task, a summary task, a question-and-answer task, etc.). That is to say, after receiving the aforementioned user request, the electronic device can, for example, retrieve the first text corresponding to the user request from a knowledge base, and then perform the task instructed by the aforementioned user request based on the aforementioned first text.
[0026] In a second aspect, embodiments of this application provide a chip system, including: a processor coupled to a memory, the memory being used to store programs or instructions, and when the program or instructions are executed by the processor, causing the chip system to perform the method described in any possible implementation of the first aspect above.
[0027] Thirdly, embodiments of this application provide an electronic device including one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, the computer program code including computer instructions, which, when the one or more processors execute the computer instructions, cause the electronic device to perform the method described in any possible implementation of the first aspect above.
[0028] Fourthly, embodiments of this application provide a computer storage medium storing a computer program, the computer program including program instructions that, when executed on an electronic device, cause the electronic device to perform the method described in any possible implementation of the first aspect above.
[0029] Fifthly, embodiments of this application provide a computer program product that, when run on a computer, causes the computer to perform the method described in any possible implementation of the first aspect above. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application;
[0031] Figure 2 This is a schematic diagram of the system architecture involved in a data processing method provided in an embodiment of this application;
[0032] Figure 3 This is a flowchart illustrating a data processing method provided in an embodiment of this application;
[0033] Figure 4 This is a schematic diagram of a long document provided in an embodiment of this application;
[0034] Figure 5 This is a flowchart illustrating another data processing method provided in an embodiment of this application;
[0035] Figure 6 This is a schematic diagram of another long document provided in an embodiment of this application;
[0036] Figure 7 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application;
[0037] Figure 8 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0039] It should be understood that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0040] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0041] For ease of understanding, some related concepts involved in the embodiments of this application are explained below.
[0042] 1. Large Language Model
[0043] Large language models refer to deep learning models trained on large amounts of text data that can generate natural language text or understand the meaning of natural language text.
[0044] Large language models can handle a variety of natural language tasks, such as text classification (i.e., classifying input text into one or more predefined categories by analyzing and learning), question answering (i.e., answering natural language questions posed by users), document summarization (i.e., automatically extracting key information from text to generate document summaries), and text generation (i.e., generating new text using previously learned patterns and structures).
[0045] Large language models can be pre-trained and fine-tuned.
[0046] In the pre-training phase, large language models can be trained on large-scale general text data to learn the basic structure of language and various common sense.
[0047] In the fine-tuning phase, the large language model can be further trained on smaller, more specific datasets, which are usually designed for a specific task or domain (such as medical texts, legal texts, specific dialogue data, etc.). Fine-tuning allows the large language model to better understand and generate language for this specific domain, thereby better performing specific tasks.
[0048] 2. Prompt Engineering
[0049] Hint engineering (also known as instruction engineering) refers to designing and optimizing the instructions input to artificial intelligence models (such as large language models) to ensure that the model generates the expected output. By constructing accurate and detailed hints, the model's understanding and response capabilities can be improved, thereby achieving efficient human-computer interaction.
[0050] Prompt engineering typically requires providing background information, a clear problem or task, details, and constraints. Background information can refer to the necessary context information that enables the model to understand the background of the problem; a clear problem or task can refer to a clear description of the specific task or question that the user expects the model to complete; details and constraints can refer to specific details, constraints, and the expected answer format.
[0051] 3. Reasoning
[0052] 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.
[0053] Common reasoning tasks supported by large language models include mathematical reasoning, common sense reasoning, symbolic manipulation reasoning, logical reasoning, and multimodal reasoning.
[0054] 4. Text segmentation
[0055] Text chunking is a key technique in natural language processing, which involves dividing long texts into smaller, more easily processed segments (or text chunks).
[0056] Properly using text chunking techniques can not only improve the overall quality and accessibility of text, but also prevent problems caused by information loss or improper chunking.
[0057] Currently, the mainstream text segmentation strategies include the following: character-based segmentation (which divides text into blocks according to character sequences, usually setting a fixed length, such as 500 or 1000 characters per block. This method is relatively simple, but may not capture the semantic structure of the text well), sentence-based segmentation (which divides text into blocks according to sentences, with each sentence as a block. This method helps maintain semantic integrity), and paragraph-based segmentation (which divides text into blocks according to paragraphs, with each paragraph as a block).
[0058] 5. Vocabulary
[0059] Vocabulary (or words) is the sum of all or a specific range of words and / or phrases in a language (such as Chinese, English, etc.). "Word" can refer to either single words or phrases. These words and phrases can be in Chinese characters, English, or other language forms.
[0060] 6. Word vectors
[0061] A word vector, or word embedding vector, is a numerical vector that maps the feature information of a word to its vector. There is a one-to-one correspondence between words and word vectors.
[0062] Word embedding is a general term for language modeling and representation learning techniques in natural language processing. It can map words or phrases in a vocabulary onto vectors composed of real numbers.
[0063] 7. Word vector library
[0064] A word vector library is a <word:vector> mapping relation library pre-trained from a large amount of corpus. It includes words and their corresponding word vectors and is used to convert (or map) words in text into numerical vectors that can be processed by computers.
[0065] 8. Latent Vectors
[0066] Latent vectors (or implicit vectors, compressed latent vectors) are a type of compressed and abstract feature representation used to represent complex data as low-dimensional real vectors. They can capture the latent structural and semantic information in the original high-dimensional data, helping models understand and process high-dimensional sparse data.
[0067] 9. Loss Function
[0068] In training deep neural networks, the goal is to make the network's output as close as possible to the desired predicted value. This is achieved by comparing the network's current prediction with the target value and updating the weight vector of each layer based on the difference. For example, if the network's prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network can predict the target value or a value very close to it. Therefore, it's necessary to predefine "how to compare the difference between the predicted and target values," which is the basis of 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, so training a deep neural network becomes a process of minimizing this loss.
[0069] Hint engineering is the most critical factor determining the quality of output content from large language models. In recent years, technologies such as thought chaining, context learning, and retrieval-enhanced generation have emerged. More and more users' actual business needs also require large language models to accept longer input content, such as multi-document summarization and long document tool calls.
[0070] As prompts become longer, the inference cost of large language models may increase, leading to computational latency and performance degradation. Furthermore, large language models typically suffer from limited context windows, making it impossible to output excessively long texts at once.
[0071] Currently, context compression technology can compress a context sequence into an implicit vector sequence of a preset length, thereby accelerating the inference speed of large language models by shortening the input length.
[0072] See Figure 1 , Figure 1 The context compression technique illustrated uses a long document tool invocation task as an example. In this technique, the entire document (e.g., a tool document) is typically treated as a whole, and the entire document can correspond to a set of summary vector blocks. These summary vector blocks can be used to indicate the compression ratio of the document, and the length of the compressed vector of the entire document is the same as the length of the summary vector block. A specially trained compression model (e.g., ...) is used. Figure 1 The tool document compression model shown compresses the entire document, resulting in a fixed-length (i.e., the preset length during model training) vectorized document. This vectorized document can be used along with the user request as a task result to generate the model (e.g., ...). Figure 1 The tool call command (shown) generates the model with input, and the task result generation model can output the corresponding response (i.e., the task result, for example) based on this input. Figure 1 (The tool call command shown).
[0073] It can be seen that, Figure 1 The context compression technique shown applies uniform compression to the content of a document. Since the input content of large language models in most practical applications contains noteworthy key information (e.g., function names and parameter names in long document tool calls; main headings, subheadings, keywords, and quotations in long document summarization and question-answering tasks), Figure 1 The context compression technique shown compresses both key and non-key content in the input uniformly, which introduces compression loss, loses key and detailed information, and may lead to incorrect inference results from the model, thus reducing task performance. In addition, the length of the compressed input is fixed, and it cannot flexibly handle variable-length input.
[0074] To address the aforementioned issues, this application provides a data processing method that can identify non-critical information (i.e., highly redundant information) in long documents, compress only the content containing non-critical information, and not compress the content containing critical information. This allows for the input of longer content into a large language model at once, reducing inference costs and computational latency, and preventing a significant performance degradation due to document content compression. Furthermore, it enables dynamic adjustment of the compression ratio, thereby alleviating the problem of inaccurate information or limited compression ratio caused by improper output vector sequence settings.
[0075] It should be noted that the data processing method provided in this application embodiment can be applied to terminal devices, and the terminal devices can be of various types. This application embodiment does not limit the specific type of terminal device. For example, the terminal device may include a mobile phone, as well as a tablet computer, desktop computer, laptop computer, handheld computer, smart screen, wearable device, augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, vehicle system, and may also include Internet of Things (IoT) devices; and so on.
[0076] By implementing the data processing method provided in the embodiments of this application, the length of the context can be reduced, and the long context can be compressed into a short context (i.e., a context less than or equal to the length that the large language model can support). When facing the large language model inference task deployed on terminal devices such as mobile phones, the length of the context that the large language model can support can be further increased, and the inference speed can be accelerated and the inference latency reduced.
[0077] The data processing method provided in this application can be applied to all large language model reasoning tasks with distinct key and non-key information, such as long document tool calls, long document summarization, long document question answering, multi-document summarization and question answering, video summarization, etc. It can also be applied to multimodal tasks (for example, it can realize the cross-understanding of images and text vectors).
[0078] The data processing method provided in this application embodiment can be executed independently by the terminal device or jointly by the terminal device and the server. This application embodiment does not limit this.
[0079] In one possible implementation, a user can input text data through a terminal device, and the terminal device can process the text data using the data processing method provided in this application embodiment, and present the processing result to the user.
[0080] In another possible implementation, the user can input text data through a terminal device, which can then send the text data to a server. The server can process the text data using the data processing method provided in this application embodiment and send the processing result back to the terminal device, which can then present the processing result to the user.
[0081] The system architecture involved in the data processing method provided in the embodiments of this application is described below.
[0082] Figure 2An exemplary system architecture related to the data processing method provided in the embodiments of this application is illustrated.
[0083] like Figure 2 As shown, the system architecture may include: a document compression model and a task result generation model.
[0084] Document compression models can be used to divide a document into a series of text blocks, which may include: one or more text blocks containing key information, and one or more text blocks containing non-key information.
[0085] In some examples, the one or more text blocks containing key information mentioned above can be text blocks that maintain semantic integrity; that is, the content containing key information may not be segmented in a fine-grained manner. The content containing non-key information can be segmented in a fine-grained manner to generate the one or more text blocks containing non-key information mentioned above.
[0086] In some examples, the task of splitting a document into a series of text blocks may not be performed by the document compression model, but by other modules included in the system architecture, such as the module for document chunking. Figure 2 (Not shown in the image).
[0087] See Figure 2 For example, a document can be divided into multiple text blocks, such as text block T0, text block T1, text block T2, text block T3, and text block T4. Text block T2 and text block T4 can be text blocks containing key information, while text block T0, text block T1, and text block T3 can be text blocks containing non-key information.
[0088] In some examples, each text block containing non-critical information may correspond to a set of summary vector blocks, which can be used to indicate the compression ratio of the text block. The length of the compressed vector of the text block is the same as the length of the summary vector block. Multiple text blocks containing non-critical information may correspond to multiple sets of summary vector blocks.
[0089] Document compression models can also be used to compress documents in chunks. Specifically, after a document is divided into multiple text chunks, the document compression model can compress each text chunk separately, rather than compressing the entire document as a whole.
[0090] Document compression models can also be used for selective compression of documents. The document compression module can perform selective compression (or selective compression) during the block compression process, that is, it can selectively compress only certain blocks of text.
[0091] In this embodiment of the application, the document compression module may compress only text blocks containing non-critical information, and not compress text blocks containing critical information.
[0092] In some examples, document compression models can convert text blocks containing key information into raw word vectors. These word vectors can be a vector representation of the key information after the text has been segmented.
[0093] In some examples, document compression models can convert text blocks containing non-critical information into compressed latent vectors. Unlike intermediate latent vectors obtained by directly inputting natural language into a large language model, compressed latent vectors can be a vector representation of non-critical information after block segmentation. Characters within the same text block can be compressed to obtain a unique compressed latent vector.
[0094] Document compression models can also be used to fuse the results of selective compression (e.g., concatenation).
[0095] For example, see Figure 2 Text blocks T2 and T4, when input into the document compression model, can sequentially output vectorized text blocks Emb(T2) and Emb(T4). Similarly, text blocks T0, T1, and T3, when input into the document compression model, can sequentially output vectorized text blocks C0, C1, and C3. Furthermore, taking concatenation as an example of fusion, the document compression model can concatenate the original word vectors and the compressed latent vectors, that is, concatenate C0, C1, Emb(T2), C3, and Emb(T4) to generate... Figure 2 An example of a vectorized document.
[0096] In some examples, the task of fusing the results of selective compression described above may not be performed by the document compression model, but by other modules included in the system architecture, such as the module for fusing the results of selective compression. Figure 2 (Not shown in the image).
[0097] The task result generation model can be used to receive one or more documents (e.g., document 1, document 2, ..., document N) and user requests. These documents can be vectorized documents (i.e., compressed, cross-stitched content) that have been compressed using a document compression model, and can replace the original long document (i.e., the document before compression).
[0098] The task result generation model can also be used to generate task results (or inference results) based on one or more documents and user requests received above. That is, the one or more documents and user requests received above can be regarded as a prompt as input to the task result generation model, and the task results can be used as the output of the task result generation model.
[0099] It is easy to understand that the above task result generation model can be a large language model.
[0100] The system architecture may also include a model training module, which can be used to apply end-to-end supervision signals.
[0101] In some examples, the model training module can concatenate the compression process (i.e., the process by which the document compression model compresses documents) and the inference process (i.e., the process by which the task result generation model outputs task results based on the input) during the training phase, performing end-to-end supervised training. The training phase can include a pre-training phase and a fine-tuning phase.
[0102] In this embodiment, during the pre-training phase, the task result generation model can learn general compressed language understanding capabilities and language understanding capabilities in the cross-compressed embedding space (or cross-latent vector space). This ensures that the model possesses both general large-scale language model understanding capabilities and compressed embedding understanding capabilities; that is, it allows the model to understand both natural language and compressed language simultaneously. During the fine-tuning phase, selective compression can be introduced to perform targeted training and optimization for downstream long document tasks (such as long document tool invocation tasks, long document summarization tasks, etc.).
[0103] In some examples, the training sample set used when training a large language model may include multiple texts, each converted into an input vector, and the corresponding credible inference results (i.e., standard results) for each of these multiple texts. The input vector for one of these texts may include a compressed latent vector converted from non-key information in that text and a word embedding vector converted from key information. It is easy to understand that the above credible inference results are the inference results output by the already trained large language model.
[0104] In some examples, during the training process, the cross-entropy loss function can be used to measure the difference between the task results and the standard results.
[0105] It should be noted that the above Figure 2 The system architecture shown is merely exemplary and should not be construed as limiting this application.
[0106] Application Scenario 1: Long document tool calling task
[0107] Figure 3 The specific flow of a data processing method provided in an embodiment of this application is illustrated by way of example.
[0108] like Figure 3 As shown, this method can be applied to electronic devices, which can refer to terminal devices or servers. The specific steps of this method are described in detail below:
[0109] S301, The electronic device acquires a long document 1 to be processed, which provides information required when the execution tool invokes a task.
[0110] The aforementioned long document 1 can be a tool description document (or tool document), such as a description document for a function call application programming interface. The content of the aforementioned long document 1 may include information required to perform the tool call task.
[0111] Tool invocation is a fundamental capability of the large language model, which means that the large language model can call external functions or application programming interfaces. Before using the tool invocation capability of the large language model, some functions need to be defined and passed to the large language model. When the user inputs a question, the large language model needs to determine which function to use. If it needs to be called, it returns a message requesting the function to be called, which includes the information of the function to be called and the parameter information carried when calling the function. Finally, it can output the corresponding response information.
[0112] The tasks invoked by the aforementioned tools may include, but are not limited to: password reset, weather query, stock query, current affairs news retrieval, flight booking, and alarm clock setting.
[0113] Before performing step S301 above, the process may also include: the electronic device receiving a user request (e.g., "reset password", "check the weather in XX city", etc.), which is used to instruct the electronic device to perform the corresponding tool call task.
[0114] S302, the electronic device divides the long document 1 into multiple text blocks, including: one or more text blocks containing key information (such as parameter names, function names), and one or more text blocks containing non-key information.
[0115] In this embodiment of the application, the aforementioned long document 1 can be a document with a length greater than a preset length. The preset length can be determined based on the maximum input length that the large language model can support. The input length can be determined based on the number of texts and / or characters contained in the document.
[0116] The method for determining document length differs depending on the language of the document. For example, Chinese documents may be judged by the number of characters contained in the document, while English documents may be judged by the number of characters contained in the document.
[0117] It's easy to understand that if the document length exceeds the preset length, the document can be compressed so that the compressed document can be processed within the range of a large language model.
[0118] In this embodiment of the application, some technical means can be used to identify the highly redundant information in the long document 1, thereby determining which key information and which non-key information are contained in the long document 1.
[0119] Among them, the technical means for identifying highly redundant information may include, but are not limited to: prior knowledge checking and automatic selection of perplexity.
[0120] Prior knowledge checking refers to a technique that uses prior knowledge to determine whether certain recurring descriptive information in a document is highly redundant. For example, in a tool description document, function names and parameter names are generally considered key information. Therefore, the aforementioned prior knowledge can be used to directly determine that the function names and parameter names in the long document 1 are key information, while other parts are non-key information.
[0121] Automatic perplexity selection refers to a technique that identifies the most relevant information (i.e., key information) for a given task by calculating perplexity. In natural language processing, lower perplexity means less uncertainty in the information's contribution to large language model predictions, resulting in lower information density. In some examples, information with a perplexity below a certain preset threshold can be considered non-key information, while information with a perplexity above a certain preset threshold can be considered key information.
[0122] After determining which key information and which non-key information are contained in the long document 1, the long document 1 can be divided into multiple text blocks. These multiple text blocks may include: one or more text blocks containing key information (such as parameter names and function names), and one or more text blocks containing non-key information.
[0123] For example, see Figure 4 , Figure 4 The document shown can be the long document 1 mentioned above, where the bold characters can refer to key information (such as function names, parameter names, etc.), and the non-bold characters can refer to non-key information.
[0124] In some examples, the length of the segmented text blocks described above may not exceed the maximum input length that a large language model can support.
[0125] In this embodiment of the application, the content containing key information in the long document 1 may not be finely segmented to ensure the integrity of the key information. For example, for a function name or parameter name, the function name or parameter name can be treated as a whole text block without fine-grained segmentation, that is, a function name or parameter name will not be split into multiple text blocks.
[0126] In this embodiment of the application, the content of the long document 1 containing non-critical information can be segmented in a fine-grained manner.
[0127] In one possible implementation, the content containing non-critical information in long document 1 can be divided into multiple non-overlapping text blocks. For example, the length of each text block can be preset, and the content containing non-critical information in long document 1 can be divided into multiple non-overlapping text blocks according to the preset length. The preset length of the text blocks can be set according to actual needs. Taking a preset length of 512 characters as an example, if the characters in the non-critical information content are arranged in ascending order, then the first text block contains the 1st to the 512th characters of the non-critical information, the second text block contains the 513th to the 1024th characters of the non-critical information, and so on. It is easy to understand that dividing the content containing non-critical information in long document 1 into multiple non-overlapping text blocks ensures that there is no character overlap between the text blocks, thereby avoiding the problem of repeated processing of some characters or semantic overlap between different text blocks during subsequent processing.
[0128] In another possible implementation, the content containing non-critical information in long document 1 can be divided into multiple intersecting text blocks. For example, this can be done using a sliding window approach. Taking a sliding step of 128 characters and a preset text block length of 512 characters as an example, dividing the content into multiple intersecting text blocks with characters arranged in ascending order, the first text block contains characters 1 to 512 of the non-critical information, the second text block contains characters 129 to 640, and so on. The preset length and sliding step of the text blocks can be pre-set according to actual needs. It is easy to understand that dividing the content containing non-critical information in long document 1 into multiple intersecting text blocks allows for consideration of context between each text block, thus facilitating better extraction of semantic features from long document 1.
[0129] It should be noted that the embodiments of this application do not limit the implementation method of dividing the long document 1 into multiple text blocks, as long as the key information in the divided text blocks remains intact.
[0130] S303. The electronic device converts one or more text blocks containing key information into corresponding word embedding vectors, and converts one or more text blocks containing non-key information into corresponding compressed latent vectors.
[0131] In this embodiment of the application, after the long document 1 is divided into multiple text blocks, these multiple text blocks can be selectively compressed. For example, only text blocks containing non-critical information can be compressed, while text blocks containing critical information can be left uncompressed.
[0132] In one possible implementation, the text blocks containing key information are not compressed. Specifically, this can include converting each text block containing key information into a corresponding word embedding vector. These word embedding vectors can be generated based on vectors obtained from a word vector library.
[0133] In one possible implementation, compressing text blocks containing non-critical information may specifically include converting each text block containing non-critical information into a corresponding compressed latent vector. The compressed latent vector can be generated using various methods (such as singular value decomposition), and this application embodiment does not limit this method.
[0134] In some examples, before converting one or more text blocks containing non-critical information into corresponding compressed latent vectors, it may also include: determining the compression ratio of long document 1 (or the compression ratio of non-critical information).
[0135] The compression ratio mentioned above can refer to the ratio of the length of the data before compression to the length of the data after compression. For example, a compression ratio of 4 times can mean that the length of the data before compression is 4 times the length of the data after compression.
[0136] The compression ratio of the aforementioned long document 1 can be specified by the user or determined based on the long document 1 and the maximum input length supported by the large language model. This application embodiment does not limit this.
[0137] S304. The electronic device fuses the word embedding vector with the compressed latent vector to obtain compressed document 1.
[0138] In one possible implementation, the word embedding vectors and compressed latent vectors are fused. Specifically, this can include concatenating the word embedding vectors and compressed latent vectors. That is, concatenating all the word embedding vectors corresponding to key information with all the compressed latent vectors corresponding to non-key information.
[0139] For example, the word embedding vector and the compressed latent vector can be concatenated in the order of the text block corresponding to the compressed latent vector and the text block corresponding to the word embedding vector in the long document 1 mentioned above.
[0140] It is easy to understand that the compressed document 1 mentioned above is a vectorized document after fusing word embedding vectors and compressed latent vectors.
[0141] It should be noted that the above-mentioned "fusion" methods can include a variety of methods. The embodiments of this application only take splicing as an example of the above-mentioned "fusion" method, and should not constitute a limitation on this application.
[0142] S305. The electronic device generates task result 1 (e.g., tool call instruction) based on compressed document 1 and user request 1.
[0143] In this embodiment of the application, after generating compressed document 1, compressed document 1 and user request 1 can be input into the large language model, and the large language model can output task result 1 (e.g., tool call instruction) based on the input.
[0144] Among them, the aforementioned user request 1 (such as "reset password", "check the weather in XX city", etc.) can be used to instruct the electronic device to perform the corresponding tool call task.
[0145] By implementing Figure 3 The method provided in the illustrated embodiment can significantly shorten the length of user input content while retaining key information (such as function names and parameter names) in the large language model tool call task, compressing non-key information to prevent key information from being lost during compression. Through block compression, it can support dynamically variable length of the compressed context. In addition, by mixing the original word embedding vectors corresponding to key information and the compressed latent vectors corresponding to non-key information, natural language and compressed language are cross-input into the large language model, allowing the large language model to simultaneously understand the original word embedding vectors of natural language and the compressed information corresponding to the cross-latent vector space, thus supporting selective compression.
[0146] Compared to the baseline scheme of overall compression, Figure 3 The selective compression and cross compression methods provided in the illustrated embodiments achieve better compression results. Furthermore, under compression ratios of 4x to 16x, their performance (i.e., the accuracy of the output results) is on par with or even better than the baseline scheme that does not compress the direct input.
[0147] Application Scenario 2: Long document summarization, question answering, and other tasks.
[0148] Figure 5 The specific flow of another data processing method provided in the embodiments of this application is illustrated by way of example.
[0149] like Figure 5 As shown, this method can be applied to electronic devices, which can refer to terminal devices or servers. The specific steps of this method are described in detail below:
[0150] S501, The electronic device acquires a long document 2 to be processed, which provides information required for performing tasks such as summarizing and answering questions.
[0151] Among them, the long document 2 mentioned above can be a very long document from books, papers, web pages, etc., and the content of the long document 1 mentioned above can include information needed to perform tasks such as summarizing and answering questions.
[0152] Before performing step S501, the process may further include: the electronic device receiving a user request (e.g., "Please generate a summary based on the following content"), which instructs the electronic device to perform corresponding summary, question-and-answer, or other tasks.
[0153] S502, the electronic device divides the long document 2 into multiple text blocks, including: one or more text blocks containing key information (such as main headings, subheadings, quotations), and one or more text blocks containing non-key information.
[0154] In this embodiment of the application, the aforementioned long document 2 can be a document with a length greater than a preset length. The preset length can be determined based on the maximum input length that the large language model can support. The input length can be determined based on the number of texts and / or characters contained in the document.
[0155] The method for determining document length differs depending on the language of the document. For example, Chinese documents may be judged by the number of characters contained in the document, while English documents may be judged by the number of characters contained in the document.
[0156] It's easy to understand that if the document length exceeds the preset length, the document can be compressed so that the compressed document can be processed within the range of a large language model.
[0157] In this embodiment of the application, some technical means can be used to identify the highly redundant information in the long document 2, thereby determining which key information and which non-key information are contained in the long document 2.
[0158] The aforementioned technical means for identifying highly redundant information may include, but are not limited to, prior knowledge checking and automatic perplexity selection. For a description of prior knowledge checking and automatic perplexity selection, please refer to the aforementioned textual descriptions; they will not be repeated here.
[0159] After determining which key information and which non-key information are contained in the long document 2, the long document 2 can be divided into multiple text blocks. These multiple text blocks may include: one or more text blocks containing key information (such as main headings, subheadings, quotations, etc.) and one or more text blocks containing non-key information.
[0160] For example, see Figure 6 , Figure 6The document shown can be the long document 2 mentioned above, where the text in bold can refer to key information (such as main headings, subheadings, quotations, etc.), and the text in non-bold can refer to non-key information.
[0161] In some examples, the length of the segmented text blocks described above may not exceed the maximum input length that a large language model can support.
[0162] In this embodiment of the application, the content containing key information in the long document 2 may not be finely segmented to ensure the integrity of the key information. For example, for a title or quotation, the title or quotation can be treated as a whole as a text block without fine-grained segmentation, that is, a title or quotation will not be divided into multiple text blocks.
[0163] In this embodiment of the application, the content of the long document 2 containing non-critical information can be segmented in a fine-grained manner.
[0164] In one possible implementation, the content containing non-critical information in long document 2 can be divided into multiple non-overlapping text blocks. For example, the length of each text block can be preset, and the content containing non-critical information in long document 2 can be divided into multiple non-overlapping text blocks according to the preset length. The preset length of the text blocks can be set according to actual needs. Taking a preset length of 512 characters as an example, if the text in long document 2 is divided into multiple non-overlapping text blocks, and the characters in the non-critical information are arranged in ascending order, then the first text block contains the 1st to the 512th characters of the non-critical information, the second text block contains the 513th to the 1024th characters of the non-critical information, and so on. It is easy to understand that dividing the content containing non-critical information in long document 2 into multiple non-overlapping text blocks ensures that there is no text overlap between the text blocks, thereby avoiding the problem of repeated processing of some characters or semantic overlap between different text blocks during subsequent processing.
[0165] In another possible implementation, the content containing non-critical information in long document 2 can be divided into multiple intersecting text blocks. For example, this can be done using a sliding window approach. Taking a sliding step of 128 characters and a preset text block length of 512 characters as an example, the text in long document 2 is divided into multiple intersecting text blocks, with the characters in the non-critical information arranged in ascending order. The first text block contains characters 1 to 512 of the non-critical information, the second text block contains characters 129 to 640, and so on. The preset length of the text blocks and the sliding step can be pre-set according to actual needs. It is easy to understand that dividing the content containing non-critical information in long document 2 into multiple intersecting text blocks allows for consideration of context between each text block, thus facilitating better extraction of semantic features from long document 2.
[0166] It should be noted that the embodiments of this application do not limit the implementation method of dividing the long document 2 into multiple text blocks, as long as the key information in the divided text blocks remains intact.
[0167] S503, the electronic device converts one or more text blocks containing key information into corresponding word embedding vectors, and converts one or more text blocks containing non-key information into corresponding compressed latent vectors.
[0168] In this embodiment of the application, after the long document 2 is divided into multiple text blocks, these multiple text blocks can be selectively compressed. For example, only text blocks containing non-critical information can be compressed, while text blocks containing critical information can be left uncompressed.
[0169] In one possible implementation, the text blocks containing key information are not compressed. Specifically, this can include converting each text block containing key information into a corresponding word embedding vector. These word embedding vectors can be generated based on vectors obtained from a word vector library.
[0170] In one possible implementation, compressing text blocks containing non-critical information may specifically include converting each text block containing non-critical information into a corresponding compressed latent vector. The compressed latent vector can be generated using various methods (such as singular value decomposition), and this application embodiment does not limit this method.
[0171] In some examples, before converting one or more text blocks containing non-critical information into corresponding compressed latent vectors, it may also include: determining the compression ratio of long document 2 (or the compression ratio of non-critical information).
[0172] The compression ratio of the long document 2 can be specified by the user or determined based on the long document 2 and the maximum input length supported by the large language model. This application embodiment does not limit this.
[0173] S504. The electronic device fuses the word embedding vector with the compressed latent vector to obtain compressed document 2.
[0174] In one possible implementation, the word embedding vectors and compressed latent vectors are fused. Specifically, this can include concatenating the word embedding vectors and compressed latent vectors. That is, concatenating all the word embedding vectors corresponding to key information with all the compressed latent vectors corresponding to non-key information.
[0175] For example, the word embedding vector and the compressed latent vector can be concatenated in the order of the text block corresponding to the compressed latent vector and the text block corresponding to the word embedding vector in the long document 2 mentioned above.
[0176] It is easy to understand that the compressed document 2 mentioned above is a vectorized document after fusing word embedding vectors and compressed latent vectors.
[0177] It should be noted that the above-mentioned "fusion" methods can include a variety of methods. The embodiments of this application only take splicing as an example of the above-mentioned "fusion" method, and should not constitute a limitation on this application.
[0178] S505, the electronic device generates task result 2 (e.g., a summary) based on compressed document 2 and user request 2.
[0179] In this embodiment of the application, after generating compressed document 2, compressed document 2 and user request 2 can be input into a large language model, and the large language model can output task result 2 (e.g., a summary) based on the input.
[0180] Among them, the aforementioned user request 2 (e.g., "Please generate a summary based on the following content") can be used to instruct electronic devices to perform corresponding summary, question-and-answer, and other tasks.
[0181] By implementing Figure 5 The method provided in the illustrated embodiment can significantly shorten the length of user input content, while retaining key information (such as main headings, subheadings, and quotations) in the large language model tool invocation task and compressing non-key information, so that key information is not lost in compression. Through block compression, the length of the compressed context can be dynamically variable. In addition, by mixing the original word embedding vectors corresponding to key information and the compressed latent vectors corresponding to non-key information, natural language and compressed language are cross-input into the large language model, and the large language model can simultaneously understand the original word embedding vectors of natural language and the compressed information corresponding to the cross-latent vector space, thus supporting selective compression.
[0182] Compared to the baseline scheme of overall compression, Figure 5 The selective compression and cross compression methods provided in the illustrated embodiments achieve better compression results. Furthermore, under compression ratios of 4x to 16x, their performance (i.e., the accuracy of the output results) is on par with or even better than the baseline scheme that does not compress the direct input.
[0183] The following is a schematic diagram of the structure of a terminal device provided in an embodiment of this application.
[0184] Figure 7 An exemplary embodiment of the terminal device provided in this application is shown.
[0185] like Figure 7 As shown, the terminal device may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0186] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal device. In other embodiments of this application, the terminal device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0187] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0188] The controller can serve as the nerve center and command center of the terminal device. Based on the instruction opcode and timing signals, the controller generates operation control signals to control the fetching and execution of instructions.
[0189] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0190] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0191] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the terminal device.
[0192] USB port 130 is a USB standard compliant interface, which can be a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge terminal devices, and can also be used for data transfer between terminal devices and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other terminal devices, such as AR devices.
[0193] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the terminal device. In other embodiments of this application, the terminal device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0194] The wireless communication function of the terminal device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.
[0195] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the terminal device can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0196] The mobile communication module 150 can provide solutions for wireless communication applications including 2G / 3G / 4G / 5G on terminal devices. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0197] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0198] The wireless communication module 160 can provide solutions for wireless communication applications on terminal devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0199] In some embodiments, antenna 1 of the terminal device is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling the terminal device to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0200] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal device may include one or N displays 194, where N is a positive integer greater than 1.
[0201] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in terminal devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0202] The external storage interface 120 can be used to connect an external storage card, such as a Micro SD card, to expand the storage capacity of the terminal device. The external storage card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external storage card.
[0203] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of the terminal device by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of the terminal device (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0204] In some embodiments of this application, the internal memory 121 may be used to store the implementation program of the data processing method provided by one or more embodiments of this application on the terminal device side. The processor 110 may be used to read and execute computer-readable instructions. Specifically, the processor 110 may be used to call the program stored in the internal memory 121, such as the implementation program of the data processing method provided by one or more embodiments of this application on the terminal device side, and execute the instructions contained in the program.
[0205] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. A terminal device can have at least one microphone 170C. In some embodiments, the terminal device can have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, the terminal device can have three, four, or more microphones 170C, enabling sound signal collection, noise reduction, sound source identification, and directional recording, among other functions.
[0206] In some embodiments of this application, a user request can be input to a terminal device via microphone 170C.
[0207] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of the terminal device, in a different position than display screen 194.
[0208] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. The terminal device can receive button input and generate key signal inputs related to user settings and function control of the terminal device.
[0209] It should be understood that, Figure 7 The terminal device shown is merely an example, and the terminal device may have more than [specific features]. Figure 7 The more or fewer components shown can be combined into two or more components, or they can have different component configurations. Figure 7 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.
[0210] The following describes the structure of a server provided in an embodiment of this application.
[0211] Figure 8 An exemplary embodiment of the server structure provided in this application is shown.
[0212] like Figure 8 As shown, the server may include: one or more processors 801, memory 802, communication interface 803, transmitter 805, receiver 806, coupler 807, and antenna 808. These components can be connected via bus 804 or other means. Figure 8 Taking a bus connection as an example:
[0213] The communication interface 803 can be used for communication between the server and other devices, such as terminal devices. Specifically, the communication interface 803 can be a 3G communication interface, a 4G communication interface, a 5G communication interface, or a future New Radio (NR) communication interface. Not limited to wireless communication interfaces, the server can also be configured with a wired communication interface 803, such as a local access network (LAN) interface. The transmitter 805 can be used to process the signals output by the processor 801. The receiver 806 can be used to process the mobile communication signals received by the antenna 808.
[0214] In some embodiments of this application, the transmitter 805 and receiver 806 can be considered as a wireless modem. In the server, the number of transmitters 805 and receivers 806 can be one or more. The antenna 808 can be used to convert electromagnetic energy in a transmission line into electromagnetic waves in free space, or to convert electromagnetic waves in free space into electromagnetic energy in a transmission line. The coupler 807 is used to split the mobile communication signal received by the antenna 808 into multiple paths and distribute them to multiple receivers 806.
[0215] Memory 802 is coupled to processor 801 and is used to store various software programs and / or sets of instructions. Specifically, memory 802 may include high-speed random access memory and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. Memory 802 may store network communication programs that can be used to communicate with one or more auxiliary devices, one or more terminal devices, or one or more network devices.
[0216] In some embodiments of this application, memory 802 may be used to store server-side implementations of the data processing methods provided in one or more embodiments of this application.
[0217] The processor 801 can be used to read and execute computer-readable instructions. Specifically, the processor 801 can be used to invoke a program stored in the memory 802, such as the server-side implementation of the data processing method provided in one or more embodiments of this application, and execute the instructions contained in the program.
[0218] It should be noted that, Figure 8 The server shown is merely one implementation of an embodiment of this application. In actual applications, the server may include more or fewer components, which is not limited here.
[0219] This application provides a chip system including: a processor coupled to a memory for storing programs or instructions, wherein when the program or instructions are executed by the processor, the chip system implements the methods described in any of the above method embodiments.
[0220] Optionally, the chip system may contain one or more processors. These processors can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, an integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor, implemented by reading software code stored in memory.
[0221] Optionally, the chip system may contain one or more memories. The memory may be integrated with the processor or disposed separately from it; this application embodiment does not limit this. For example, the memory may be a non-transient processor, such as a read-only memory (ROM), which may be integrated with the processor on the same chip or disposed separately on different chips. This application embodiment does not specifically limit the type of memory or the arrangement of the memory and processor.
[0222] For example, the chip system may be a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system on chip (SoC), a central processor (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD), or other integrated chips.
[0223] It should be understood that each step in the above method embodiments can be completed by integrated logic circuits in the processor hardware or by instructions in software form. The method steps disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules in the processor.
[0224] 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. 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 this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0225] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0226] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A data processing method, characterized in that, The method includes: The electronic device acquires the first text; The electronic device divides the first text into multiple text blocks, the multiple text blocks including a first text block and a second text block, the first text block being a text block containing key information, and the second text block being a text block containing non-key information; The electronic device compresses the second text block to generate a compressed second text block; The electronic device merges the first text block and the compressed second text block to generate the second text. The electronic device performs reasoning operations on the second text using a large language model.
2. The method according to claim 1, characterized in that, The electronic device compresses the second text block, specifically including: The electronic device converts the second text block into a latent vector.
3. The method according to claim 1 or 2, characterized in that, Before the electronic device merges the first text block and the compressed second text block, the method further includes: The electronic device converts the first text block into a word embedding vector.
4. The method according to claim 3, characterized in that, The electronic device integrates the first text block and the compressed second text block, specifically including: The electronic device concatenates the word embedding vector and the latent vector according to the order of the first text block and the second text block in the first text.
5. The method according to any one of claims 1-4, characterized in that, When the first text is code text, the key information includes one or more of the function name and parameter name.
6. The method according to any one of claims 1-5, characterized in that, When the first text is a text to be summarized, the text to be summarized includes a main title, subtitles, and quotes, and the key information includes one or more of the main title, subtitles, and quotes.
7. The method according to any one of claims 1-6, characterized in that, The method further includes: The electronic device trains the large language model using a training sample set, wherein the training sample set includes multiple texts, each converted into an input vector, and the corresponding reliable inference results for each of the multiple texts. The input vector corresponding to a text includes a latent vector converted from non-key information in the text and a word embedding vector converted from key information.
8. The method according to any one of claims 1-7, characterized in that, Before the electronic device compresses the second text block, the method further includes: The electronic device determines the compression ratio of the non-critical information based on the length of the first text and the maximum input length supported by the large language model.
9. The method according to any one of claims 1-8, characterized in that, Before the electronic device segments the first text into multiple text blocks, the method further includes: The electronic device determines the key information based on prior knowledge; or, The electronic device calculates the perplexity of the first information, and when the perplexity is higher than a first threshold, the electronic device determines that the first information is the key information.
10. The method according to any one of claims 1-9, characterized in that, The method further includes: The electronic device receives user requests; In response to the user request, the electronic device acquires the first text.
11. An electronic device, characterized in that, The electronic device includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, the computer program code including computer instructions, which, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1-10.
12. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which includes program instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-10.
13. A computer program product, when run on a computer, causes the computer to perform the method as described in any one of claims 1-10.