Context input processing method of generative artificial intelligence model

By building a message chain and entering historical context messages into the generative large model, the problem of context truncation in the existing technology is solved, and the generation quality and semantic understanding ability are improved.

CN120106219APending Publication Date: 2025-06-06SHENZHEN SDMC TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510195933.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

Existing generative models are difficult to maintain the generation quality when processing a large number of contexts, which easily leads to information loss or context truncation, affecting the processing effect of multi-round dialogue and multi-task scenarios.

Method used

By building a message chain, build historical context messages based on the generated output messages, and enter these messages into the big model. When the number of message link message nodes exceeds the maximum context window of the big model, use the message link node message digest to create a new message link to ensure the integrity of historical context messages.

Benefits of technology

It effectively avoids the loss or truncation of context messages, improves the quality of generation, and can better capture key information and semantic relationships when handling multiple rounds of tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120106219A_ABST
    Figure CN120106219A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence, and particularly relates to a context input processing method of a generative artificial intelligence model, which constructs a message chain based on an output message of a generative large model so as to construct a historical context message and input the historical context message into the large model. And when the number of message nodes of the message chain exceeds the maximum context window of the large model, creating a new message chain based on the node message digest of the message chain. When the historical context message is constructed, directly acquiring a node message on the current message chain as the historical context message input by the large model, and if the output of the large model refers to the historical context message, reversely deducing to obtain a message group corresponding to the first message chain; and constructing a context by using a message group corresponding to the first message chain, inputting the context into the large model again, and generating the large model again. The context message is prevented from being lost or cut off, and key information and semantic management can be fully captured when multiple rounds of tasks are processed, so that the generation quality is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a context input processing method for a generative artificial intelligence model. Background Art

[0002] With the rapid development of artificial intelligence technology, generative large models have become the focus of research and application. In the application scenario of multi-round dialogue, the context information input to the large model will continue to grow over time. Due to the limited input context length of the generative large model, very long texts or complex tasks may cause information loss or context truncation, and fail to fully capture the key information and semantic relationships of the input, affecting the generation quality. Secondly, when understanding the contextual relationship in long texts, the model is prone to deviating from the context, especially when dealing with multi-round dialogues or multi-task scenarios, and cannot effectively maintain dependencies over a long time span.

[0003] In natural language processing, truncated contextual input may lead to unclear semantic understanding, affecting the accuracy and fluency of the dialogue system; in the field of image generation, truncated contextual input may limit the quality and diversity of generated images. In the existing technology, some large generative models use improved algorithms such as attention mechanisms to alleviate these contextual input problems, but when processing large data sets or multimodal inputs, there is still high computational overhead and memory consumption. Summary of the invention

[0004] The technical problem to be solved by the present invention is to overcome the defect in the prior art that large generative models are difficult to process a large amount of context, resulting in reduced generation quality, and to provide a context input processing method for a generative artificial intelligence model.

[0005] A context input processing method for a generative artificial intelligence model comprises the following method steps: Step S1: The user initiates a message query request and inputs it into the message processing module; Step S2: the message processing module receives the message query request, obtains the query message therein, and requests the context management module for the historical context message; the context management module receives and generates the historical context message and returns it to the message processing module; the historical context message is generated based on the message chain, and the message chain includes a message group consisting of a summary of the previous query message and the answer message; Step S3: The message processing module constructs input prompt words based on historical context messages and inputs them into the large model module; Step S4: The large model module generates a reply message based on the message prompt word and returns it to the message processing module; the reply message includes the reply text and the context index; Step S5: the message processing module determines whether the context message is located on the 0th message chain according to the context index; if the context message is located on the 0th message chain, the answer text is returned to the user and a synchronization message is sent to the context management module; if the context message is not located on the 0th message chain, the message group on the previous message chain is reversed and step S5 is repeated; Step S6: The context management module receives the synchronization message, creates a new message chain and updates each message chain.

[0006] Furthermore, in the step S2, the kth message chain is defined as the current message chain, and the kth message chain is obtained based on the summary of the k-1th message chain.

[0007] Furthermore, in step S2, the maximum context window size of the large model module is defined as w, and the maximum length of the message generated by the large model module is d, then the maximum number of context messages input into the large model each time is n=w / d.

[0008] Furthermore, the maximum context window size is 1024, and the maximum length of the message generated by the large model module is 340, so the maximum number of context messages input into the large model each time is 3.

[0009] Furthermore, in a user query, the user sends multiple query messages in sequence, and the message processing module returns a corresponding answer text each time; When the user sends the kth query message, the 0th message chain is constructed, and the 0th message chain is M1M2…Mk; If k>n x , then construct the xth message chain, divide every n query messages from left to right in the x-1th message chain into a message block, and finally at least one query message is a message block, and summarize each of the message blocks in turn to form the xth message chain; Wherein, x is a positive integer, and the output of the summary is less than the maximum length d of the message; at this time, the historical context message is the message chain with the largest sequence number.

[0010] Furthermore, in step S3, the message processing module constructs an input prompt word based on the historical context message, and the prompt word includes the historical context message, the current query message and the output format.

[0011] Furthermore, step S5 includes the following method steps: Step S5.1: The message processing module receives the answer message and parses it to obtain the answer text and context index; Step S5.2: If the value of the context index is 0, jump to step S5.5, otherwise jump to step S5.3; Step S5.3: Determine the message chain where the context message is located. If it is the 0th message chain, jump to step S5.5; otherwise, jump to step S5.4; Step S5.4: reversely infer the message group on the previous message chain according to the current message chain sequence number and context index, build a historical context input large model module based on the message group on the previous message chain, obtain the answer message, and return to step S5.1; Step S5.5: Synchronize the answer text to the context management module and return it to the user.

[0012] A context input processing system for a generative artificial intelligence model, comprising a message processing module, a context management module and a large model module; The message processing module is used to receive the user's query request and return the answer text to the user; the message processing module is used to request the context management module for historical context messages, construct input prompt words based on the historical context messages and message chains, input the input prompt words into the large model module and receive the returned answer message; The context management module is used to receive synchronization messages from the message processing module, and to create and update message chains.

[0013] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the context input processing method of the generative artificial intelligence model are implemented as described above.

[0014] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the context input processing method of the generative artificial intelligence model as described above.

[0015] Beneficial effects: The present invention discloses a context input processing method for a generative artificial intelligence model, which constructs a message chain based on the output message of the generative large model, thereby constructing a historical context message to be input into the large model. When the number of message nodes in the message chain exceeds the maximum context window of the large model, a new message chain is created based on the node message summary of the message chain. When constructing the historical context message, the node message on the current message chain is directly obtained as the historical context message input to the large model. If the output of the large model refers to the historical context message, the message group corresponding to the first message chain is obtained by reverse inference, and then the context is constructed with the message group corresponding to the first message chain and input into the large model again, so that the large model can be generated again. The loss or truncation of context messages is avoided, and key information and semantic management can be fully captured when processing multiple rounds of tasks, thereby improving the generation quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0017] Figure 1 It is a schematic block diagram of the main structure of the system of the present invention; Figure 2 It is a schematic diagram of the steps of the present invention. DETAILED DESCRIPTION

[0018] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific embodiments disclosed below.

[0019] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present application, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0020] Reference Figure 1 and Figure 2 As shown, this embodiment discloses a context input processing method of a generative artificial intelligence model, including the following method steps: Step S1: The user initiates a message query request and inputs it into the message processing module; Step S2: the message processing module receives the message query request, obtains the query message therein, and requests the context management module for the historical context message; the context management module receives and generates the historical context message and returns it to the message processing module; the historical context message is generated based on the message chain, and the message chain includes a message group consisting of a summary of the previous query message and the answer message; Step S3: The message processing module constructs input prompt words based on historical context messages and inputs them into the large model module; Step S4: The large model module generates a reply message based on the message prompt word and returns it to the message processing module; the reply message includes the reply text and the context index; Step S5: the message processing module determines whether the context message is located on the 0th message chain according to the context index; if the context message is located on the 0th message chain, the answer text is returned to the user and a synchronization message is sent to the context management module; if the context message is not located on the 0th message chain, the message group on the previous message chain is reversed and step S5 is repeated; Step S6: The context management module receives the synchronization message, creates a new message chain and updates each message chain.

[0021] Specifically, in step S2, the kth message chain is defined as the current message chain, and the kth message chain is obtained based on the summary of the k-1th message chain.

[0022] Define the maximum context window size of the large model module as w, and the maximum length of the message generated by the large model module as d. Then, the maximum number of context messages input into the large model each time is n=w / d.

[0023] As a preference of this embodiment, the maximum context window size is 1024, the maximum length of the message generated by the large model module is 340, and the maximum number of context messages input into the large model each time is 3.

[0024] Specifically, in a user query, the user sends multiple query messages in sequence, and the message processing module returns a corresponding answer text each time; When the user sends the kth query message, the 0th message chain is constructed, and the 0th message chain is M1M2…Mk; where M1 represents the input content of the user's first message query request during a continuous conversation, M2 represents the input content of the user's second message query request, and so on, Mk represents the input content of the user's kth message query request, that is, the message. {} represents the representation form of the message list.

[0025] If k>n x , then construct the xth message chain, divide every n query messages from left to right in the x-1th message chain into a message block, and finally at least one query message is a message block, and summarize each of the message blocks in turn to form the xth message chain; Wherein, x is a positive integer, and the output of the summary is less than the maximum length d of the message; at this time, the historical context message is the message chain with the largest sequence number.

[0026] In this embodiment, when the context management module receives the first synchronization message, the 0th message chain is M1, and the historical context message is {M1}; When the context management module receives the second synchronization message, the 0th message chain is M1M2, and the historical context message is {M1M2}; When the context management module receives the third synchronization message, the 0th message chain is M1M2M3, and the historical context message is {M1M2M3}; When the context management module receives the 4th synchronization message, the 0th message chain is M1M2M3M4, the 1st message chain is M`1M`2, and the historical context message is {M`1M`2}; where M`1=summary{M1M2M3}, M`2=M4, and summary means summary; When the context management module receives the fifth synchronization message, the message chain of the 0th message is M1M2M3M4M5, the message chain of the 1st message is M`1M`2, and the historical context message is {M`1M`2}; where M`1=summary{M1M2M3}, M`2=summary{M4M5}; When the context management module receives the sixth synchronization message, the message chain of the 0th message is M1M2M3M4M5M6, the message chain of the 1st message is M`1M`2, and the historical context message is {M`1M`2}; where M`1=summary{M1M2M3}, M`2=summary{M4M5M6}; When the context management module receives the 7th synchronization message, the 0th message chain is M1M2M3M4M5M6M7, the 1st message chain is M`1M`2M`3, and the historical context message is {M`1M`2M`3}; among them, M`1=summary{M1M2M3}, M`2=summary{M4M5M6}, and M`3=M7; When the context management module receives the 8th synchronization message, the 0th message chain is M1M2M3M4M5M6M7M8, the 1st message chain is M`1M`2M`3, and the historical context message is {M`1M`2M`3}; among them, M`1=summary{M1M2M3}, M`2=summary{M4M5M6}, and M`3= summary{M7M8}; When the context management module receives the 9th synchronization message, the 0th message chain is M1M2M3M4M5M6M7M8M9, the 1st message chain is M`1M`2M`3, and the historical context message is {M`1M`2M`3}; among them, M`1=summary{M1M2M3}, M`2=summary{M4M5M6}, and M`3= summary{M7M8M8}; When the context management module receives the 10th synchronization message, the 0th message chain is M1M2M3M4M5M6M7M8M9M10, the 1st message chain is M`1M`2M`3M`4, the 2nd message chain is M``1M``2, and the historical context message is {M``1M``2}; among them, M`1=summary{M1M2M3}, M`2=summary{M4M5M6}, M`3=summary{M7M8M8}, M``2=M`4, M`4=M10; When the context management module receives the 11th synchronization message, the 0th message chain is M1M2M3M4M5M6M7M8M9M10M11, the 1st message chain is M`1M`2M`3M`4, the 2nd message chain is M``1M``2, and the historical context message is {M``1M``2}; among them, M`1=summary{M1M2M3}, M`2=summary{M4M5M6}, M`3= summary{M7M8M8}, M``2=M`4, M`4=summary{M10M11}; And so on.

[0027] In this embodiment, the summarization process represented by summary is completed by the large model.

[0028] Specifically, in step S3, the message processing module constructs an input prompt word based on the historical context message, and the prompt word includes the historical context message, the current query message and the output format.

[0029] In this embodiment, the format of the input prompt word is as follows:

[0030] Among them, prompt represents the input prompt word, context represents the historical context message, text represents the answer text, context_index represents the context index, and query represents the query request.

[0031] The step S5 comprises the following method steps: Step S5.1: The message processing module receives the answer message and parses it to obtain the answer text and context index; Step S5.2: If the value of the context index is 0, jump to step S5.5, otherwise jump to step S5.3; Step S5.3: Determine the message chain where the context message is located. If it is the 0th message chain, jump to step S5.5; otherwise, jump to step S5.4; Step S5.4: Based on the current message chain sequence number k and the context index context_index, inversely deduce the message group on the previous message chain, construct the historical context input large model module based on the message group on the previous message chain to obtain the response message, and return to Step S5.1; In Step S5.4, the context index is an integer greater than zero, representing the context_index-th message. context_index = 0 represents the 1st message, context_index = 1 represents the 2nd message, context_index = 2 represents the 3rd message, and so on. If the current message chain sequence number is k and the context index is context_index, representing the 3rd message of the k-th message chain, this message is obtained by summarizing several messages on the (k - 1)-th message chain. The context index of the (k - 1)-th message chain can be calculated according to the maximum context message number.

[0032] In Step S5.4, assume the number of messages on the k-th message chain is s, and the maximum context message number is d; if s = n, the new historical context is constructed with the messages on the k-th message chain; if s < n, the new historical context is constructed with the messages on the k-th message chain and the messages after the s*d-th message on the (k - 1)-th message chain; thus, the historical context is constructed.

[0033] Step S5.5: Synchronize the response text to the context management module and return it to the user.

[0034] As a further improvement of this embodiment, it further includes Step S7.

[0035] Step S7: The message processing module returns a response and returns the response text to the user.

[0036] It further includes Step S8 and Step S9.

[0037] Step S8: The context management module inputs the historical context messages into the large model module; Step S9: The large model module generates a summary based on the historical context messages.

[0038] This embodiment provides a context input processing system for a generative artificial intelligence model, which realizes context input processing based on the above steps, including a message processing module, a context management module, and a large model module; The message processing module is used to receive the user's query request and return a response text to the user; the message processing module is used to request historical context messages from the context management module, construct an input prompt word based on the historical context messages and the message chain, input the input prompt word into the large model module, and receive the returned response message; The context management module is used to receive synchronization messages from the message processing module, and to create and update message chains.

[0039] This embodiment also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the context input processing method of the generative artificial intelligence model as described above when executing the computer program.

[0040] This embodiment also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the context input processing method of the generative artificial intelligence model as described above.

[0041] The present embodiment provides a context input processing method for a generative artificial intelligence model, which constructs a message chain based on the output message of the generative large model, thereby constructing a historical context message and inputting it into the large model. When the number of message nodes in the message chain exceeds the maximum context window of the large model, a new message chain is created based on the node message summary of the message chain. When constructing the historical context message, the node message on the current message chain is directly obtained as the historical context message input to the large model. If the output of the large model refers to the historical context message, the message group corresponding to the first message chain is obtained by reverse inference, and then the context is constructed with the message group corresponding to the first message chain and input into the large model again, so that the large model can be generated again. It avoids the loss or truncation of context messages, and can fully capture key information and semantic management when processing multiple rounds of tasks, thereby improving the generation quality.

[0042] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0043] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached claims.

Claims

1. A context input processing method for a generative artificial intelligence model, characterized in that: The method comprises the following steps: Step S1: The user initiates a message query request and inputs it into the message processing module; Step S2: the message processing module receives the message query request, obtains the query message therein, and requests the context management module for the historical context message; the context management module receives and generates the historical context message and returns it to the message processing module; the historical context message is generated based on the message chain, and the message chain includes a message group consisting of a summary of the previous query message and the answer message; Step S3: The message processing module constructs input prompt words based on historical context messages and inputs them into the large model module; Step S4: The large model module generates a reply message based on the message prompt word and returns it to the message processing module; the reply message includes the reply text and the context index; Step S5: The message processing module determines whether the context message is located on the 0th message chain according to the context index; If the context message is on the 0th message chain, the answer text is returned to the user and a synchronization message is sent to the context management module; If the context message is not on the 0th message chain, reverse the message group on the previous message chain and repeat step S5; Step S6: The context management module receives the synchronization message, creates a new message chain and updates each message chain.

2. The context input processing method of a generative artificial intelligence model according to claim 1, characterized in that: In the step S2, the kth message chain is defined as the current message chain, and the kth message chain is obtained based on the summary of the k-1th message chain.

3. The context input processing method of a generative artificial intelligence model according to claim 2, characterized in that: In step S2, the maximum context window size of the large model module is defined as w, and the maximum length of the message generated by the large model module is d. Then, the maximum number of context messages input into the large model each time is n=w / d.

4. The context input processing method of a generative artificial intelligence model according to claim 3, characterized in that: The maximum context window size is 1024, and the maximum length of the message generated by the large model module is 340. Therefore, the maximum number of context messages input into the large model each time is 3.

5. The context input processing method of a generative artificial intelligence model according to claim 3, characterized in that: In a user query, the user sends multiple query messages in sequence, and the message processing module returns a corresponding answer text each time; When the user sends the kth query message, the 0th message chain is constructed, and the 0th message chain is M1M2…Mk; If k>n x , then construct the xth message chain, divide every n query messages from left to right in the x-1th message chain into a message block, and finally at least one query message is a message block, and summarize each of the message blocks in turn to form the xth message chain; Wherein, x is a positive integer, and the output of the summary is less than the maximum length d of the message; at this time, the historical context message is the message chain with the largest sequence number.

6. The context input processing method of a generative artificial intelligence model according to claim 1, characterized in that: In the step S3, the message processing module constructs an input prompt word based on the historical context message, and the prompt word includes the historical context message, the current query message and the output format.

7. The context input processing method of a generative artificial intelligence model according to claim 1, characterized in that: The step S5 comprises the following method steps: Step S5.1: The message processing module receives the answer message and parses it to obtain the answer text and context index; Step S5.2: If the value of the context index is 0, jump to step S5.5, otherwise jump to step S5.3; Step S5.3: Determine the message chain where the context message is located. If it is the 0th message chain, jump to step S5.5; otherwise, jump to step S5.4; Step S5.4: reversely infer the message group on the previous message chain according to the current message chain sequence number and context index, build a historical context input large model module based on the message group on the previous message chain, obtain the answer message, and return to step S5.1; Step S5.5: Synchronize the answer text to the context management module and return it to the user.

8. A context input processing system for a generative artificial intelligence model, characterized in that: Includes message processing module, context management module and large model module; The message processing module is used to receive the user's query request and return the answer text to the user; the message processing module is used to request the context management module for historical context messages, construct input prompt words based on the historical context messages and message chains, input the input prompt words into the large model module and receive the returned answer message; The context management module is used to receive synchronization messages from the message processing module, and to create and update message chains.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the context input processing method of the generative artificial intelligence model as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the context input processing method of the generative artificial intelligence model as described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Streaming AI dialogue data processing method and device, medium and program product

    CN121705402A