Model training method, data processing method, system, electronic device, storage medium and computer program product
By fusing cue training data, request training data, and context training data to generate a target compression model, the problem of high computational cost and low accuracy of traditional deep learning models in long text processing is solved, and efficient and low-cost context optimization is achieved.
Patent Information
- Application Number
- PCT/CN2026/084102
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-23
- Filing Date
- 2026-03-17
- Publication Date
- 2026-11-26
AI Technical Summary
Traditional deep learning models are computationally expensive and inaccurate when processing long texts. Existing optimization schemes, such as sparse attention and retrieval-enhanced generation methods, suffer from resource dependence and poor flexibility.
By acquiring prompt training data, request training data, and context training data, a target compression model is generated through fusion training. This model is then used to perform context optimization processing on the target prompt data, request data, and context data, thereby enhancing the model's understanding of query commands and information retention.
It achieves high accuracy and low cost when processing contextual data, improves the accuracy and efficiency of the model, and solves the problems of high cost and poor accuracy of traditional models in long text processing.
Smart Images

Figure CN2026084102_26112026_PF_FP_ABST
Abstract
Description
Model training methods, data processing methods, systems, electronic devices, storage media, and computer program products Technical Field
[0001] This disclosure relates to the fields of artificial intelligence technology and data processing technology, and more specifically, to a model training method, a data processing method, a system, an electronic device, a storage medium, and a computer program product. Background Technology
[0002] With the development of deep learning models, the demand for long text processing in application scenarios is constantly increasing. However, traditional attention mechanisms are highly complex, generating a huge number of tokens during the pre-filling stage of long text processing. Furthermore, they may lose some important information when processing long texts, leading to a decrease in model inference accuracy. To address this, some optimization solutions have been proposed, such as introducing retrieval-enhanced generation to process long texts. However, retrieval-enhanced generation relies on coarse-grained text block retrieval, making it difficult to accurately locate fine-grained knowledge, which can further lead to the loss of information in the text sequence and reduce the model's inference accuracy. Another example is using sparse attention to process long texts; however, sparse attention requires a large amount of training data resources and specialized computing equipment resources, resulting in poor flexibility and extremely high costs.
[0003] Therefore, reducing the computational cost of models processing long texts and improving the accuracy of model inference have become important technical challenges in related technologies. Currently, no effective solutions have been proposed to address these issues. Summary of the Invention
[0004] This disclosure provides a model training method, a data processing method, a system, an electronic device, a storage medium, and a computer program product to at least solve the technical problems of high cost and poor accuracy when models trained in related technologies optimize context data.
[0005] According to one aspect of the present disclosure, a model training method is provided, comprising: acquiring prompt training data, request training data, and context training data, wherein the prompt training data is used to indicate the context compression granularity and the association between the prompt training data and the request training data, the request training data is used to indicate the original request instruction, and the context training data includes at least: the original text to be optimized; training an initial compression model based on the prompt training data, request training data, and context training data to generate a target compression model, wherein the target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain a context optimization result.
[0006] According to another aspect of the present disclosure, a data processing method is provided, comprising: acquiring target prompt data, target request data, and target context data; performing context optimization processing on the target prompt data, target request data, and target context data using a target compression model to obtain a context optimization result; and performing answer generation processing on the target request data and context optimization result using a target language model to obtain a target answer; wherein the target compression model is generated according to the model training method of any one of the above.
[0007] According to another aspect of the embodiments of this disclosure, a data processing method is provided, comprising: acquiring technical document prompt data, technical document query data, and technical document context data; performing context optimization processing on the technical document prompt data, technical document query data, and technical document context data using a target compression model to obtain a context optimization result; and performing answer generation processing on the technical document query data and the context optimization result using a target language model to obtain a technical document guidance answer; wherein the target compression model is generated according to the model training method of any one of the above.
[0008] According to another aspect of the embodiments of this disclosure, a data processing method is provided, comprising: obtaining a data processing request through a first application programming interface, wherein the request data carried in the data processing request includes: target prompt data, target request data, and target context data; and returning a data processing response through a second application programming interface, wherein the response data carried in the data processing response includes: a target answer, wherein the target answer is obtained by performing answer generation processing on the target request data and the context optimization result using a target language model, and the context optimization result is obtained by performing context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model, and the target compression model is generated according to the model training method of any one of the above.
[0009] According to another aspect of the embodiments of this disclosure, a data processing method is provided, comprising: acquiring a currently input data processing dialogue request, wherein the request data carried in the data processing dialogue request includes: target prompt data, target request data, and target context data; responding to the data processing dialogue request, returning a data processing dialogue response, wherein the information carried in the data processing dialogue response includes: a target answer, wherein the target answer is obtained by performing answer generation processing on the target request data and the context optimization result using a target language model, and the context optimization result is obtained by performing context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model, wherein the target compression model is generated according to any of the above model training methods; and displaying the target answer in a graphical user interface.
[0010] According to another aspect of the embodiments of this disclosure, a data processing method is provided, comprising: responding to an input command applied to an operation interface, displaying target prompt data, target request data, and target context data on the operation interface; and responding to a processing command applied to the operation interface, displaying a target answer on the operation interface; wherein the target answer is obtained by performing answer generation processing on the target request data and the context optimization result using a target language model, and the context optimization result is obtained by performing context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model, and the target compression model is generated according to the model training method of any one of the above.
[0011] According to another aspect of the embodiments of this disclosure, a data processing system is provided, comprising: a client for sending target prompt data, target request data, and target context data; a server connected to the client for performing context optimization processing on the target prompt data, target request data, and target context data using a target compression model to obtain a context optimization result, and performing answer generation processing on the target request data and context optimization result using a target language model to obtain a target answer; the client is also used to output the target answer; wherein the target compression model is generated according to the model training method of any one of the above.
[0012] According to another aspect of the present disclosure, an electronic device is provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the model training method or the data processing method of any of the above-mentioned methods during runtime.
[0013] According to another aspect of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to execute the model training method or the data processing method of any of the above-mentioned methods.
[0014] According to another aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the model training method or the data processing method of any of the above-described embodiments.
[0015] In this embodiment of the disclosure, prompt training data, request training data, and context training data are obtained. The prompt training data is used to indicate the context compression granularity and the correlation between the prompt training data and the request training data. The request training data is used to indicate the original request instruction. The context training data includes at least the original text to be optimized. An initial compression model is trained based on the prompt training data, request training data, and context training data to generate a target compression model. The target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain a context optimization result.
[0016] It is noteworthy that this embodiment of the present disclosure uses prompt training data, request training data, and context training data for fusion training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions while ensuring the accuracy and cost-effectiveness of context optimization results. Therefore, this embodiment of the present disclosure achieves the goal of training a target compression model with high accuracy and low cost in context data processing by comprehensively utilizing prompt training data, request training data, and context training data. This achieves the technical effect of improving the accuracy of the trained target compression model in processing context content while reducing costs, thereby solving the technical problem of high cost and poor accuracy when models trained in related technologies optimize context data.
[0017] It is worth noting that the above general description and the following detailed description are merely for illustrative and explanatory purposes and do not constitute a limitation thereof. Attached Figure Description
[0018] The accompanying drawings, which are included to provide a further understanding of this disclosure and form part of this disclosure, illustrate exemplary embodiments of the present disclosure and are used to explain the disclosure, but do not constitute an undue limitation of the disclosure. In the drawings:
[0019] Figure 1 is a schematic diagram of an application scenario of a model training method according to an embodiment of the present disclosure;
[0020] Figure 2 is a flowchart of a model training method according to an embodiment of the present disclosure;
[0021] Figure 3 is a schematic diagram of an optional compression model architecture according to an embodiment of the present disclosure;
[0022] Figure 4 is a schematic diagram of an optional text compression-based inference process according to an embodiment of the present disclosure;
[0023] Figure 5 is a flowchart of a data processing method according to an embodiment of the present disclosure;
[0024] Figure 6 is a flowchart of another data processing method according to an embodiment of the present disclosure;
[0025] Figure 7 is a flowchart of another data processing method according to an embodiment of the present disclosure;
[0026] Figure 8 is a flowchart of another data processing method according to an embodiment of the present disclosure;
[0027] Figure 9 is a flowchart of another data processing method according to an embodiment of the present disclosure;
[0028] Figure 10 is a structural block diagram of a model training device according to an embodiment of the present disclosure;
[0029] Figure 11 is a structural block diagram of a data processing apparatus according to an embodiment of the present disclosure;
[0030] Figure 12 is a structural block diagram of another data processing apparatus according to an embodiment of the present disclosure;
[0031] Figure 13 is a structural block diagram of another data processing apparatus according to an embodiment of the present disclosure;
[0032] Figure 14 is a structural block diagram of another data processing apparatus according to an embodiment of the present disclosure;
[0033] Figure 15 is a structural block diagram of another data processing apparatus according to an embodiment of the present disclosure;
[0034] Figure 16 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. Detailed Implementation
[0035] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.
[0036] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. 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 comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0037] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0038] The technical solution provided in this disclosure primarily employs a deep learning model. Deep learning models can be widely applied in fields such as Natural Language Processing (NLP), computer vision, and speech processing. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as to NLP tasks such as text-based sentiment classification, text summarization, and machine translation. Therefore, the main application scenarios of this disclosure include, but are not limited to, digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0039] First, some of the nouns or terms that appear in the description of the embodiments of this disclosure are to be interpreted as follows.
[0040] Large Language Models (LLMs): also known as large models, are built on deep learning frameworks and are able to generate coherent text content when processing language tasks.
[0041] Prefilling refers to the computational stage in which the model encodes the input data into a specific format before processing text tasks.
[0042] Long context refers to input content whose length exceeds the effective input window length of the model. When processing long contexts, models may encounter problems such as excessive pre-filling costs and loss of information from the input content.
[0043] Retrieval-Augmented Generation (RAG) refers to a method in which the model obtains context fragments related to the generation task by calling retrieval tools, and uses these context fragments to assist the model in completing the generation task.
[0044] Sparse attention is an attention mechanism optimization method that improves inference speed by reducing the number of fully connected components when computing the attention matrix.
[0045] Context compression refers to the method of extracting keywords from a very long context to obtain new input content, thereby increasing the information density of the input content.
[0046] Compression Rate: This measures the ratio between the length of the model input before and after compression, and reflects the degree of compression.
[0047] Context optimization refers to mechanisms that streamline input while ensuring information integrity, used to improve the efficiency and effectiveness of models processing extremely long texts. For example, the goal of context optimization could be to minimize the compressed context length and maximize the amount of compressed context information.
[0048] According to embodiments of this disclosure, a model training method is provided. It should be noted that the steps shown in the flowcharts in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0049] The technical solutions provided in this disclosure can employ deep learning models with relatively large parameter scales, such as large models containing billions or even more model parameters. Here, "large model" is merely an example, and this disclosure does not limit the number of model parameters supported by the deep learning model used, aiming to meet actual needs. The deep learning models involved in this disclosure can be artificial intelligence-based language models (LM) or multimodal models (MM).
[0050] Considering the limited computing resources of mobile terminals, the method provided in this disclosure can be applied to the application scenario shown in Figure 1, but is not limited thereto. In the application scenario shown in Figure 1, the deep learning model is deployed on server 10. Server 10 can connect to one or more client devices 20 via a local area network (LAN), wide area network (WAN), internet connection, or other types of data network. The client devices 20 may include, but are not limited to, smartphones, tablets, laptops, PDAs, personal computers, smart home devices, and in-vehicle devices. The client devices 20 can interact with the user through a graphical user interface to invoke the deep learning model, thereby implementing the method provided in this disclosure.
[0051] In this embodiment, the system comprising a client device and a server can perform the following steps: the client device uploads prompt training data, request training data, and context training data to the server, wherein the prompt training data is used to indicate the context compression granularity and the association between the prompt training data and the request training data, the request training data is used to indicate the original request instruction, and the context training data includes at least: the original text to be optimized; the server trains an initial compression model based on the prompt training data, request training data, and context training data to generate a target compression model, and further, the server returns the target compression model to the client, or the server provides the client with a calling interface for the target compression model. The aforementioned target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain a context optimization result.
[0052] It should be noted that with the rapid development of high-performance computing units, the methods provided in this disclosure can also be applied to integrated model machines in other application scenarios. In one optional embodiment, the integrated model machine has multiple built-in models. Users can select one model to adjust as needed to obtain their own model. The high-performance computing unit built into the integrated model machine can then directly call the adjusted model to execute the methods provided in this disclosure. In another optional embodiment, the large integrated model machine has a pre-trained model built-in. The high-performance computing unit built into the integrated model machine can then directly call this model to execute the methods provided in this disclosure.
[0053] Furthermore, when users need to train their own models, they can upload their own datasets via the client. These datasets are then sent to the server, allowing the server to adjust the pre-trained model using the dataset to obtain the user's customized model, which can then be deployed to the production environment. To facilitate users' model adjustment needs, the server provides complete adjustment tools, development frameworks, and processes, supporting multiple adjustment strategies. This allows the adjusted model to better adapt to different application domains and achieve a high degree of customization.
[0054] Under the above operating environment, this disclosure provides a model training method as shown in Figure 2. Figure 2 is a flowchart of the model training method according to an embodiment of this disclosure. As shown in Figure 2, the method may include the following steps S202 to S208.
[0055] Step S202: Obtain prompt training data, request training data, and context training data. The prompt training data is used to indicate the context compression granularity and the correlation between the prompt training data and the request training data. The request training data is used to indicate the original request instruction. The context training data includes at least the original text to be optimized.
[0056] In this embodiment of the disclosure, the prompt training data is preset text information used to guide the model in its processing method when handling context compression. Specifically, the prompt training data may include specific instructions, which are used to characterize the compression granularity of the model when performing context compression (e.g., word-level, phrase-level, or sentence-level compression granularity). In addition, the aforementioned specific instructions can also be used to characterize the association between the prompt training data and the requested training data.
[0057] For example, the correlation between suggested training data and requested training data is reflected in how the suggested training data guides the model to understand query intent and optimize the context accordingly. For instance, suggested training data can specify metrics for query relevance, compression granularity, or context preservation strategies, thereby ensuring that the model's compression results closely match query requirements and retain the most relevant information. By appropriately setting the correlation between suggested training data and requested training data, efficient and accurate context compression can be achieved.
[0058] By introducing cue-based training data, the model learns to understand and respond to different compression requirements during training, enabling flexible optimization of long contexts. In other words, in this embodiment, the model possesses natural language-controlled compression capabilities, adaptively adjusting compression strategies according to different task scenarios, thereby improving the model's generalization ability and user-friendliness after training.
[0059] The training data mentioned above can be the original request instructions submitted by the user. For example, the request type of the original request instructions can include: query requests, question-and-answer requests, dialogue requests, etc. These original request instructions can include specific information or questions that the user needs to obtain from the original text. By learning from the request training data, the model can understand the user's query intent and distinguish key information from the original text.
[0060] In this embodiment, the request training data and the prompt training data work together to enable the model to not only identify important information when performing context compression, but also to ensure the relevance of this important information to the user's query. During training, by learning from the request training data, the model can more accurately retain and highlight the information points that the user cares about when processing long text tasks, thus improving the targeting and efficiency of long context processing.
[0061] The aforementioned contextual training data includes at least the original text to be optimized. The original text can be text from the source document to be optimized. This contextual training data is crucial for training the model for contextual optimization in this embodiment of the disclosure. The original text can contain text of arbitrary length and diverse content, designed to enable the model to learn how to identify and retain important information in different scenarios.
[0062] In this embodiment of the disclosure, when used in conjunction with prompt training data and request training data, the contextual training data helps the model understand the text structure, content importance, and relevance to the query. This helps the model make more accurate decisions during contextual compression, avoiding the loss of key information. By setting contextual training data, complex and varied original texts can be used during training, enabling the trained model to adapt to various long text processing needs and achieve efficient and information-dense contextual compression.
[0063] In application scenarios, the prompt training data can be the preset system prompt in the training scenario, the request training data can be the preset user query in the training scenario, and the above-mentioned context training data can be the preset long context in the training scenario.
[0064] Step S204: Train the initial compression model based on the prompt training data, request training data, and context training data to generate the target compression model. The target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain the context optimization result.
[0065] This embodiment of the disclosure trains an initial compression model based on the obtained prompt training data, request training data, and context training data, thereby generating a target compression model. During the training process described above, the prompt training data, request training data, and context training data are used to enable the model to learn specific strategies for performing context optimization based on the target prompt data, target request data, and target context data. The trained target compression model already possesses the ability to efficiently compress the original text to be optimized based on the context compression granularity and the correlation between the prompt training data and the request training data.
[0066] Specifically, the target compression model can perform fine-grained (determined by the target prompt data) filtering of the text content in the target context data based on the target prompt data and the target request data, focusing on the parts related to the target request data, thereby achieving efficient compression processing of the target context data and producing context optimization results.
[0067] It should be noted that, in the embodiments of this disclosure, the context optimization processing performed on the original text can be context compression processing, and the resulting context optimization result can be the compressed text.
[0068] Through the training process described above, the target compression model can perform in-depth analysis and processing of the input target prompt data, target request data, and target context data. Specifically, the target compression model first parses the target prompt data to understand the specific requirements of context compression, such as compression granularity and query association methods. Next, the target compression model interprets the target request data to clarify the user's information needs or query intent. Furthermore, the target compression model performs efficient and fine-grained context optimization on the target context data (which can be regarded as the original text to be processed), removing unnecessary information and retaining content highly relevant to the target request data, generating context optimization results. Thus, the target compression model achieves effective compression of ultra-long text in application scenarios, avoiding oversimplification or loss of important information during the context compression process, ensuring the conciseness and relevance of the output information, thereby improving the model's processing accuracy and efficiency in long sequence tasks.
[0069] Through steps S202 to S204 described above, this embodiment of the present disclosure uses prompt training data, request training data, and context training data for fusion training. This enables the target compression model to learn the ability to optimize context data in the original text at different context compression granularities, strengthening the target compression model's understanding of query instructions while ensuring the accuracy and cost-effectiveness of context optimization results. Therefore, this embodiment of the present disclosure achieves the goal of training a target compression model with high accuracy and low cost in context data processing by comprehensively utilizing prompt training data, request training data, and context training data. This achieves the technical effect of improving the accuracy of the trained target compression model in processing context content while reducing costs, thereby solving the technical problem of high cost and poor accuracy when the model trained in related technologies optimizes context data.
[0070] In an optional embodiment, in step S204, the initial compression model is trained based on the cue training data, the request training data, and the context training data to generate the target compression model, including the following method steps:
[0071] Step S241: According to the message organization template definition format of the initial compression model, the prompt training data, request training data and context training data are concatenated to obtain the concatenation result;
[0072] Step S242: Train the initial compression model based on the splicing result to generate the target compression model.
[0073] In the optional embodiments described above, a message organization template definition format is set when constructing the initial compression model. The message organization template definition format refers to a specific data structure or format specification used to determine the data organization method when providing cue training data, request training data, and context training data to the initial compression model. In an exemplary application scenario, the message organization template definition format can define the data arrangement order, data delimiters, and data nesting levels in the concatenation result, thereby ensuring that the initial compression model can correctly understand and process different types of information based on the concatenation result. The aforementioned concatenation result refers to the combined result of cue training data, request training data, and context training data processed according to the message organization template definition format.
[0074] For example, the message organization template definition format can be set to "{system prompt, user query, long context}", where "system prompt" represents the prompt training data, "user query" represents the request training data, and "long context" represents the context training data. Following this template format, the prompt training data, request training data, and context training data are concatenated to obtain the concatenated result. In the concatenated result, the prompt training data comes first, guiding the subsequent operations of the initial compression model; the request training data is in the middle, helping the initial compression model understand the specific task or problem; and the context training data is at the end, providing the text content to be processed. By adopting this template format, the initial compression model can consider multiple pieces of information simultaneously in a single forward propagation, thereby making more reasonable compression processing decisions.
[0075] Furthermore, the initial compression model is trained based on the concatenation result to generate the target compression model. During this process, the model can learn the relationships between cue training data, requested training data, and contextual training data, and also learn how to extract important information from the contextual training data. The concatenation result, used as direct input to the initial compression model during training, helps improve the model's learning performance and enhances the generalization performance of the target compression model.
[0076] Through steps S241 to S242 described above, this embodiment of the disclosure, by concatenating different types of training data in a specific format, enables the model to learn how to optimize the context based on specific prompts and queries, achieving more accurate and task-oriented text compression. Training the model based on the concatenation results can improve the adaptability and intelligence of the target compression model, allowing it to effectively filter and retain key information while reducing irrelevant content when handling diverse long text tasks, thus enhancing the targeting and efficiency of context compression.
[0077] In an optional embodiment, the initial compression model includes: a natural language dynamic control module, a bidirectional positional reasoning module, and a lexical evaluation module. In step S242, the initial compression model is trained based on the concatenation result to generate a target compression model, including the following method steps:
[0078] Step S2421: The natural language dynamic control module is used to dynamically control the splicing result to obtain context extraction information. The context extraction information is adaptively extracted based on the needs of prompt training data and request training data.
[0079] Step S2422: Use the bidirectional positional reasoning module to perform word-level bidirectional positional reasoning on the context-extracted information to obtain the positional reasoning result;
[0080] Step S2423: Use the lexical evaluation module to evaluate the positional reasoning results and generate the target compression model.
[0081] In the above optional embodiments, during the process of dynamically controlling the splicing result using a natural language dynamic control module, the natural language dynamic control module can parse the prompt training data and request training data in the splicing result, and then use the parsing results to guide the subsequent processing flow. The aforementioned natural language dynamic control module allows users to express compression instructions in natural language form. This means that users can use natural language instructions to specify the context compression granularity and set the association relationship with user queries, which is user-friendly and highly flexible. By introducing a natural language dynamic control module, the embodiments of this disclosure can adaptively extract necessary context information from extremely long contexts according to different needs of natural language expression.
[0082] The aforementioned contextual information is key text segments automatically selected and retained from the contextual training data by the model based on the compression rules set in the prompted training data and the specific requirements corresponding to the requested training data. This process can adaptively adjust to ensure that the extracted contextual information highly meets the task requirements.
[0083] In an exemplary application scenario, the aforementioned natural language dynamic control module is used to understand and respond to natural language prompts. It can dynamically adjust the granularity and type of context compression based on query instructions (organized in natural language) provided by the user or system. For example, if the natural language prompt is "extract sentences related to climate change," the natural language dynamic control module will use the identified "sentences" and "climate change" as keywords, adaptively filtering out content that meets the requirements from the input text to obtain contextual extraction information.
[0084] The aforementioned bidirectional positional reasoning module integrates a bidirectional attention mechanism (e.g., including forward and backward attention mechanisms) to perform positional reasoning at the lexical level, where information is extracted from the context. Introducing this module helps the model more accurately determine the role and position of each lexical term in the text.
[0085] A bidirectional positional reasoning module is employed to perform word-level bidirectional positional reasoning on context-extracted information, generating positional reasoning results. These results represent the module's assessment of the position and role of each word in the compressed text after analyzing the context-extracted information. For example, a word might be labeled as "start," "inner," "end," or "outer," which helps the model make more accurate decisions during context compression, ensuring the integrity of each part of the compressed text and identifying its logical structure.
[0086] In the aforementioned bidirectional positional reasoning process, the bidirectional positional reasoning module can not only analyze the context from front to back to extract word units, but also reason from back to front, ensuring that the model fully considers the relationship and role of word units at both ends of the context when performing each step of reasoning. Through the bidirectional reasoning mechanism implemented by the aforementioned bidirectional positional reasoning module, the model can better identify context boundaries, avoid missing key information, and improve the accuracy and efficiency of compression.
[0087] The lexical evaluation module described above assesses the importance of each lexical to determine whether it should be retained in the compressed text. Using parameters from a language model, the module understands the semantics and contextual relevance of lexical units. In this way, the model scores lexical units, retaining those important for contextual understanding while removing redundant or irrelevant contextual information, thus generating compressed text with higher information density.
[0088] The lexical evaluation module analyzes the positional reasoning results, assesses the importance of each lexical, and determines whether each lexical should be retained. Through this process, the lexical evaluation module guides the model to learn how to effectively compress text. The resulting target compression model can accurately filter out key information when processing long texts, achieving efficient and information-preserving contextual compression.
[0089] It should be noted that, in this embodiment, the aforementioned context extraction information can be extracted from the concatenation result. Specifically, under the guidance of the natural language dynamic control module, based on the prompt training data and the requested training data, keyword elements are adaptively selected from the concatenation result to obtain the aforementioned context extraction information. In this process, "dynamic control" and "adaptive extraction" work together. "Dynamic control" emphasizes that the model flexibly adjusts the compression strategy according to natural language instructions, while "adaptive extraction" focuses on the actual information extraction process, thereby ensuring that the length and content of the compressed context closely match the specific task requirements, achieving efficient and accurate text information compression and transmission.
[0090] It should be noted that "bidirectional positional reasoning" aims to enhance the model's understanding of lexical boundaries by integrating forward and backward language understanding. Specifically, the model layer of the natural language dynamic control module (such as the Transformer layer) retains a unidirectional attention mechanism to ensure the coherence of language modeling; while the model layer of the bidirectional positional reasoning module adopts bidirectional attention, enabling the model to consider both the preceding and following context when evaluating each lexical unit, thereby accurately locating and retaining task-related contextual fragments. Therefore, the embodiments of this disclosure ensure the integrity and accuracy of the compressed content, effectively avoiding the omission of key information even when processing extremely long texts.
[0091] Furthermore, a lexical evaluation module is used to evaluate the positional reasoning results to obtain lexical evaluation results. The model parameters of the initial compression model are then fine-tuned using the lexical evaluation results to generate the target compression model.
[0092] Through steps S2421 to S2423 described above, this embodiment of the present disclosure, through the collaboration of the natural language dynamic control module, the bidirectional positional reasoning module, and the lexical evaluation module, enables the trained target compression model to dynamically adjust its compression strategy according to natural language instructions, accurately locate and retain key words and lexical units, and enhance the accuracy of boundary recognition through bidirectional positional reasoning. In other words, this embodiment of the present disclosure achieves intelligent optimization of the context, ensuring that the compressed text is both compact and contains all necessary information, thus improving the efficiency and quality of the model when processing text.
[0093] In an optional embodiment, in step S2423, a lexical evaluation module is used to evaluate the positional reasoning results and generate a target compression model, including the following method steps:
[0094] Step S2424: The word evaluation module is used to evaluate the position reasoning result to obtain the target loss. The target loss is used to determine the word semantic loss and word position loss corresponding to the position reasoning result.
[0095] Step S2425: Fine-tune the model parameters of the initial compression model based on the target loss to generate the target compression model.
[0096] The aforementioned target loss is an indicator used during model training to evaluate the gap between the model output and the expected result. In this embodiment, the target loss combines lexical semantic loss and lexical position loss, reflecting whether the model correctly labels the positional attributes of lexical units while preserving contextual meaning. The lower the target loss, the closer the model's context compression effect is to the ideal state; that is, it can both preserve key information and accurately identify the position of lexical units in the text, thereby guiding the optimization direction of model parameters.
[0097] The aforementioned lexical semantic loss measures the accuracy of the model's semantic understanding of lexical units during compression. When the model attempts to determine the actual meaning of a lexical unit and classify it (e.g., role, location, number), a lexical semantic loss occurs if the classification result does not match the actual meaning. This lexical semantic loss encourages the model to understand the semantics of lexical units more accurately, avoiding the omission or misunderstanding of key information during compression, thereby improving the quality of the compressed text.
[0098] The aforementioned lexical position loss is used to evaluate the accuracy of the model's judgment of the positional attributes of lexical units in the context during compression. For example, the model needs to determine whether a lexical unit belongs to the beginning, middle, or end of an important sentence, or whether the lexical unit is irrelevant content of an important sentence. If the model incorrectly labels the position of a lexical unit, such as mistaking the end of a sentence for the beginning, lexical position loss will occur. This lexical position loss prompts the model to not only focus on the semantics of lexical units during compression, but also to correctly identify the position of lexical units in the original text, in order to reduce information distortion or loss and ensure the logical integrity and coherence of the compressed text.
[0099] In this embodiment, a lexical evaluation module is used to evaluate the positional reasoning results. Specifically, the lexical evaluation module calculates the semantic loss and positional loss of each lexical by analyzing the actual semantic label of each lexical and its expected positional information in the content to be compressed. The semantic loss and positional loss of each lexical together determine the target loss, which serves as an important indicator for evaluating the accuracy of the positional reasoning results and guiding the optimization of model parameters. It is noteworthy that this embodiment combines semantic understanding and positional awareness in calculating the target loss to evaluate the model's performance during context compression, thereby promoting the model's comprehensive optimization capability and avoiding insufficient generalization ability that may result from single-dimensional evaluation.
[0100] Furthermore, based on the feedback from the target loss, the model parameters of the initial compression model are finely adjusted to generate the target compression model. This means that through a multi-task learning framework, the model can not only capture the basic structure and meaning of language, but also learn to locate important information in text based on system prompts and user queries, thereby compressing the context more efficiently while retaining key details. The aforementioned model parameter fine-tuning process ensures that the model can more accurately identify and process fine-grained information at the word level when performing context optimization. Through parameter fine-tuning based on the target loss, the model's performance is significantly improved, especially when processing long documents, where the model can more effectively cope with information overload.
[0101] Through steps S2424 to S2425 described above, the target loss in this embodiment of the disclosure is determined comprehensively through the lexical evaluation module. This target loss can be a comprehensive loss including lexical semantic loss and lexical positional loss. Therefore, the model can accurately quantify the errors in semantic preservation and positional decision-making during the compression process. Adjusting the model parameters based on the target loss can improve the accuracy and semantic coherence of the model when performing contextual compression processing, ensuring that the compressed text is not only concise but also complete in information and logically clear, thus optimizing the effect and efficiency of text processing.
[0102] In an optional embodiment, in step S2424, the lexical evaluation module performs lexical evaluation on the positional reasoning result to obtain the target loss, including the following method steps:
[0103] Step S25: Use the word element evaluation module to perform word element semantic prediction on the position reasoning result to obtain word element semantic loss, and use the word element evaluation module to perform word element position prediction on the position reasoning result to obtain word element position loss;
[0104] Step S26: Calculate the target loss based on the semantic loss and positional loss of the lexical units.
[0105] The lexical evaluation module performs in-depth analysis of the positional reasoning results. This in-depth analysis can be divided into two parts: lexical semantic prediction and lexical position prediction. Lexical semantic prediction refers to the module evaluating the actual meaning and type of each lexical in the original text, such as a character name, location, or number. Through lexical semantic prediction, the model can understand the specific meaning of each lexical in the context. In particular, it can also use the reusability of the language model module to label the importance of lexical in a more generalized way. Lexical position prediction refers to the module determining the interval position of the lexical in the context (such as the start position, internal position, end position, or external position) based on the positional reasoning results. This helps the model determine whether the lexical belongs to the key information that needs to be retained.
[0106] Furthermore, the target loss is calculated based on the semantic loss and the positional loss of the lexical units. For example, the target loss can be calculated by weighting and summing the semantic loss and the positional loss of the lexical units according to the first weight corresponding to the semantic loss and the second weight corresponding to the positional loss of the lexical units.
[0107] In this embodiment of the disclosure, a lexical evaluation module is used to perform lexical semantic prediction on the position reasoning results to obtain lexical semantic loss, and a lexical evaluation module is used to perform lexical position prediction on the position reasoning results to obtain lexical position loss.
[0108] It should be noted that in this embodiment, "lexical semantic prediction" aims to predict the semantic label of each lexical unit, and "lexical position prediction" aims to predict the position label of each lexical unit. The above prediction process generates the distribution of semantic labels and position labels, which are then compared with the actual labels. The lexical semantic loss and lexical position loss are calculated respectively using the cross-entropy loss function. The above-mentioned lexical semantic loss and lexical position loss are used to guide the update of model parameters to optimize the semantic understanding and position awareness capabilities at the lexical level, ensuring that the compressed contextual information is both rich and focused.
[0109] Through steps S25 to S26 above, this embodiment of the disclosure calculates the target loss by combining word semantic loss and positional loss, and uses the target loss to assist in fine-tuning the model parameters. This enables the model to take into account both semantic accuracy and contextual boundary integrity when performing context compression processing, thereby directly improving the compression quality, ensuring that the output text is concise without losing key information, and enhancing the performance and reliability of the target compression model in long text processing tasks.
[0110] In an optional embodiment, in step S25, the lexical evaluation module is used to perform lexical semantic prediction on the positional reasoning result to obtain the lexical semantic loss, including the following method steps:
[0111] Step S251: Use the lexical evaluation module to perform lexical semantic prediction on the positional reasoning results to obtain semantic prediction results;
[0112] Step S252: Calculate the semantic loss of lexical units based on the semantic prediction results and the predefined semantic labels of lexical units.
[0113] The semantic prediction results described above are the output of the lexical evaluation module, which predicts the possible semantic categories of each lexical after analyzing the positional reasoning results. For example, the lexical evaluation module may predict that a certain lexical represents semantic categories such as "role name," "location," or "number." These semantic prediction results not only reflect the meaning of the lexical itself but also consider the contextual environment of the lexical in the original text. The semantic prediction results can serve as an important basis for judging the importance and relevance of lexical in the context optimization process.
[0114] A lexical evaluation module is used to perform lexical semantic prediction on the previously generated positional inference results. This evaluates the true semantic content of each lexical and its expected role in the context, yielding the semantic prediction result. The lexical evaluation module reuses parameters from the language model module during lexical semantic prediction, meaning that the model can make predictions based on its existing language understanding capabilities without additional training. Notably, this process leverages the existing language model's knowledge base, achieving fine-grained understanding and control at the lexical level with minimal resource consumption. This demonstrates the model's generalization ability and potential application value in the field of context optimization.
[0115] During training, predefined semantic tags are a set of standard labels pre-annotated to guide the model's learning. These semantic tags define the semantic category that a lexical should have in a specific context. For example, the semantic tag "B-PERSON" is set to represent the starting lexical of a character name, and the semantic tag "I-LOCATION" is set to represent the internal lexical of a location. The semantic prediction results are compared with these predefined semantic tags, and the semantic loss is obtained by calculating the difference between the semantic prediction results and the semantic tags.
[0116] The aforementioned lexical semantic loss reflects the gap between the model's predicted semantic results and the actual expectations, and can serve as a supervision signal during model training. The calculation of this lexical semantic loss incorporates rich contextual information and predefined labels, prompting the model to continuously learn and adjust, thereby reducing prediction errors, improving the accuracy of lexical understanding and classification, and ensuring the precise location and preservation of key information points in the text during compression.
[0117] Through the above steps S251 to S252, this embodiment of the disclosure calculates semantic loss by comparing word semantic prediction with predefined labels, enabling the model to accurately identify the impact of compression operations on the meaning of text, prompting the model to learn to perform effective compression while retaining key semantics, avoiding information distortion, improving the semantic accuracy of compressed text, and improving the performance of the model when performing long text understanding tasks.
[0118] In an optional embodiment, in step S251, the lexical evaluation module is used to predict the lexical position of the position reasoning result to obtain the lexical position loss, including the following method steps:
[0119] Step S253: Use the lexical evaluation module to predict the lexical positions of the position reasoning results to obtain the position prediction results;
[0120] Step S254: Calculate the lexical position loss based on the position prediction result and the predefined lexical position labels.
[0121] During context compression, the lexical evaluation module performs position classification prediction on each lexical corresponding to the position inference result, obtaining the position prediction result. This position prediction result contains the potential positional identifier of the lexical in the compressed text. Through lexical position prediction, the model can understand the role and boundaries of lexical in the context, thus making more accurate choices during compression.
[0122] The predefined lexical position labels mentioned above are lexical position information annotated in the training data, used to guide and evaluate the model's lexical position predictions. These lexical position labels are determined manually or by pre-designed rules to ensure that the positional attributes of each lexical in the training data are correct. For example, if a lexical is the beginning of an important sentence, its predefined label could be "Begin"; if a lexical is inside an important sentence, its predefined label could be "Inner"; if a lexical is the end of an important sentence, its predefined label could be "End"; and if a lexical is outside an important sentence (i.e., irrelevant information), its predefined label could be "Outside". During training, the model's position prediction results are compared with these predefined lexical position labels to calculate the lexical position loss, which is then used to adjust the model parameters, enabling the model to more accurately identify and retain the positional information of key lexical terms in practical use.
[0123] In this embodiment, a lexical evaluation module is used to predict the position of lexical terms based on the positional reasoning results. The predicted position is then used to determine whether a lexical term is located in a key position required for contextual optimization, such as the beginning, interior, end, or exterior. Therefore, the solution provided in this embodiment does not rely solely on traditional scalar scoring or a limited tag set, but reuses the parameters of the lexical evaluation module. It transforms the original language understanding capability of the lexical evaluation module into a judgment of the importance of lexical positions, thereby improving the model's generalization ability and accuracy in compression tasks.
[0124] The lexical position loss is calculated based on the position prediction result and predefined lexical position labels. These predefined labels are set according to the context optimization target and represent the ideal lexical position information. The calculation of the lexical position loss is an important indicator for evaluating the model's prediction accuracy, reflecting the gap between the model's position prediction result and the ideal position. It guides the optimization of model parameters, ensuring that the position inference mechanism can accurately locate key information in the context. Therefore, this embodiment quantifies the model's deviation in position prediction, enabling the model to specifically improve its ability to recognize lexical positions and reduce information loss in long context processing.
[0125] Through steps S253 to S254 above, this embodiment of the present disclosure calculates the loss between the position prediction result and the predefined lexical position label, enabling the model to accurately adjust its understanding and processing of the text structure. This enhances the model's ability to maintain the integrity of sentence and paragraph boundaries during compression, prevents information fragment breakage, and thus achieves a more efficient context compression effect while ensuring text coherence and structural rationality.
[0126] In an exemplary application scenario, a compression model architecture as shown in Figure 3 is provided. As shown in Figure 3, the input of the compression model architecture includes three parts: system prompt, user query, and long context. The system prompt can be used to represent the granularity of context compression, or to represent the relationship between the system prompt and the query. The query can be a query command entered by the user, and the long context can be the text data to be compressed and optimized.
[0127] Specifically, both the initial compression model and the target compression model adopt the compression model architecture shown in Figure 3. During the training of the initial compression model, the system prompts are determined by the prompt training data, the queries are determined by the request training data, and the context data is determined by the context training data. After training, in the application scenario of the target compression model, the system prompts are determined by the target prompt data, the queries are determined by the target request data, and the context data is determined by the target context data.
[0128] As shown in Figure 3, system prompts, queries, and contextual data can be input into the first number of causal language model layers. It should be noted that the first number of causal language model layers can be arranged in series to form a natural language dynamic control module.
[0129] Specifically, in the first number of causal language model layers, dynamic control of natural language can be achieved. That is, in this embodiment of the disclosure, to achieve context compression optimization with different granularities and needs that can be controlled by natural language, a natural language-controlled compression model input paradigm is designed in the compression model architecture. This input paradigm can be defined as a concatenated combination of system prompts, queries, and context data, represented as {system prompt, user query, long context}. The above input paradigm can be obtained by concatenating according to a preset message definition method. Therefore, after the first number of causal language model layers dynamically control the above input paradigm, context extraction information is obtained, which includes at least a portion of the information in the context data.
[0130] As shown in Figure 3, the context-extracted information obtained from the first number of causal language model layers will be further input into the second number of bidirectional reasoning model layers. These bidirectional reasoning model layers can be Transformer layers. It should be noted that these second number of bidirectional reasoning model layers can be arranged in series to form a bidirectional positional reasoning module. Specifically, these second number of bidirectional reasoning model layers perform word-level bidirectional positional reasoning on the context-extracted information to obtain the positional reasoning result.
[0131] In this embodiment, it is necessary to select the text content to be compressed from the context data in the form of sequence labels. Therefore, the model needs to be able to determine the boundaries of the content intervals to be compressed in the context data. To this end, the aforementioned bidirectional inference model layer can determine the interval boundary information for each word in the context extraction information and can fuse the context signals corresponding to the context extraction information from both forward and backward dimensions.
[0132] As described above, the compression model architecture first includes a causal language model layer, followed by a bidirectional reasoning model layer to implement different functions. This layered model architecture strategy not only ensures the stable transmission of language information during context compression optimization, but also enhances the model's context boundary recognition performance through bidirectional reasoning.
[0133] As shown in Figure 3, the compression model architecture also includes a token critique module, which can be a token critique module that reuses the language model head. Unlike traditional token critique methods that use a limited set of tags, this embodiment uses the language modeling head of the basic language model to predict the semantic tag of each token, and simultaneously uses an auxiliary head (such as a feedforward network head) to predict the position of each token in the content to be compressed, thus obtaining a position tag. Through the joint prediction of these two heads, the token critique module can determine the tag search space as the Cartesian product of the semantic tags and position tags. Based on this, the context data is compressed and optimized to obtain the compressed result of the context data.
[0134] Therefore, the combined modeling scheme corresponding to the compressed model architecture in this embodiment expands the model decision space, enabling dynamic adaptation to diverse compression optimization standards through system prompts, and preserving the linguistic knowledge of the basic model through parameter integration.
[0135] During the training of the compression model architecture shown in Figure 3, a multi-task training method can be adopted. For each word position, the language model head is used to predict the semantic label to obtain the word semantic loss. The above word semantic loss can be calculated as shown in Equation (1) below.
[0136] In the above equation (1), L tag This indicates semantic loss of lexical units. This represents the position t of all lexical units in a long context (from 0 to |X). l The loss of |) is taken at its maximum value.l Represents long context data, |X l | indicates the number of tokens in the long context data. y tag This represents a semantic label. P indicates a system suggestion, and q indicates a user query. logp θ (y tag |P,q,X l ) represents the log probability of the semantic label given system prompts, user queries, and long context data, under model parameters θ.
[0137] Furthermore, the position prediction head is used to predict the position label to obtain the lexical position loss. The above lexical position loss can be calculated as shown in the following equation (2).
[0138] In equation (2) above, L pos Indicates the loss of lexical position, y pos Indicates a location label.
[0139] Furthermore, the target loss L can be calculated as shown in equation (3) below. L=αL tag +βL pos Equation (3)
[0140] In equation (3) above, α represents the lexical semantic loss L. tag The weights, β represents the word position loss L pos The weight.
[0141] In an optional embodiment, in step S241, the prompt training data, request training data, and context training data are concatenated according to the message organization template definition format of the initial compression model to obtain the concatenation result, including the following method steps:
[0142] Step S2411: Divide the context training data into multiple non-overlapping windows according to the given window size;
[0143] In step S2412, according to the message organization template definition format of the initial compression model, the prompt training data and request training data are independently spliced with multiple non-overlapping windows one by one to obtain the splicing result.
[0144] The given window size refers to a pre-defined fixed length used when processing long contextual training data to segment the data into smaller, manageable segments. This window size is chosen based on the sequence length the model can effectively process, aiming to achieve a balance between computational efficiency and information retention. For example, if the window size is set to 1024 words, the model will cut the contextual training data into 1024-word segments for independent processing.
[0145] The aforementioned multiple non-overlapping windows refer to dividing long contextual training data into several non-overlapping segments based on a given window size; each segment constitutes a window. In this way, the data within each window is independent and without repetition, facilitating parallel processing and reducing redundant computation. This strategy of segmenting data into multiple non-overlapping windows helps the model maintain efficient utilization of computational resources when processing extremely long texts, while avoiding excessive compression or omission of information.
[0146] During the process of concatenating the prompt training data, request training data, and context training data according to the message organization template definition format of the initial compression model, the prompt training data and request training data will be concatenated with the context training data in each non-overlapping window one by one to form independent training samples.
[0147] It's worth noting that the concatenation operation follows the message organization template definition format of the initial compression model, ensuring that the input of each window includes system prompts for training data, user queries for training data, and the specific content of the contextual training data. This method of concatenating each window independently allows the model to make independent compression decisions for the contextual training data within each window, avoiding interference between contexts and supporting efficient parallel computation.
[0148] In this embodiment, the context training data is divided into multiple non-overlapping windows according to a given window size. The context training data can be extremely long context text. Segmenting this extremely long context text according to the window size yields multiple non-overlapping windows. This window size ensures that each non-overlapping window contains a certain number of tokens. Dividing the extremely long context text into multiple non-overlapping windows avoids memory overflow issues when processing extremely long sequences and allows for parallel processing, thereby significantly reducing pre-padding latency and improving inference efficiency.
[0149] Furthermore, the message organization template definition format is used as the data organization method. Prompt training data and request training data are independently concatenated with multiple non-overlapping windows one by one. This allows the model to understand system prompts and user queries through the concatenation results and apply them to the terms in the non-overlapping windows. By independently concatenating the prompt training data, request training data, and data from each non-overlapping window, independent input fragments are formed. Each fragment contains system prompts, user queries, and some contextual information. The advantage of this approach is that it not only ensures that the optimization processing of each window is not affected by other windows, but also allows the model to explicitly perform contextual optimization based on the needs of system prompts and user queries when processing each window. The above scheme achieves parallelization and modularization of long context processing, enabling the model to perform efficient and accurate optimization of ultra-long sequences without losing contextual dependencies.
[0150] It should be noted that, in this embodiment, after the context training data is divided into multiple non-overlapping windows and independently concatenated, each non-overlapping window generates an optimized context fragment through the initial compression model. These context fragments are then integrated according to their relative positions in the original context to form a complete compressed context. During the inference phase, the optimized fragments of the long context processed through the same window division and concatenation steps can be directly used as input to the generative language model without additional reconstruction. The window parallel strategy not only accelerates the processing flow but also ensures that the optimization of non-overlapping windows is independent of other data outside that window, thereby improving overall processing efficiency and model response speed while maintaining information integrity.
[0151] Through the above steps S2411 to S2412, this embodiment of the disclosure divides the context training data into non-overlapping windows and independently splices the prompts and queries. The model can achieve parallel computation when processing ultra-long sequences, significantly reducing pre-filling latency and improving training efficiency. At the same time, independent analysis of each window helps the model to more accurately capture local context information, improving compression accuracy and overall performance.
[0152] In an exemplary application scenario, a text compression-based inference process is provided, as shown in Figure 4. This inference process embodies a window-parallel inference strategy. As shown in Figure 4, the ultra-long text data serves as the context data to be compressed and optimized. To achieve efficient context compression optimization, the ultra-long text data is divided into multiple non-overlapping parallel windows based on a given window size. Each non-overlapping parallel window can be concatenated with system prompts and queries to obtain independent inputs for the compression model. The compression model can then process the multiple independent inputs corresponding to the multiple non-overlapping parallel windows in parallel to obtain the compressed text. Furthermore, a language model is used to analyze the query and the compressed text, inferring and generating an answer that can be directly used to respond to the query.
[0153] In an optional embodiment, the context training data further includes: multi-granularity context optimization training data and query-aware context optimization training data, wherein the multi-granularity context optimization data is used to train the initial compression model to compress the original text to be optimized into multiple optimization results of different granularities based on the prompt training data, and the query-aware context optimization data is used to train the initial compression model to perform context optimization aligned with the request training data.
[0154] The aforementioned multi-granularity context optimization training data is a pre-designed training dataset containing text fragments of varying lengths and complexities. During training, this dataset helps the model learn to identify and extract important information at different levels. For example, multi-granularity context optimization training data may include text data at the word, phrase, sentence, paragraph, and document levels, helping the model learn how to compress the original text into optimized results of different granularities based on system prompts corresponding to the training data, thus adapting to various text processing needs.
[0155] During model training, for the same original text, the model may generate multiple versions of context compression results. Each version of the context compression result is optimized for compression at different levels of contextual information. Context compression granularity can be understood as the fineness of the information; for example, context compression results at the word level will focus more on word-level details, while context compression results at the paragraph level will focus on the text's topic and structure. These multiple optimization results at different granularities are used together to train the model, enabling the model to flexibly select the best compression strategy when handling real-world tasks.
[0156] The aforementioned query-aware context optimization training data is used to enhance the model's sensitivity to user queries, ensuring that the compressed text closely reflects the query requirements and retains the most relevant information. Each sample in the query-aware context optimization training data is associated with a specific query. By learning the correspondence between these samples and queries, the model can accurately perform context compression optimization, removing redundant content from the original text and retaining content directly related to the query.
[0157] Based on query-aware context optimization, the model considers the specific needs raised in the training data when compressing the context, adjusting the compression strategy to ensure that the final context compression optimization result directly supports or answers the query. For example, if the query is a detailed description of a specific event, the model will prioritize retaining words and phrases containing information about that event while ignoring content irrelevant to the query, thus achieving query-aware context optimization and improving the targeting and efficiency of text processing.
[0158] Through the above optional embodiments, this disclosure utilizes multi-granularity context-optimized data training, enabling the model to learn to flexibly respond to requirements of different lengths and levels of detail, enhancing the diversity and adaptability of compression strategies when handling context compression tasks. Furthermore, training with query-aware context-optimized data allows the model to accurately focus on query-related information, effectively eliminating non-critical content, thereby improving the model's targeting and efficiency when performing long text processing.
[0159] It's important to note that multi-granularity context-optimized training data and query-aware context-optimized data work synergistically during training to enhance the model's flexibility and task adaptability. Multi-granularity data provides context-optimized instances of varying lengths and complexities, enabling the model to dynamically adjust its compression strategy based on instructions, effectively addressing the need for multi-scale information extraction, from lexical units to paragraphs. Query-aware data focuses on the model's understanding and response to user requests, ensuring accurate identification and retention of highly relevant content through numerous fine-grained instruction-response pairs. This combination of multi-granularity context-optimized training data and query-aware context-optimized data allows the model to adaptively compress text based on system prompts and user queries when processing long texts, while ensuring that the compressed contextual information is closely aligned with task requirements, significantly improving the efficiency and accuracy of long text processing.
[0160] It should be noted that, in the embodiments of this disclosure, during the processing stage following bidirectional positional reasoning, the model performs semantic and positional joint analysis on the tokens in each window through a token evaluation module, identifying and marking core information regions highly relevant to the query. Subsequently, based on the marking results, the model intelligently selects key tokens within each window and reorganizes them to form the compressed context. This process ensures that the optimized context is not only significantly shorter than the original context but also retains fine-grained knowledge crucial to the query response, achieving a compression effect from lengthy source documents to concise information segments.
[0161] In the aforementioned operating environment, this disclosure also provides a data processing method as shown in FIG5. FIG5 is a flowchart of a data processing method according to an embodiment of this disclosure. As shown in FIG5, the data processing method includes:
[0162] Step S501: Obtain target prompt data, target request data, and target context data;
[0163] Step S502: Use the target compression model to perform context optimization processing on the target prompt data, target request data and target context data to obtain the context optimization result;
[0164] Step S503: Use the target language model to process the target request data and context optimization results to generate the target answer;
[0165] The target compression model is generated according to any of the above model training methods.
[0166] The aforementioned target suggestion data, target request data, and target context data can be data input by the user in the application scenario, or data determined by other programs or threads. Target suggestion data indicates the granularity of context compression and the correlation between the target suggestion data and the target request data. Target request data determines the user's query instruction. Target context data includes at least the text sequence to be optimized. The aforementioned target compression model is used to perform context optimization processing on the target suggestion data, target request data, and target context data to obtain the context optimization result. This context optimization result can be the text content obtained after context compression optimization of the aforementioned text sequence. Further, a target language model is used to perform answer generation processing on the target request data and the context optimization result to obtain the target answer. Because the amount of data in the aforementioned context optimization result is relatively small and the correlation between the data and the query is high, the target language model can efficiently generate a highly accurate target answer.
[0167] In an optional embodiment, in step S502 above, the target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain the following context optimization results:
[0168] Step S521: According to the message organization template definition format of the target compression model, the target prompt data, target request data and target context data are concatenated to obtain the target concatenation result;
[0169] Step S522: Use the target compression model to perform context optimization processing on the target splicing result to obtain the context optimization result.
[0170] The specific implementation methods of steps S521 to S522 above can be referred to the relevant descriptions in the aforementioned model training method, and will not be repeated here.
[0171] In this embodiment, the target compression model is trained according to any of the above-mentioned model training methods. In these methods, prompt training data, request training data, and context training data are fused together for training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions and ensures the accuracy and cost-effectiveness of the context optimization results. In other words, the above-mentioned model training method comprehensively utilizes prompt training data, request training data, and context training data to train a target compression model with high accuracy and low cost in context data processing. Based on this, this embodiment utilizes this target compression model for context optimization, achieving high accuracy in context optimization results at a lower cost. Furthermore, a target language model is used to generate answers using the context optimization results. Since the context optimization results are compressed context data, the entire data processing flow is highly efficient and the reasoning accuracy is high. Especially when processing large amounts of target context data (such as very long text), this embodiment demonstrates high data processing efficiency, low cost, and high accuracy in the generated target answer. As described above, the embodiments of this disclosure achieve the technical effects of improving data processing efficiency and accuracy and reducing data processing costs by applying a target compression model, thereby solving the technical problems of high cost, poor accuracy and low efficiency when the model processes context data in related technologies.
[0172] It should be noted that the preferred embodiments of steps S501 to S503 described above can be found in the foregoing descriptions, and will not be repeated here.
[0173] In the aforementioned operating environment, this disclosure also provides another data processing method as shown in FIG6. FIG6 is a flowchart of another data processing method according to an embodiment of this disclosure. As shown in FIG6, the data processing method includes:
[0174] Step S601: Obtain technical document prompt data, technical document query data, and technical document context data;
[0175] Step S602: Use the target compression model to perform context optimization processing on the technical document prompt data, technical document query data and technical document context data to obtain the context optimization result;
[0176] Step S603: Use the target language model to process the technical document query data and context optimization results to generate answers, and obtain the technical document guidance answers;
[0177] The target compression model is generated according to any of the above model training methods.
[0178] The aforementioned technical document hint data, technical document query data, and technical document context data can be data input by the user in the application scenario, or data determined by other programs or threads. The technical document hint data indicates the granularity of context compression and the correlation between the technical document hint data and the technical document query data. The technical document query data determines the user's query instruction. The technical document context data includes at least the technical document text content to be optimized. The aforementioned target compression model is used to perform context optimization processing on the technical document hint data, technical document query data, and technical document context data to obtain a context optimization result. This context optimization result can be a portion of the text content obtained after context compression optimization of the aforementioned technical document text content. Further, a target language model is used to perform answer generation processing on the technical document query data and the context optimization result to obtain a technical document guidance answer. Because the amount of data in the aforementioned context optimization result is relatively small and the correlation between the data and the query is high, the target language model can efficiently generate technical document guidance answers with high accuracy.
[0179] In this embodiment, the target compression model is trained according to any of the above-mentioned model training methods. In these methods, prompt training data, request training data, and context training data are fused together for training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions and ensures the accuracy and cost-effectiveness of the context optimization results. In other words, the above-mentioned model training method comprehensively utilizes prompt training data, request training data, and context training data to train a target compression model with high accuracy and low cost in context data processing. Based on this, this embodiment utilizes the target compression model for context optimization, achieving high accuracy in context optimization results at a lower cost. Furthermore, a target language model is used to generate answers using the context optimization results. Since the context optimization results are compressed context data, the entire data processing flow is highly efficient and the reasoning accuracy is high. Especially when processing large amounts of technical document context data (such as very long texts), this embodiment demonstrates high data processing efficiency, low cost, and high accuracy in the generated technical document answers. As described above, the embodiments of this disclosure achieve the technical effects of improving data processing efficiency and accuracy and reducing data processing costs by applying a target compression model, thereby solving the technical problems of high cost, poor accuracy and low efficiency when the model processes context data in related technologies.
[0180] It should be noted that the preferred embodiments of steps S601 to S603 described above can be found in the foregoing description, and will not be repeated here.
[0181] In the aforementioned operating environment, this disclosure also provides another data processing method as shown in FIG7. FIG7 is a flowchart of another data processing method according to an embodiment of this disclosure. As shown in FIG7, the data processing method includes:
[0182] Step S701: Obtain a data processing request through the first application programming interface, wherein the request data carried in the data processing request includes: target prompt data, target request data, and target context data;
[0183] Step S702: Return a data processing response through the second application programming interface. The response data carried in the data processing response includes: the target answer, which is obtained by generating the answer using the target language model after processing the target request data and the context optimization result; the context optimization result is obtained by optimizing the target prompt data, the target request data and the target context data using the target compression model; and the target compression model is generated according to any of the above model training methods.
[0184] The data processing method described in this embodiment can run on a cloud server to provide cloud data processing services to clients. The client sends a data processing request by calling a first application programming interface (API). After the cloud server receives the data processing request through the first API, it generates the target answer according to the data processing method and further returns the target answer to the client through a second API.
[0185] The first and second application programming interfaces (APIs) mentioned above can be the same or different APIs. In one optional embodiment, the interface parameters in the first and second APIs may include, but are not limited to: a global interface identifier, an interface signing key, an interface timestamp, an interface request identifier, and a system call credential identifier. The first API can use a GET request or a POST request as the interface request method to obtain a file processing request. The second API can use a lightweight data exchange format (such as JavaScript Object Notation, or JSON for short) to return a file processing response.
[0186] In this embodiment, the target compression model is trained according to any of the above-mentioned model training methods. In these methods, prompt training data, request training data, and context training data are fused together for training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions and ensures the accuracy and cost-effectiveness of the context optimization results. In other words, the above-mentioned model training method comprehensively utilizes prompt training data, request training data, and context training data to train a target compression model with high accuracy and low cost in context data processing. Based on this, this embodiment utilizes this target compression model for context optimization, achieving high accuracy in context optimization results at a lower cost. Furthermore, a target language model is used to generate answers using the context optimization results. Since the context optimization results are compressed context data, the entire data processing flow is highly efficient and the reasoning accuracy is high. Especially when processing large amounts of target context data (such as very long text), this embodiment demonstrates high data processing efficiency, low cost, and high accuracy in the generated target answer. As described above, the embodiments of this disclosure achieve the technical effects of improving data processing efficiency and accuracy and reducing data processing costs by applying a target compression model, thereby solving the technical problems of high cost, poor accuracy and low efficiency when the model processes context data in related technologies.
[0187] It should be noted that the preferred embodiments of steps S701 to S702 described above can be found in the foregoing descriptions, and will not be repeated here.
[0188] In the aforementioned operating environment, this disclosure also provides another data processing method as shown in FIG8. FIG8 is a flowchart of another data processing method according to an embodiment of this disclosure. As shown in FIG8, the data processing method includes:
[0189] Step S801: Obtain the currently input data processing dialogue request, wherein the request data carried in the data processing dialogue request includes: target prompt data, target request data, and target context data;
[0190] Step S802: In response to the data processing dialogue request, a data processing dialogue response is returned. The information carried in the data processing dialogue response includes: the target answer, which is obtained by processing the target request data and the context optimization result using the target language model; the context optimization result is obtained by processing the target prompt data, the target request data and the target context data using the target compression model; and the target compression model is generated according to any of the above model training methods.
[0191] Step S803: Display the target answer within the graphical user interface.
[0192] Based on the above method steps, a visualization scheme for data processing functions is provided. The terminal device provides a graphical user interface (GUI), which displays at least a data processing scenario. The GUI's display content also includes input components (such as text input boxes, voice input controls, etc.) and output components (such as text display windows, image display windows, audio playback windows, etc.). The user inputs a data processing dialogue request through the input components to specify the target prompt data, target request data, and target context data in the data processing task. After detecting the user's input, the target prompt data, target request data, and target context data are optimized using a target compression model to obtain a context optimization result. Then, the target request data and context optimization result are processed using a target language model to generate the target answer. Finally, the target answer is displayed through the output components within the GUI.
[0193] In this embodiment, the target compression model is trained according to any of the above-mentioned model training methods. In these methods, prompt training data, request training data, and context training data are fused together for training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions and ensures the accuracy and cost-effectiveness of the context optimization results. In other words, the above-mentioned model training method comprehensively utilizes prompt training data, request training data, and context training data to train a target compression model with high accuracy and low cost in context data processing. Based on this, this embodiment utilizes this target compression model for context optimization, achieving high accuracy in context optimization results at a lower cost. Furthermore, a target language model is used to generate answers using the context optimization results. Since the context optimization results are compressed context data, the entire data processing flow is highly efficient and the reasoning accuracy is high. Especially when processing large amounts of target context data (such as very long text), this embodiment demonstrates high data processing efficiency, low cost, and high accuracy in the generated target answer. As described above, the embodiments of this disclosure achieve the technical effects of improving data processing efficiency and accuracy and reducing data processing costs by applying a target compression model, thereby solving the technical problems of high cost, poor accuracy and low efficiency when the model processes context data in related technologies.
[0194] It should be noted that the preferred embodiments of steps S801 to S803 described above can be found in the foregoing description, and will not be repeated here.
[0195] In the aforementioned operating environment, this disclosure also provides another data processing method as shown in FIG9. FIG9 is a flowchart of another data processing method according to an embodiment of this disclosure. As shown in FIG9, the data processing method includes:
[0196] Step S901: In response to the input command applied to the operation interface, display the target prompt data, target request data, and target context data on the operation interface;
[0197] Step S902: In response to the processing command applied to the operation interface, display the target answer on the operation interface;
[0198] The target answer is obtained by using the target language model to generate the answer after processing the target request data and the context optimization result. The context optimization result is obtained by using the target compression model to process the target prompt data, target request data and target context data. The target compression model is generated according to any of the above model training methods.
[0199] The data processing method provided in this embodiment can utilize the aforementioned target compression model to implement a visualized data processing scheme, facilitating human-computer interaction. The user inputs target prompt data, target request data, and target context data by triggering input commands on the operation interface. Further, the user triggers processing commands on the operation interface, instructing the system to drive the target compression model to perform context optimization processing on the target prompt data, target request data, and target context data according to the aforementioned data processing method, obtaining a context optimization result. Then, the target language model is used to perform answer generation processing on the target request data and the context optimization result to obtain the target answer. Further, the system displays the target answer within the operation interface for the user.
[0200] In this embodiment, the target compression model is trained according to any of the above-mentioned model training methods. In these methods, prompt training data, request training data, and context training data are fused together for training, enabling the target compression model to learn the ability to optimize context data in the original text at different context compression granularities. This strengthens the target compression model's understanding of query instructions and ensures the accuracy and cost-effectiveness of the context optimization results. In other words, the above-mentioned model training method comprehensively utilizes prompt training data, request training data, and context training data to train a target compression model with high accuracy and low cost in context data processing. Based on this, this embodiment utilizes this target compression model for context optimization, achieving high accuracy in context optimization results at a lower cost. Furthermore, a target language model is used to generate answers using the context optimization results. Since the context optimization results are compressed context data, the entire data processing flow is highly efficient and the reasoning accuracy is high. Especially when processing large amounts of target context data (such as very long text), this embodiment demonstrates high data processing efficiency, low cost, and high accuracy in the generated target answer. As described above, the embodiments of this disclosure achieve the technical effects of improving data processing efficiency and accuracy and reducing data processing costs by applying a target compression model, thereby solving the technical problems of high cost, poor accuracy and low efficiency when the model processes context data in related technologies.
[0201] It should be noted that the preferred embodiments of steps S901 to S902 described above can be found in the foregoing description, and will not be repeated here.
[0202] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, because according to this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this disclosure.
[0203] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, they can also be implemented by hardware. Based on this understanding, the technical solution of this disclosure, 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 storage medium (such as read-only memory (ROM), random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this disclosure.
[0204] According to an embodiment of this disclosure, an apparatus embodiment for implementing the above-described model training method is also provided. Figure 10 is a schematic structural diagram of a model training apparatus according to an embodiment of this disclosure. As shown in Figure 10, the apparatus includes: an acquisition module 1001 configured to acquire prompt training data, request training data, and context training data, wherein the prompt training data is used to indicate the context compression granularity and the association between the prompt training data and the request training data, the request training data is used to indicate the original request instruction, and the context training data includes at least: the original text to be optimized; and a training module 1002 configured to train an initial compression model based on the prompt training data, request training data, and context training data to generate a target compression model, wherein the target compression model is used to perform context optimization processing on the target prompt data, target request data, and target context data to obtain a context optimization result.
[0205] Optionally, the training module 1002 is further configured to: concatenate the prompt training data, request training data, and context training data according to the message organization template definition format of the initial compression model to obtain the concatenation result; and train the initial compression model based on the concatenation result to generate the target compression model.
[0206] Optionally, the initial compression model includes: a natural language dynamic control module, a bidirectional positional reasoning module, and a lexical evaluation module. The training module 1002 is further configured to: use the natural language dynamic control module to dynamically control the splicing result to obtain context extraction information, wherein the context extraction information is adaptively extracted based on the needs of prompt training data and requested training data; use the bidirectional positional reasoning module to perform lexical-level bidirectional positional reasoning on the context extraction information to obtain positional reasoning results; and use the lexical evaluation module to perform lexical evaluation on the positional reasoning results to generate the target compression model.
[0207] Optionally, the training module 1002 is further configured to: use a lexical evaluation module to evaluate the positional reasoning results to obtain the target loss, wherein the target loss is used to determine the lexical semantic loss and lexical positional loss corresponding to the positional reasoning results; and fine-tune the model parameters of the initial compression model based on the target loss to generate the target compression model.
[0208] Optionally, the training module 1002 is further configured to: use the lexical evaluation module to perform lexical semantic prediction on the position reasoning result to obtain lexical semantic loss, and use the lexical evaluation module to perform lexical position prediction on the position reasoning result to obtain lexical position loss; and calculate the target loss based on the lexical semantic loss and the lexical position loss.
[0209] Optionally, the training module 1002 is further configured to: use a lexical evaluation module to perform lexical semantic prediction on the positional reasoning results to obtain semantic prediction results; and calculate lexical semantic loss based on the semantic prediction results and predefined lexical semantic labels.
[0210] Optionally, the training module 1002 is further configured to: use a lexical evaluation module to predict the position of the position inference result and obtain the position prediction result; and calculate the lexical position loss based on the position prediction result and the predefined lexical position label.
[0211] Optionally, the training module 1002 is further configured to: divide the context training data into multiple non-overlapping windows according to the given window size; and independently concatenate the prompt training data and request training data with the multiple non-overlapping windows one by one according to the message organization template definition format of the initial compressed model to obtain the concatenation result.
[0212] Optionally, in the above-mentioned model training device, the context training data further includes: multi-granularity context optimization training data and query-aware context optimization training data. The multi-granularity context optimization data is used to train the initial compression model to compress the original text to be optimized into multiple optimization results of different granularities based on the prompt training data. The query-aware context optimization data is used to train the initial compression model to perform context optimization aligned with the request training data.
[0213] It should be noted that the acquisition module 1001 and training module 1002 mentioned above correspond to steps S202 to S204 in the embodiments. The two modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiments.
[0214] According to embodiments of this disclosure, an apparatus embodiment for implementing the above-described data processing method is also provided. Figure 11 is a schematic structural diagram of a data processing apparatus according to an embodiment of this disclosure. As shown in Figure 11, the apparatus includes: an acquisition module 1101 configured to acquire target prompt data, target request data, and target context data; a processing module 1102 configured to perform context optimization processing on the target prompt data, target request data, and target context data using a target compression model to obtain a context optimization result; and a generation module 1103 configured to perform answer generation processing on the target request data and context optimization result using a target language model to obtain a target answer; wherein the target compression model is generated according to the model training method of any one of the above embodiments.
[0215] Optionally, the above processing module 1102 is further configured to: concatenate the target prompt data, target request data, and target context data according to the message organization template definition format of the target compression model to obtain the target concatenation result; and perform context optimization processing on the target concatenation result using the target compression model to obtain the context optimization result.
[0216] It should be noted that the above-mentioned acquisition module 1101, processing module 1102 and generation module 1103 correspond to steps S501 to S503 in the embodiment. The three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiment.
[0217] According to embodiments of this disclosure, another apparatus embodiment for implementing the above-described data processing method is also provided. Figure 12 is a schematic diagram of the structure of another data processing apparatus according to an embodiment of this disclosure. As shown in Figure 12, the apparatus includes: an acquisition module 1201 configured to acquire technical document prompt data, technical document query data, and technical document context data; a processing module 1202 configured to perform context optimization processing on the technical document prompt data, technical document query data, and technical document context data using a target compression model to obtain a context optimization result; and a generation module 1203 configured to perform answer generation processing on the technical document query data and context optimization result using a target language model to obtain a technical document guidance answer; wherein the target compression model is generated according to the model training method of any one of the above embodiments.
[0218] It should be noted that the above-mentioned acquisition module 1201, processing module 1202 and generation module 1203 correspond to steps S601 to S603 in the embodiment. The three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiment.
[0219] According to embodiments of this disclosure, another apparatus embodiment for implementing the above-described data processing method is also provided. Figure 13 is a schematic diagram of the structure of another data processing apparatus according to an embodiment of this disclosure. As shown in Figure 13, the apparatus includes: a request module 1301 configured to obtain a data processing request through a first application programming interface, wherein the request data carried in the data processing request includes: target prompt data, target request data, and target context data; and a response module 1302 configured to return a data processing response through a second application programming interface, wherein the response data carried in the data processing response includes: a target answer, wherein the target answer is obtained by performing answer generation processing on the target request data and the context optimization result using a target language model, and the context optimization result is obtained by performing context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model, wherein the target compression model is generated according to any of the above model training methods.
[0220] It should be noted that the above-mentioned request module 1301 and response module 1302 correspond to steps S701 to S702 in the embodiment. The two modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiment.
[0221] According to embodiments of this disclosure, another apparatus embodiment for implementing the above-described data processing method is also provided. Figure 14 is a schematic diagram of the structure of another data processing apparatus according to an embodiment of this disclosure. As shown in Figure 14, the apparatus includes: an acquisition module 1401 configured to acquire a currently input data processing dialogue request, wherein the request data carried in the data processing dialogue request includes: target prompt data, target request data, and target context data; a return module 1402 configured to return a data processing dialogue response in response to the data processing dialogue request, wherein the information carried in the data processing dialogue response includes: a target answer, which is obtained by performing answer generation processing on the target request data and context optimization results using a target language model, and the context optimization results are obtained by performing context optimization processing on the target prompt data, target request data, and target context data using a target compression model, wherein the target compression model is generated according to any of the above model training methods; and a display module 1403 configured to display the target answer in a graphical user interface.
[0222] It should be noted that the above-mentioned acquisition module 1401, return module 1402 and display module 1403 correspond to steps S801 to S803 in the embodiment. The three modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiment.
[0223] According to embodiments of this disclosure, another apparatus embodiment for implementing the above-described data processing method is also provided. Figure 15 is a schematic diagram of the structure of another data processing apparatus according to an embodiment of this disclosure. As shown in Figure 15, the apparatus includes: a first response module 1501, configured to respond to an input command applied to an operation interface, and display target prompt data, target request data, and target context data on the operation interface; a second response module 1502, configured to respond to a processing command applied to the operation interface, and display a target answer on the operation interface; wherein, the target answer is obtained by performing answer generation processing on the target request data and context optimization results using a target language model, and the context optimization results are obtained by performing context optimization processing on the target prompt data, target request data, and target context data using a target compression model, and the target compression model is generated according to any of the above model training methods.
[0224] It should be noted that the first response module 1501 and the second response module 1502 mentioned above correspond to steps S901 to S902 in the embodiments. The two modules and the corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the foregoing embodiments.
[0225] It should be noted that the above-mentioned modules or units may be hardware or software components stored in memory and processed by one or more processors. The above-mentioned modules may also be part of a device and run in a computer terminal.
[0226] It should be noted that the preferred implementation of this embodiment can be found in the relevant descriptions of the foregoing embodiments, and will not be repeated here.
[0227] It should be noted that the preferred embodiments involved in the above embodiments of this disclosure are the same as the solutions, application scenarios and implementation processes provided in the above embodiments, but are not limited to the solutions provided in the above embodiments.
[0228] Embodiments of this disclosure may provide a data processing system, including: a client configured to send target prompt data, target request data, and target context data; a server connected to the client, configured to perform context optimization processing on the target prompt data, target request data, and target context data using a target compression model to obtain a context optimization result, and to perform answer generation processing on the target request data and context optimization result using a target language model to obtain a target answer; the client is further configured to output the target answer; wherein the target compression model is generated according to the model training method of any one of the above.
[0229] Embodiments of this disclosure may provide an electronic device, including: a memory storing an executable program; and a processor configured to run the program, wherein the program executes any of the aforementioned model training methods or data processing methods during runtime.
[0230] Figure 16 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. As shown in Figure 16, the electronic device 160 may include: one or more (only one is shown in the figure) processors 162, memory 164, memory controller, and peripheral interfaces.
[0231] The aforementioned electronic device can be understood as an integrated smart terminal, including but not limited to servers, desktop computers, personal computers (PCs), all-in-one model machines, etc., and the electronic device may have the model described in the above embodiments of this disclosure pre-installed.
[0232] Specifically, this electronic device can pre-install various types of models, including but not limited to models in natural language processing, visual processing, speech processing, code processing, and multimodal task processing, thus providing diverse model selection. In different product forms, this electronic device can support one or more model usage methods, including but not limited to model training, model invocation, model fine-tuning, model deployment, model inference, and application. In some product forms, this electronic device also supports model management, including but not limited to multi-type model management (supporting the management of discriminative, generative, and other model types), model version control (supporting the control of different model versions), and model evaluation (evaluating model performance and effectiveness based on model evaluation tools). In other product forms, this electronic device can also create applications based on models, providing Application Programming Interface (API) invocation capabilities. Models can be invoked into the created applications through the API interface, and application management tools are provided to manage and monitor the applications.
[0233] Furthermore, the electronic device may also include data management (supporting the creation and management of model tuning datasets), a training center (providing rich training resources to help users learn and master artificial intelligence (AI) technology), and basic control capabilities (providing enterprise-level basic control capabilities to ensure the security and efficient operation of the system). Through the above functions, it provides a comprehensive and integrated device for AI development, training, deployment, and application.
[0234] The memory can be configured to store software programs and modules, such as the program instructions / modules corresponding to the model training method, data processing method, model training device, and data processing device in the embodiments of this disclosure. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the model training method or data processing method in the above embodiments. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to terminal A via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0235] The processor can invoke the executable program stored in the memory through the transmission device to execute any of the model training methods or data processing methods described in the above embodiments.
[0236] It will be understood by those skilled in the art that the structure shown in FIG16 is merely illustrative, and the electronic device may also be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, and a mobile internet device (MID), etc. FIG16 does not limit the structure of the above-described electronic device. For example, the electronic device 160 may also include more or fewer components (such as a network interface, a display device, etc.) than shown in FIG16, or have a different configuration than that shown in FIG16.
[0237] Those skilled in the art will understand that all or part of the steps in the various model training methods or data processing methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0238] Embodiments of this disclosure also provide a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium includes a stored executable program, wherein, when the executable program runs, it controls the device where the computer-readable storage medium is located to execute any of the aforementioned model training methods or data processing methods.
[0239] Optionally, in this embodiment, the storage medium may be located in an electronic device.
[0240] Optionally, in this embodiment, the computer-readable storage medium is configured to store an executable program, which, when the executable program is running, controls the device where the computer-readable storage medium is located to execute any of the model training methods or data processing methods described in the above embodiments.
[0241] Embodiments of this disclosure also provide a computer program product. Optionally, in this embodiment, the computer program product may include a computer program that, when executed by a processor, implements the model training method or data processing method provided in the above embodiments.
[0242] Embodiments of this disclosure also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which can be used to store a computer program that, when executed by a processor, implements the model training method or data processing method provided in the above embodiments.
[0243] Embodiments of this disclosure also provide a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, it implements the model training method or data processing method provided in the above embodiments.
[0244] In the above embodiments of this disclosure, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0245] In the several embodiments provided in this disclosure, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0246] The units described above as separate components may or may not be physically separate. 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 units can be selected to achieve the purpose of this embodiment according to actual needs.
[0247] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0248] If the aforementioned integrated units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the model training method or data processing method described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, ROM, RAM, portable hard drives, magnetic disks, or optical disks.
[0249] The above description is only a preferred embodiment of this disclosure. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles of this disclosure, and these improvements and modifications should also be considered within the scope of protection of this disclosure.
Claims
1. A model training method, comprising: Acquire prompt training data, request training data, and context training data, wherein the prompt training data is used to indicate the context compression granularity and the correlation between the prompt training data and the request training data, the request training data is used to indicate the original request instruction, and the context training data includes at least: the original text to be optimized; The initial compression model is trained based on the prompt training data, the request training data, and the context training data to generate a target compression model. The target compression model is used to perform context optimization processing on the target prompt data, the target request data, and the target context data to obtain a context optimization result. 2.The model training method of claim 1, wherein, Training the initial compression model based on the prompt training data, the request training data, and the context training data to generate the target compression model includes: According to the message organization template definition format of the initial compression model, the prompt training data, the request training data, and the context training data are concatenated to obtain the concatenation result. The initial compression model is trained based on the splicing result to generate the target compression model. 3.The model training method of claim 2, wherein, The initial compression model includes: a natural language dynamic control module, a bidirectional positional reasoning module, and a lexical evaluation module. The initial compression model is trained based on the concatenation result to generate the target compression model, which includes: The natural language dynamic control module is used to dynamically control the splicing result to obtain context extraction information, wherein the context extraction information is adaptively extracted based on the requirements of the prompt training data and the request training data; The bidirectional positional reasoning module is used to perform word-level bidirectional positional reasoning on the context-extracted information to obtain positional reasoning results. The lexical evaluation module is used to evaluate the positional reasoning results and generate the target compression model.
4. The model training method according to claim 3, wherein, The target compression model is generated by performing word evaluation on the positional reasoning result using the word evaluation module. The lexical evaluation module is used to evaluate the positional reasoning result to obtain the target loss, wherein the target loss is used to determine the lexical semantic loss and lexical positional loss corresponding to the positional reasoning result; The model parameters of the initial compression model are fine-tuned based on the target loss to generate the target compression model. 5.The model training method of claim 4, wherein, The target loss is obtained by using the lexical evaluation module to evaluate the positional reasoning result and obtaining the lexical evaluation module. The lexical evaluation module is used to perform lexical semantic prediction on the position reasoning result to obtain the lexical semantic loss, and the lexical evaluation module is used to perform lexical position prediction on the position reasoning result to obtain the lexical position loss. The target loss is calculated based on the semantic loss of the lexical units and the positional loss of the lexical units. 6.The model training method of claim 5, wherein, The lexical evaluation module is used to perform lexical semantic prediction on the positional reasoning result, and the lexical semantic loss is obtained, including: The lexical evaluation module is used to perform lexical semantic prediction on the positional reasoning result to obtain the semantic prediction result. The semantic loss is calculated based on the semantic prediction results and the predefined semantic tags of the lexical units.
7. The model training method according to claim 5, wherein, The lexical evaluation module is used to predict the lexical positions of the position inference results, and the resulting lexical position loss includes: The lexical evaluation module is used to predict the position of the position reasoning result to obtain the position prediction result. The lexical position loss is calculated based on the position prediction result and the predefined lexical position labels.
8. The model training method according to claim 2, wherein, According to the message organization template definition format of the initial compression model, the prompt training data, the request training data, and the context training data are concatenated to obtain the concatenation result, which includes: The context training data is divided into multiple non-overlapping windows according to the given window size; According to the message organization template definition format of the initial compression model, the prompt training data and the request training data are independently concatenated with the multiple non-overlapping windows one by one to obtain the concatenation result. 9.The method of Claim 1, wherein The context training data further includes: multi-granularity context optimization training data and query-aware context optimization training data, wherein the multi-granularity context optimization data is used to train the initial compression model to compress the original text to be optimized into multiple optimization results of different granularities based on the prompt training data, and the query-aware context optimization data is used to train the initial compression model to perform context optimization aligned with the request training data. 10.The model training method of claim 7, wherein, The word position tags include start position tags, internal position tags, end position tags, and external position tags.
11. A data processing method, wherein, include: Acquire target hint data, target request data, and target context data; The target prompt data, the target request data, and the target context data are subjected to context optimization processing using a target compression model to obtain the context optimization result. The target language model is used to process the target request data and the context optimization results to generate the target answer. The target compression model is generated according to the model training method described in any one of claims 1 to 10.
12. The data processing method according to claim 11, wherein, The target compression model is used to perform context optimization processing on the target prompt data, the target request data, and the target context data to obtain the following context optimization results: According to the message organization template definition format of the target compression model, the target prompt data, the target request data, and the target context data are concatenated to obtain the target concatenation result; The target compression model is used to perform context optimization processing on the target splicing result to obtain the context optimization result.
13. A data processing method, comprising: Retrieve technical document hints, technical document query data, and technical document context data; The technical document prompt data, the technical document query data, and the technical document context data are subjected to context optimization processing using a target compression model to obtain the context optimization result. The target language model is used to process the technical document query data and the context optimization results to generate answers, thereby obtaining technical document guidance answers. The target compression model is generated according to the model training method described in any one of claims 1 to 10.
14. A data processing method, comprising: A data processing request is obtained through a first application programming interface, wherein the request data carried in the data processing request includes: target prompt data, target request data, and target context data; A data processing response is returned through a second application programming interface, wherein the response data carried in the data processing response includes: a target answer, which is obtained by generating an answer using a target language model on the target request data and the context optimization result; the context optimization result is obtained by optimizing the target prompt data, the target request data and the target context data using a target compression model; and the target compression model is generated according to the model training method described in any one of claims 1 to 10.
15. A data processing method, comprising: Obtain the currently input data processing dialogue request, wherein the request data carried in the data processing dialogue request includes: target prompt data, target request data, and target context data; In response to the data processing dialogue request, a data processing dialogue response is returned, wherein the information carried in the data processing dialogue response includes: a target answer, which is obtained by performing answer generation processing on the target request data and the context optimization result using a target language model; the context optimization result is obtained by performing context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model; and the target compression model is generated according to the model training method described in any one of claims 1 to 10. The target answer is displayed within the graphical user interface.
16. A data processing method, comprising: In response to input commands applied to the user interface, target prompt data, target request data, and target context data are displayed on the user interface. In response to processing instructions applied to the user interface, the target answer is displayed on the user interface. Wherein, the target answer is obtained by processing the target request data and the context optimization result using a target language model to generate an answer; the context optimization result is obtained by processing the target prompt data, the target request data and the target context data using a target compression model to optimize the context; and the target compression model is generated according to the model training method described in any one of claims 1 to 10.
17. A data processing system, comprising: The client is configured to send target hint data, target request data, and target context data; The server, connected to the client, is configured to perform context optimization processing on the target prompt data, the target request data, and the target context data using a target compression model to obtain a context optimization result, and to perform answer generation processing on the target request data and the context optimization result using a target language model to obtain a target answer; The client is also configured to output the target answer; The target compression model is generated according to the model training method described in any one of claims 1 to 10.
18. An electronic device comprising: Memory, which stores executable programs; A processor is configured to run the program, wherein the program, when running, performs the model training method according to any one of claims 1 to 10 or the data processing method according to any one of claims 11 to 16.
19. A computer readable storage medium comprising a stored executable program, wherein, When the executable program is executed, it controls the device containing the computer-readable storage medium to perform the model training method according to any one of claims 1 to 10 or the data processing method according to any one of claims 11 to 16.
20. A computer program product comprising a computer program that, when executed by a processor, implements the model training method of any one of claims 1 to 10 or the data processing method of any one of claims 11 to 16.
