Large model context processing method and device, equipment, storage medium and program product

By constructing a source interaction data tree and a context view tree, and combining a back-to-source compression operation with a dynamic pressure coefficient, the problem of decreased understanding accuracy of large language models in long-range, multi-topic dialogues is solved, and accurate responses to new requests are achieved.

CN121615794BActive Publication Date: 2026-05-01ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610149281.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-02-03
Publication Date
2026-05-01
Estimated Expiration
2046-02-03

AI Technical Summary

Technical Problem

Existing large language models suffer from decreased accuracy in understanding new requests in long-range, multi-topic dialogues due to the forgetting of historical interaction information, resulting in an inability to respond accurately.

Method used

Construct source interaction data tree and context view tree, trigger source compression operation through dynamic pressure coefficient, optimize context length, ensure lossless storage and traceability of historical information, maintain context clarity by adopting topic organization structure, and retain key semantics through cyclic compression mechanism.

Benefits of technology

It significantly improves the accuracy of large language models in understanding and responding to new user tasks, ensuring that the provided contextual content is clearly structured, concise, and semantically complete.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121615794B_ABST
    Figure CN121615794B_ABST
Patent Text Reader

Abstract

The application provides a large model context processing method and device, computer equipment, a storage medium and a computer program product. The method comprises: obtaining a new action step request, updating a context view tree and a source interaction data tree based on the new action step request, and determining a pressure coefficient according to the updated context view tree; determining whether there is a to-be-compressed node in the updated context view tree according to the pressure coefficient; if there is, performing source compression on the to-be-compressed node in combination with the updated source interaction data tree and the updated context view tree, updating the updated context view tree and the updated source interaction data tree, returning to the step of determining the pressure coefficient according to the updated context view tree until there is no to-be-compressed node; and expanding the context content input into a large language model based on the updated context view tree. The method can enable the large language model to accurately understand and respond to the new action step request.
Need to check novelty before this filing date? Find Prior Art

Description

Large model context processing methods, apparatuses, devices, storage media, and program products Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, storage medium, and program product for large model context processing. Background Technology

[0002] Large language models typically manage excessively long dialogue contexts by setting a fixed token length limit and using methods such as digest compression, in order to achieve continuous multi-turn interactions.

[0003] As the number of dialogue rounds increases or tools return large amounts of text, the system summarizes or truncates historical content that exceeds limits to accommodate new information. However, this approach relies primarily on a linear, irreversible information compression process. Once content is summarized, the original details and constraints may be permanently lost. Subsequent compression will build upon existing summaries, causing information to become distorted round by round, much like a game of telephone. Furthermore, the mixing of dialogue content from different topics interferes with the large language model's accurate understanding and response to the current problem.

[0004] Therefore, existing technologies suffer from the problem that when users engage in long-term, multi-topic dialogues using a large language model, the model's accuracy in understanding new requests decreases, resulting in an inability to respond accurately. Summary of the Invention

[0005] Based on this, this application aims to at least solve one of the aforementioned technical defects, particularly the technical defect in the prior art where, when users engage in long-term, multi-topic dialogues using a large language model, the large language model's accuracy in understanding new requests decreases due to the forgetting of historical interaction information, thus making it unable to respond accurately. This application provides a large language model context processing method, apparatus, computer device, computer-readable storage medium, and computer program product that enables the large language model to accurately understand and respond to new requests when users engage in long-term, multi-topic dialogues using a large language model.

[0006] Firstly, this application provides a method for processing large model contexts, the method including:

[0007] Construct the source interaction data tree and context view tree for the current dialogue event flow;

[0008] Obtain new action step requests belonging to the current dialogue event stream; based on the new action step requests, update the context view tree and the source interaction data tree; and determine the pressure coefficient of the current context based on the updated context view tree.

[0009] Based on the pressure coefficient, determine whether there are nodes to be compressed in the updated context view tree;

[0010] If it exists, then combine the updated source interaction data tree and the updated context view tree to perform a back-to-source compression operation on the node to be compressed, so as to update the updated context view tree and the updated source interaction data tree, and return to the step of determining the pressure coefficient of the current context based on the updated context view tree, until there is no node to be compressed in the updated context view tree;

[0011] Based on the updated context view tree, expand it into context content and input it into the large language model, so that the large language model can combine the context content to output the request response result for the new action step request.

[0012] In one embodiment, the context view tree organizes each topic thread node according to topic type; each topic thread node is attached with the latest round content representation of its own round nodes, and each round node is attached with the latest action step content representation of its own action step nodes; each action step node records the request and response results of each action step request;

[0013] Based on the pressure coefficient, determine whether there are nodes to be compressed in the updated context view tree, including:

[0014] Determine the importance score of each topic thread node in the updated context view tree, and determine the upper limit of the token length of each topic thread node based on the importance score and stress coefficient of each topic thread node;

[0015] Determine the importance score of each round node in the updated context view tree, and determine the upper limit of the token length of each round node based on the importance score of each round node and the upper limit of the token length of the topic thread node to which each round node belongs;

[0016] Determine the importance score of each action step node in the updated context view tree, and determine the upper limit of the token length of each action step node based on the importance score of each action step node and the upper limit of the token length of the round node to which each action step node belongs.

[0017] Determine the token length of each topic thread node, each round node, and each action step node in the updated context view tree. Based on the token length and upper limit of each topic thread node, the token length and upper limit of each round node, and the token length and upper limit of each action step node, determine whether there are any nodes to be compressed in the updated context view tree.

[0018] In one embodiment, the source interaction data tree is loaded with the content representations of each round node in the order of interaction time, and each round node is loaded with the content representations of each action step node belonging to itself; the source interaction data tree maintains the compressed version chain of each action step node; combining the updated source interaction data tree and the updated context view tree, a back-to-source compression operation is performed on the node to be compressed to update the updated context view tree and the updated source interaction data tree, including:

[0019] If the node to be compressed is an action step node, then obtain the compressed version chain of the action step node from the source interaction data tree, and obtain the original action step content representation of the action step node based on the compressed version chain.

[0020] The original action step content representation is compressed to obtain a new action step content representation for the action step node; the token length corresponding to the new action step content representation is less than a preset ratio of the token length corresponding to the latest action step content representation of the action step node.

[0021] Replace the latest action step content representation of the action step node in the updated context view tree with the new action step content representation of the action step node, and record the new action step content representation of the action step node in the updated source interaction data tree.

[0022] In one embodiment, the source interaction data tree mounts the content representations of each round node in the order of interaction time; the source interaction data tree maintains a compressed version chain of each round node; each round node corresponds to a multi-topic round, a single-topic round, or a single-topic round slice; the single-topic round slice is obtained by performing topic slicing on each action step request in a multi-topic round; after recording the new action step content representation of the action step node in the updated source interaction data tree, the method further includes:

[0023] Return to the steps that determine the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree. If it is determined that there are still nodes to be compressed in the updated context view tree and the nodes to be compressed are round nodes, obtain the compressed version chain of the round node and the compressed version chain of each associated action step node involved in the round node from the source interaction data tree.

[0024] Based on the compressed version chain of the round node and the compressed version chain of each associated action step node, obtain the original round content representation of the round node;

[0025] The original round content representation is compressed to obtain a new round content representation for the round node; the token length corresponding to the new round content representation is less than a preset ratio of the token length corresponding to the latest round content representation of the round node;

[0026] Replace the latest round content representation of the round node in the updated context view tree with the new round content representation of the round node, and record the new round content representation of the round node in the updated source interaction data tree.

[0027] In one embodiment, the updated context view tree records the past topic content representations of each topic thread node and maintains the compressed version chain of each topic thread node; after the step of recording the new round content representation of the round node in the updated source interaction data tree, the method further includes:

[0028] Return to the steps that determine the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree. If there are nodes to be compressed in the updated context view tree and the nodes to be compressed are topic thread nodes, select the topic thread node with the largest token length over-limit ratio from the topic thread nodes to be compressed as the target node.

[0029] Obtain the compressed version chain of the target node from the updated context view tree, and obtain the compressed version chain of each associated round node involved in the target node and the compressed version chain of each associated action step node involved in each associated round node from the source interaction data tree.

[0030] Based on the compressed version chain of the target node, the compressed version chain of each associated round node, and the compressed version chain of each associated action step node, obtain the original topic content representation of the target node.

[0031] The original topic content representation of the target node is compressed using a preset compression strategy to obtain a new topic content representation of the target node; the token length of the new topic content representation is less than a preset ratio of the token length of the latest topic content representation.

[0032] The new topic content representation of the target node is stored as the latest topic content representation of the target node in the updated context view tree.

[0033] In one embodiment, the method further includes:

[0034] Determine whether the number of topic thread nodes in the updated context view tree exceeds a preset threshold. If so, determine the topic thread node with the lowest importance score from the updated context view tree as the first topic thread node, and determine the other topic thread nodes whose topics are most similar to the first topic thread node as the second topic thread nodes.

[0035] The first topic thread node and the second topic thread node are merged to generate a new topic thread and the topic content representation corresponding to the new topic thread;

[0036] Update the context view tree based on the topic content representation corresponding to the new topic thread.

[0037] Secondly, this application provides a large model context processing apparatus, the apparatus comprising:

[0038] The building module is used to construct the source interaction data tree and context view tree for the current dialogue event stream;

[0039] The update module is used to obtain new action step requests belonging to the current dialogue event stream, update the context view tree and source interaction data tree based on the new action step requests, and determine the pressure coefficient of the current context based on the updated context view tree.

[0040] The determination module is used to determine whether there are nodes to be compressed in the updated context view tree based on the pressure coefficient.

[0041] The compression module is used to perform a back-to-source compression operation on the node to be compressed, if it exists, by combining the updated source interactive data tree and the updated context view tree, in order to update the updated context view tree and the updated source interactive data tree, and return the step of determining the pressure coefficient of the current context based on the updated context view tree, until there is no node to be compressed in the updated context view tree.

[0042] The generation module expands the updated context view tree into context content and inputs it into the large language model, so that the large language model can combine the context content to output the request response result for the new action step request.

[0043] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.

[0044] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.

[0045] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.

[0046] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0047] The large-scale language model context processing method, apparatus, device, storage medium, and program product provided in this application construct a source interaction data tree and a context view tree for the current dialogue event stream; obtain new action step requests belonging to the current dialogue event stream; update the context view tree and source interaction data tree based on the new action step requests; determine the pressure coefficient of the current context based on the updated context view tree; determine whether there are nodes to be compressed in the updated context view tree based on the pressure coefficient; if so, perform a back-to-source compression operation on the nodes to be compressed in conjunction with the updated source interaction data tree and the updated context view tree to update the updated context view tree and the updated source interaction data tree, and return to the step of determining the pressure coefficient of the current context based on the updated context view tree, until there are no nodes to be compressed in the updated context view tree; expand the updated context view tree into context content and input it into the large language model, so that the large language model can combine with the context view tree. The following content outputs the request and response results for the new action step request; thus, a dual-tree cross structure of source interaction data tree and context view tree is constructed, and a dynamic pressure coefficient is introduced to trigger intelligent back-to-source compression operation. This solves the problem of decreased model understanding accuracy caused by the distortion of historical information due to the lengthy and chaotic context and the oversimplification of the summarization strategy in long-range, multi-topic dialogues. The source interaction data tree ensures the lossless storage and traceability of historical information, while the context view tree organizes the latest information by topic, maintaining a clear structure of the context. The cyclic compression mechanism based on the pressure coefficient can dynamically optimize the context length within the model's capabilities. At the same time, by compressing back-to-source operations and adaptively setting different token length upper limits for different levels to maximize the preservation of key semantics, the context content provided to the large language model is always clearly structured, concise, and semantically complete, thereby significantly improving the accuracy of the large language model's understanding and response to new user tasks. Attached Figure Description

[0048] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0049] Figure 1 is a flowchart illustrating a large model context processing method in one embodiment;

[0050] Figure 2 is a schematic diagram of a context view tree in one embodiment;

[0051] Figure 3 is a flowchart of a round node in one embodiment;

[0052] Figure 4 is a schematic diagram of a topic thread node in one embodiment;

[0053] Figure 5 is a schematic diagram of a round-slice node in one embodiment;

[0054] Figure 6 is a schematic diagram of node affiliation and member pointers in one embodiment;

[0055] Figure 7 is a schematic diagram of the compressed version and tree affiliation in one embodiment;

[0056] Figure 8 is a schematic diagram of the tree structure of a sub-proxy scenario in one embodiment;

[0057] Figure 9 is a schematic diagram of the data processing flow of the round slicing module in one embodiment;

[0058] Figure 10 is a schematic diagram of the data processing flow of the source compression strategy in one embodiment;

[0059] Figure 11 is a schematic diagram of a round node including a merged action step node in one embodiment;

[0060] Figure 12 is a schematic diagram of the module interaction of a large model context processing system in one embodiment;

[0061] Figure 13 is a structural block diagram of a large model context processing device in one embodiment;

[0062] Figure 14 is an internal structure diagram of a computer device in one embodiment. Detailed Implementation

[0063] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0064] In an exemplary embodiment, as shown in FIG1, a large model context processing method is provided. Taking the application of this method to a server as an example, the method includes the following steps S102 to S110. Wherein:

[0065] Step S102: Construct the source interaction data tree and context view tree for the current dialogue event stream.

[0066] The current dialogue event flow refers to the complete history of a series of continuous interactions between the user and the large language model.

[0067] The source interaction data tree is a tree-structured data structure organized in strict chronological order, which archives the complete and lossless history of the dialogue. Its nodes store all versions of the content representation of a round (a complete request or goal initiated by a user or sub-agent) and its subsequent action steps (multiple sub-steps performed by the model to complete a task).

[0068] In this application, the Source Interaction Tree maintains round nodes in the order of actual interaction time, without topic classification. When a round contains content from multiple topics, round slicing is performed, thereby generating multiple round slice nodes by linking to the corresponding round node. In this application, a round containing content from a single topic is called a single-topic round, a round containing content from multiple topics is called a multi-topic round, and the slice obtained by slicing multi-topic rounds is called a single-topic round slice. Each single-topic round node, single-topic round slice node, and action step node maintains a compressed version chain (L0→L1→…) to record the evolution relationship from the original content representation L0 to each level of content representation (i.e., each level of compressed content) L1…Ln.

[0069] The context view tree organizes topic thread nodes according to topic type. Each topic thread node carries the latest task content representation of each round node belonging to the corresponding topic type, and each round node carries the latest action step content representation of each action step node belonging to the round node. In other words, the context view tree is a tree-shaped data structure organized by topic type (such as travel planning, code debugging) to dynamically generate the currently valid context for the large language model. Each topic thread node only links to the latest content representation of each round and action step under that topic to maintain a clear context structure. In this application, the context view tree (see Figure 2) organizes round nodes, round slice nodes, and can also organize summary round nodes, etc., for budget allocation and compression decisions, and to maintain topic consistency within threads. The root node `start` is an empty node, connecting each topic thread subtree. The context view tree, expanded by depth-first search (sorted by the time order of topic thread creation or the importance score of topic threads), becomes the context input to the large language model.

[0070] In this context, a round node can be represented as a Turn. The boundaries of a round are fixed, and a round contains multiple action steps, as shown in Figure 3. There are three triggering conditions for starting a new round: a new user input triggers a new round, an agent starts a sub-agent triggers a new round, and a sub-agent returns a result triggers a new round.

[0071] An action step node can be represented as an AS (Action Step), which is the smallest unit of action in a dialogue. An action step corresponds to an action such as a model returning an assistant, a tool calling a tool, a tool returning a tool result, an error message, a system message, or a digest message. Each action step corresponds to only one of these types.

[0072] The topic thread node can be represented as a Topic Thread. The topic thread node maintains a member list, which consists of multiple single topic round nodes or single topic round slice nodes with the same or similar topics. The topic thread node is used for thread-level budget allocation and compression decisions, and also for maintaining topic consistency within the thread (triggering round slice correction when necessary), as shown in Figure 4.

[0073] In this context, a single-topic-turn slice node can be represented as a Shard. By splitting a multi-topic-turn into several views with consistent topics and assigning them to corresponding topic thread nodes, topic mixing within threads is avoided. The data structure of a single-topic-turn slice node is the same as that of a single-topic-turn node. When performing topic sharding on a multi-topic-turn node, the LLM can be called to rewrite the multi-topic-turn, generating the slice content of each single-topic-turn slice node. Sharding and compression of multi-topic-turn nodes can be decoupled, meaning sharding can be performed without compression. In practical applications, when a turn node n contains multiple topics, the LLM is called to cut the multi-topic-turn node into multiple single-topic-turn slice nodes. For example, when a multi-topic-turn node n includes two topics, it is cut into single-topic-turn slice nodes n.1 and n.2. In practice, the number of single-topic-turn slice nodes obtained is equal to the number of topics involved in a multi-topic-turn node, as shown in Figure 5. The timing constraint for slicing in multi-topic rounds is that the system does not perform round slicing before the current round ends, and performs multi-topic judgment and round slicing after the current round ends (i.e. after the action step sequence of the current round is collected and solidified into round nodes).

[0074] Regarding the compressed version L of this application, L0 represents the original text, L1 represents the result compressed once, and Ln represents the result compressed n times. To suppress the digest-to-digest drift, when the compressed input contains L≥1 content, it is preferentially expanded back to the source before compression, and an upper limit can be set for the length of Ln, for example, not exceeding a certain proportion of the length of L(n-1).

[0075] To support traceable, source-oriented, and multi-level compression context management, this application introduces version chain and source tracking fields on entities such as action steps, rounds (including single-topic rounds and single-topic round slices), and topic threads. These fields include, but are not limited to: *_id, representing the unique ID of the current version node (e.g., as_010_L0, turn_012_L1); origin_*_id, representing the L0 original node ID pointing to this version chain. In practical applications, regardless of whether the current version is L1, L2, or Ln, the source of this chain can be found through origin_*_id; compress_level, representing the compression level, which can be L0, L1, ..., Ln; next_level_*_id, representing the version node pointing to the next compression level. If there is no higher-level version, it is null. For example, as_ 010_L0.next_level_as_id=as_010_L1; token_len, representing the number of tokens (which can be cached) under the target tokenizer in the text representation of this version node; created_at, representing the creation timestamp; created_step, representing the global step number recorded at creation (which will be used to calculate #Step later with global_step). When multiple nodes are merged into a digest node, the source needs to be recorded separately. The digest type node contains multiple digest source nodes digest_sources, which saves the origin_*_id list of the merged digest source nodes. This ensures that when the digest source node later generates compressed versions L1, L2, ..., Ln, it can still stably locate the source chain.

[0076] Regarding the data structure of action steps (including Digest Action Steps), since an action step represents the smallest action unit in a dialogue and is the finest-grained unit in compressed scheduling, the data for each action step node includes at least the model's intermediate return results, tool calls, tool call results, error messages, system information, and the digested Action Step (AS) or other content. Each action step node maintains a compressed version chain L0→L1→…→Ln (connected by next_level_as_id). When the action step type step_type is Digest DIGEST, this action step is a Digest Action Step (DAS), and its digest source node records the list of the original action steps being merged, facilitating back-to-source expansion. In this application, token_len(AS) is the number of tokens for the AS text, i.e., the number of tokens.

[0077] Regarding the round data structure (including single-topic rounds, single-topic round shards, and digest rounds), each round node's data begins with a new user input, a sub-agent initiation, or a sub-agent return result, and includes all action step interaction information up to the start of a new round. Single-topic round shards are a special case of the round data structure. Round nodes store round initiation information, such as user input and agent call information, through `event.text`. Action steps within a round node are organized in action step sequence (i.e., `as_sequence`). Round nodes also maintain a compressed version chain L0→L1→…→Ln (connected by `next_level_turn_id`). Multi-topic round nodes can contain a list of single-topic round shards, recording multiple single-topic round shards (sidechains) derived from that multi-topic round node. The round type for single-topic round shards is SHARD, and their data structure is consistent with that of single-topic rounds. In this application, token_len(Turn) is the sum of token_len of all action steps AS in the current version of turn Turn and the content in event.text.

[0078] Regarding the data structure of the Topic Thread, the context view tree organizes single-topic round nodes, single-topic round slice nodes, and summary round nodes with the Topic Thread node as the root subtree. Each Topic Thread node contains multiple single-topic round nodes, single-topic round slice nodes, and summary round nodes. To maintain topic consistency within the same Topic Thread, a single-topic round node, single-topic round slice node, and summary round node belong to only one Topic Thread. The Topic Thread also maintains a compression version chain, linked by `next_level_thread_id`, and records `topic_text`, a member list (i.e., a list of round IDs), `scores`, etc., for thread-level budget allocation and compression decisions. In this application, `token_len(Thread)` is the sum of `token_len` for all single-topic round nodes, single-topic round slice nodes, and summary round nodes under the Topic Thread.

[0079] Optionally, the server constructs a source interaction data tree and a context view tree based on the current dialogue event stream.

[0080] The source interactive data tree and the context view tree are cross-linked through node affiliation and pointer mapping, achieving a separation architecture between the fidelity storage structure and the decision view structure, as shown in Figures 6, 7, and 8. The core association mechanism between the two trees is as follows:

[0081] 1) Node Attribution and Member Pointers. As shown in Figure 6, each single-topic round node, single-topic round slice node, and summary round node exists directly or indirectly in both trees, but plays different roles. In the source interaction data tree: single-topic round nodes, multi-topic round nodes, single-topic round slice nodes, and summary round nodes are arranged in the order of interaction time, forming a high-fidelity time-series log; single-topic round slice nodes are associated as side-link nodes of multi-topic round nodes through the shards[] field. In the context view tree, single-topic round nodes, single-topic round slice nodes, and summary round nodes are recorded as member nodes of the topic thread node in the member list of the topic thread node. This dual attribution allows the same node to retain both time sequence information (for audit traceability) and topic organizational structure (for budget allocation and compression decisions).

[0082] 2) Tree structure changes after multi-topic round slicing. When a multi-topic round node is sliced ​​into multiple single-topic round slice nodes, the original multi-topic round node in the source interaction data tree is retained, and the single-topic round slice node is attached as a sidelink node in the shards[] field of the original multi-topic round node. The main time series chain of the original multi-topic round node remains unchanged. The original multi-topic round node in the context view tree is no longer a member of any topic thread node (removed from the member list), and each single-topic round slice node is assigned to the member list of the topic thread node of the corresponding topic. Among them, the single-topic round slice node is the origin return endpoint, and subsequent compression will no longer return to the original multi-topic round node to avoid cross-topic origin return causing topic mixing within the thread.

[0083] 3) Compressed Versions and Tree Attribution. As shown in Figure 7, when a single-topic round node or single-topic round slice node has multiple compression levels (L0→L1→…→Ln), all compressed level versions in the source interaction data tree are retained and form a version chain through the next_level_turn_id pointer. Each Ln (n>0) version directly points back to the original L0 version through origin_turn_id, supporting fast source retrieval. In the context view tree, only the latest content representation (tail compressed version) enters the context view tree as a member of the topic thread node, while the remaining intermediate content representations (intermediate compressed levels) do not enter the context view tree and are only retained in the source interaction data tree for source retrieval.

[0084] 4) Tree structure in sub-agent scenarios. As shown in Figure 8, when a main agent calls multiple sub-agents to execute tasks in parallel, the source interaction data tree presents a branching structure. Specifically, the round node of the main agent (e.g., round node 1) serves as the parent node, and the task rounds of each sub-agent (e.g., round node 2.1, i.e., Turn2.1, and round node 2.2, i.e., Turn2.2) serve as child nodes. After a sub-agent returns a result, subsequent rounds (e.g., round node 3, i.e., Turn3) merge multiple branches. In the context view tree, the rounds of each sub-agent are assigned to the corresponding topic thread node based on the topic they process. The main agent's start round and result summary round can be assigned to the topic thread node corresponding to the main task. In the actual cross-tree structure, all four scenarios will occur simultaneously.

[0085] In determining the affiliation of a topic thread, this application directly adopts LLM classification. For a newly completed round, the system calls LLM to determine the topic and returns whether it matches a topic in an existing topic thread, the matching topic ID (or topic description), the confidence / similarity score (optional), and whether it is a multi-topic round (multi-topic flag). If the confidence score is below the threshold and the number of topic thread nodes has not reached the upper limit, the creation of a new topic thread node is allowed; otherwise, it is assigned to the most similar existing topic to suppress the expansion of the number of topics.

[0086] In multi-topic determination and round-slicing triggering, the system triggers the round-slicing process when the LLM returns multi_topic=true and the number of identified topics is ≥2. Additionally, the following situations can also trigger round-slicing: 1) Thread consistency check failure: After a round node is initially assigned to a topic thread node, the system asks the LLM to determine if the content of the round node is consistent with the topic of that topic thread node. If they are inconsistent and the LLM simultaneously indicates the existence of multiple topics or that it can be split into multiple topic blocks, then round-slicing is triggered; 2) Significant AS-level topic conflict (optional): The system allows the LLM to output topic tags or topic IDs for each action step node within a round node. If the action step node is assigned to ≥2 topic clusters and the similarity between clusters is below a threshold (or the LLM explicitly indicates that they belong to different tasks / topics), then round-slicing is triggered.

[0087] Among the alternatives, in addition to direct LLM classification, a hybrid strategy of coarse embedding similarity classification followed by LLM verification and correction can be adopted, or only embedding classification can be used.

[0088] This application provides a round-slicing method. The following description, in conjunction with Figure 9, elaborates on the timing of round-slicing execution, the execution process of round-slicing, and round-slicing as the source endpoint.

[0089] Regarding the timing of round slicing, the system follows these constraints: Round slicing is not performed before the current round ends. The system first collects and solidifies all action steps within the current round (e.g., tool calls / returns, assistant messages, etc.), forming a complete round node (Turn(L0)) and writing it into the initial mounting of the source interaction data tree and context view tree. After the current round ends, the topic identification and thread management module determines topic affiliation and multiple topics. If multiple topics are determined, round slicing is triggered. This timing constraint is designed to avoid incorrect topic determination or frequent topic affiliation migration due to incomplete information during the current round, thus improving topic consistency and slice stability.

[0090] Regarding the execution flow of round slicing, when the topic identification module determines that the current round is a multi-topic round, the system executes the following: Determine the number of round slices and topics, i.e., the LLM outputs a list of topics (e.g., topic_1…topic_m) and the content range of each topic (which can be based on AS number or text fragment boundaries); Generate round slice content, i.e., call the LLM to rewrite the original multi-topic round, generating m single-topic round slices based on the topic (each single-topic round slice retains only the content of a single topic), and the data structure of the single-topic round slice is the same as that of the single-topic round; Round slice mounting and attribution: In the source interactive data tree, the single-topic round slice is recorded as a sidelink node of the original multi-topic round, and the shards field of the original multi-topic round records the shard_id list; In the context view tree, each single-topic round slice is mounted to the corresponding topic thread node; Single-topic round slices are decoupled from compression, i.e., single-topic round slices are not required to be compressed immediately, topic isolation can be completed first, and compression can be decided later based on pressure / budget.

[0091] Regarding single-topic round slices as the origin return endpoint, single-topic round slices are considered the origin return endpoint. That is, the compression of single-topic round slices will no longer return to their corresponding original multi-topic rounds, in order to avoid cross-topic origin return causing topic mixing within the same topic thread.

[0092] Step S104: Obtain new action step requests belonging to the current dialogue event stream; update the context view tree and source interaction data tree based on the new action step requests; and determine the pressure coefficient of the current context based on the updated context view tree.

[0093] New action step requests can be triggered by new text input from the user, a call from the current agent to a sub-agent, or the termination of a sub-agent. Additionally, new action step requests are also triggered when the model continues to output events to complete a task, when a tool is invoked, or when a tool returns.

[0094] The pressure coefficient is a dynamically calculated numerical indicator used to quantify the pressure of the current context of the large language model. The higher the pressure, the more the current context needs to be compressed.

[0095] Optionally, as the conversation progresses, whenever a new action step request is received, both trees are updated based on that action step request.

[0096] This application provides a counting mechanism that defines a global step number `global_step` (monotonically increasing) and `created_step`. When a new action step `AS` is added to the context view tree, `global_step` ← `global_step` + 1. Each action step node, single-topic round node, single-topic round slice node, topic thread node, and summary merge node records its `created_step` = `global_step` upon creation. When calculating importance or performing decay, the step distance for any node `X` is defined as: This definition is consistent with ← +1 has the same effect, but there is no need to iterate and update.

[0097] Step S106: Determine whether there are nodes to be compressed in the updated context view tree based on the pressure coefficient.

[0098] The nodes to be compressed can be round nodes, action step nodes, or topic thread nodes, or they can be summary round nodes, summary source nodes, or merge summary action step nodes.

[0099] Optionally, the server calculates the pressure coefficient of the updated context view tree. If the pressure is too high, nodes whose token length exceeds the upper limit are identified as nodes to be compressed.

[0100] Step S108: If it exists, then combine the updated source interaction data tree and the updated context view tree to perform a back-to-source compression operation on the node to be compressed, so as to update the updated context view tree and the updated source interaction data tree, and return to the step of determining the pressure coefficient of the current context based on the updated context view tree, until there is no node to be compressed in the updated context view tree.

[0101] Optionally, if the node to be compressed is a round node or action step node, the original version content representation of the node is found from the source interaction data tree, a new round of compression is performed, and the new compression result is updated back to both trees. If the node to be compressed is a topic thread node, the original version content representation of the node is found from the context view tree, a new round of compression is performed, and the new compression result is updated back to the context view tree. This compression-evaluation loop continues until the number of tokens of each level node meets its corresponding hierarchical soft upper limit. For the method of determining the soft upper limit of each level, please refer to the next embodiment.

[0102] Step S110: Based on the updated context view tree, expand it into context content and input it into the large language model, so that the large language model can combine the context content to output the request response result for the new action step request.

[0103] Optionally, the server combines the final updated context view tree, expands to generate context content, and inputs it into the large language model, so that the large language model, in combination with the context content, outputs a request-response result for the new action step request.

[0104] In the aforementioned large-scale model context processing method, by constructing a dual-tree cross structure of source interaction data tree and context view tree, and introducing a dynamic pressure coefficient to trigger intelligent back-to-source compression operation, the problem of decreased model understanding accuracy caused by lengthy and chaotic context in long-range, multi-topic dialogues is solved. The source interaction data tree ensures lossless storage and traceability of historical information, while the context view tree organizes the latest information by topic, maintaining a clear context structure. The cyclic compression mechanism based on the pressure coefficient can dynamically optimize the context length within the model's capabilities. At the same time, the back-to-source operation maximizes the preservation of key semantics, ensuring that the context provided to the large language model is always structurally clear, concise in content, and semantically complete, thereby significantly improving the accuracy of the large language model's understanding and response to new user tasks.

[0105] In one embodiment, the context view tree organizes topic thread nodes according to topic type; each topic thread node is attached with the latest round content representation of its own round nodes, and each round node is attached with the latest action step content representation of its own action step nodes; each action step node records the request-response result of each action step request; based on the pressure coefficient, it is determined whether there are nodes to be compressed in the updated context view tree, including: determining the importance score of each topic thread node in the updated context view tree, and determining the token length limit of each topic thread node based on the importance score and pressure coefficient; determining the importance score of each round node in the updated context view tree, and determining the token length limit of each topic thread node based on the importance score and pressure coefficient; determining the importance score of each round node in the updated context view tree, and determining the token length limit of each round node based on the importance score and pressure coefficient; The importance score of each secondary node and the upper limit of the token length of the topic thread node to which each round node belongs are used to determine the upper limit of the token length of each round node; the importance score of each action step node in the updated context view tree is determined, and the upper limit of the token length of each action step node is determined based on the importance score of each action step node and the upper limit of the token length of the round node to which each action step node belongs; the token length of each topic thread node, each round node, and each action step node in the updated context view tree is determined, and based on the token length and upper limit of the token length of each topic thread node, the token length and upper limit of the token length of each round node, and the token length and upper limit of the token length of each action step node, it is determined whether there are nodes to be compressed in the updated context view tree.

[0106] The importance score represents the importance of the content represented by the node to the current dialogue context, and can be calculated based on factors such as node freshness and content brevity.

[0107] The token length refers to the number of tokens represented by the content associated with the node.

[0108] The token length limit is the maximum content length allowed for a node, which is dynamically calculated based on the pressure coefficient. It is a function of the pressure coefficient and the importance of the node—the higher the pressure, the tighter the overall limit; the more important the node, the more lenient the limit it is allocated.

[0109] Optionally, after calculating the pressure coefficient, the server will traverse each node in the context view tree to obtain its real-time assessed importance score and current token length. Then, based on the pressure coefficient and the importance score of each node, the server will dynamically allocate the upper limit of the token length for each node proportionally. Finally, the server will compare the token length of each node with its upper limit. If the actual token length of any node exceeds its upper limit, the node will be marked as a node to be compressed.

[0110] In this embodiment, an independently trained reward model R can be used to score action step nodes, round nodes, and topic thread nodes based on content importance and compression risk to obtain a reward value R, and to take into account time distance ( ) and length ( Attenuation, compression times ( The modulation forms an importance score I, and the form of I can be (but is not limited to): ,in, (or other monotonic functions), To normalize nodes of the same type in the current context (e.g.) , For nodes of the same type in the current context The value obtained after taking the maximum value. To normalize nodes of the same type in the current context (e.g.) , For nodes of the same type in the current context The value obtained after taking the maximum value. To normalize nodes of the same type in the current context (e.g.) , For nodes of the same type in the current context The value obtained after taking the maximum value. Small positive constants (such as) (Used for numerical stabilization processing).

[0111] α, β, and γ are non-negative real hyperparameters used to adjust the weights of factors modulating importance scores based on time-distance decay, length decay, and compression frequency. When a factor is not desired to participate in the importance score calculation, its corresponding hyperparameter can be set to 0. The values ​​can be selected within a wide range, for example, all values ​​are [0, 10], and more preferably [0, 3]. The determination method can be to perform a grid search on the candidate value set (such as {0, 0.25, 0.5, 1, 2, 3}, etc.), and use the success rate of the compressed dialogue task, the answer consistency score or the human preference win rate as evaluation indicators, and select the hyperparameter combination with the best indicators as the system configuration parameters and fix it for use. Selectable as Weighted averages or maximum values, etc., can also be directly returned by the model. R(t) is not directly related.

[0112] α represents the strength of decay over time distance (#Step). The larger the #Step (the further back), the smaller the importance score I. The larger the α, the faster the decay, indicating that the system is more inclined to retain the most recent content and to compress / merge the earlier content first. If α=0, then the newness and oldness are not considered at all, and historical content will not be downgraded because it is earlier. If α is very large, there will be a strong recency bias. If the task requires long-term constraints (such as the initial system instructions, long-term goals, key settings), it needs to be combined with other mechanisms (such as increasing R(t) for specific types of content or setting separate retention rules) to avoid being crushed too early.

[0113] β represents the strength of I decay with length. When β > 0, the longer the content, the smaller I becomes (under the same R(t)). This encourages the system to prioritize compressing long and redundant blocks, leaving the budget for short and critical segments. The larger β is, the stronger the penalty for long text, resulting in more aggressive compression; however, if set too large, long but critical content may be incorrectly prioritized for compression (e.g., a very long tool return containing key fields). This usually requires using R(t) or type weights to salvage the critical long content.

[0114] γ represents the modulation direction and intensity (h(k)) with the number of compressions k. The non-negativity of γ determines that compressed content is more likely to be retained in subsequent rounds. The larger k is, the larger h(k) is, and the larger I is. The already compressed content is considered more concise / higher density / more worthy of retention. The system will tend to avoid repeatedly compressing it to avoid the drift introduced by the summary re-summarizing, and hopes that the summary is as stable as possible after it is formed, only returning to the source for re-compression when necessary. The larger γ is, the more important the already compressed summary is regarded, and the more likely it is to be avoided for re-summarizing; when it needs to be shortened, it should trigger the return to the source for re-compression. If γ=0 and h(k)=1, the number of compressions does not affect importance. Whether it has been compressed or not does not change the subsequent priority. I is completely determined by R(t), Step, and Length.

[0115] The training sample set for reward model R may include content representations (such as the original node text) and node types (action step / round / topic thread node) of the nodes to be scored obtained from the structuring of the contextual dialogue text. The training labels may be scores manually annotated based on content importance and compression risk (e.g., normalized to [0, 1]), or human preference relationship labels for two nodes of the same type in the same context (“…”). "Node ratio" (Nodes are more important and compression risks are higher) Human preference relationship labels can come from manual comparison feedback or from offline evaluation, etc.

[0116] The reward model R can be implemented using a Transformer-based sequence encoder or other neural networks, and its output is normalized to a value using the Sigmoid function (S-shaped function). When training using regression (i.e., when training labels are manually labeled scores), the objective function is to minimize the mean squared error; when training using preference-based methods (i.e., when training labels are human-preferred labels), the objective function can be to minimize the contrastive loss. This is done so that important nodes receive higher reward scores and unimportant nodes receive lower reward scores. The trained reward model then functions as an independent model to score node importance and compression risk, and participates in the subsequent calculation of the importance score I.

[0117] In this embodiment, the pressure coefficient can be expressed as: Where B represents the hard upper limit of the input token length (token hard upper limit) determined by the large language model itself, U(t) represents the total token length of the model to be input after the current context view tree is assembled, ρ represents the security ratio (e.g., 0.8), and clip truncates the value to [0,1].

[0118] In this application, the token length limit for each node specifically refers to the hierarchical soft cap Cap (Thread / Turn / AS), which needs to be allocated to different levels based on the pressure coefficient and importance score, in forms including but not limited to: , , Where LC is the tolerance coefficient, θ is a non-negative hyperparameter, and the amplification effect of control pressure on the soft upper limit refers to the effect when P(t) = 0 (no pressure), The soft upper limit is only limited by the hard upper limit when P(t) > 0. The soft upper limit is compressed; the larger θ is, the lower the pressure under the same conditions. The faster the decay, the smaller the soft upper limit, and the more likely compression is to be triggered. When θ=0, The soft upper limit is only limited by the hard upper limit and is not affected by pressure.

[0119] In this embodiment, the token length limit can be adaptively adjusted for nodes at different levels based on the pressure coefficient, reserving more information capacity for key nodes and minimizing or delaying the compression of key information. This refined resource allocation strategy ensures that historical information crucial for understanding the current new action step request is preserved to the maximum extent during the compression process, directly improving the semantic quality of the compressed context and the accuracy of understanding the large model language.

[0120] In one embodiment, the source interaction data tree is loaded with the content representations of each round node in the order of interaction time, and each round node is loaded with the content representations of each action step node in the order of its own action step nodes; the source interaction data tree maintains the compressed version chain of each action step node; the updated source interaction data tree and the updated context view tree are combined to perform a back-to-source compression operation on the node to be compressed, so as to update the updated context view tree and the updated source interaction data tree, including: if the node to be compressed is an action step node, the compressed version chain of the action step node is obtained from the source interaction data tree, and the original action step content representation of the action step node is obtained based on the compressed version chain; the original action step content representation is compressed to obtain a new action step content representation of the action step node; the token length corresponding to the new action step content representation is less than a preset ratio of the token length corresponding to the latest action step content representation of the action step node; the latest action step content representation of the action step node in the updated context view tree is replaced with the new action step content representation of the action step node, and the new action step content representation of the action step node is recorded in the updated source interaction data tree.

[0121] The compressed version chain refers to a linked list maintained by time for each action step node in the source interaction data tree, which sequentially stores the action step content representation from the original action step content representation to each compressed version of the action step content representation.

[0122] The original action step content usually refers to the earliest and most detailed version in the compressed version chain (usually the uncompressed original interactive text), which serves as the source content for recompression.

[0123] Optionally, once an action step node is identified as a node to be compressed, a back-to-source compression operation is triggered. First, the corresponding node in the source interaction data tree is located, and its compressed version chain is read. If, after regressing to the original action step content representation (i.e., the L0 version of the action step content representation), the action step content representation exceeds the token limit of the compression model, it can regress to the L1 version of the action step content representation. If the L1 version of the action step content representation still exceeds the token limit of the compression model, it can regress to the L2 version, and so on. Then, for the final regressed version of the action step content representation, a new round of compression is performed using a text compression algorithm to generate a new compression result. Finally, this new compression result is used to update the latest content representation of the node in the context view tree, and the new compression result is appended as another version to the version chain of the source interaction data tree to complete the archiving.

[0124] In this embodiment, the compression loss of context details is reduced by performing source compression operation on action step nodes. Unlike directly compressing the already compressed text, the source compression mechanism allows each time to start from richer and more accurate source content, ensuring that the action step information in the context view tree still maintains high fidelity even after multiple compressions. This provides a reliable basis for the model to understand the cause and effect of the current task and effectively alleviates the comprehension bias caused by excessive information loss.

[0125] In one embodiment, the source interaction data tree mounts the content representations of each round node in the order of interaction time; the source interaction data tree maintains the compressed version chain of each round node; each round node corresponds to a multi-topic round, a single-topic round, or a single-topic round slice; the single-topic round slice is obtained by performing topic slicing on each action step request in a multi-topic round; after the step of recording the new action step content representation of the action step node in the updated source interaction data tree, the method further includes: returning to the step of determining the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree, and determining that there are still nodes to be compressed in the updated context view tree. When the compressed node is a round node, the compressed version chain of the round node and the compressed version chains of each associated action step node involved in the round node are obtained from the source interaction data tree; based on the compressed version chain of the round node and the compressed version chains of each associated action step node, the original round content representation of the round node is obtained; the original round content representation is compressed to obtain a new round content representation of the round node; the token length corresponding to the new round content representation is less than a preset ratio of the token length corresponding to the latest round content representation of the round node; the latest round content representation of the round node in the updated context view tree is replaced with the new round content representation of the round node, and the new round content representation of the round node is recorded in the updated source interaction data tree.

[0126] The compressed version chain of each round node is similar to the action step, and is a sequence of content representations for each round maintained by each round node.

[0127] The original round content typically refers to the initial, complete set of user queries, sub-agent calls, and model responses for that round.

[0128] Optionally, when the node to be compressed is a round node, the server performs a back-to-source operation, finds the compressed version chain of the round node from the source interaction data tree, and obtains the L0 version round content representation of the round node based on the compressed version chain of the round node. The round content representation includes startup information and action step sequence. The action step sequence may be {AS1(L1), AS2(L2), AS(L0), AS4(L1)}. Then, based on the compressed version chains of AS1, AS2, and AS4, the L0 version action step content representations of action step nodes AS1, AS2, and AS4 need to be obtained. Then, based on the startup information in the L0 version round content representation and the L0 version action step content representations of action step nodes AS1, AS2, AS3, and AS4, the original round content representation is obtained. The original round content representation is compressed using a round node compression strategy. After generating a new compression result, the round summary in the context view tree and the compressed version chain in the source interaction data tree are updated synchronously.

[0129] In this embodiment, by implementing source compression on round nodes, the dialogue mainline is maintained at a higher level of abstraction, which solves the problem that in long dialogues, as the number of rounds increases, the historical descriptions accumulate and become lengthy, crowding out the context space.

[0130] In one embodiment, the updated context view tree records the past topic content representations of each topic thread node and maintains a compressed version chain for each topic thread node. After recording the new round content representation of the round node in the updated source interaction data tree, the method further includes: returning to the steps of determining the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree; and if there is a node to be compressed in the updated context view tree and the node to be compressed is a topic thread node, selecting the topic thread node with the largest token length exceeding the limit as the target node from among the topic thread nodes to be compressed; and obtaining the compressed version of the target node from the updated context view tree. The chain, and, from the source interaction data tree, obtain the compressed version chain of each associated round node involved in the target node and the compressed version chain of each associated action step node involved in each associated round node; based on the compressed version chain of the target node, the compressed version chain of each associated round node, and the compressed version chain of each associated action step node, obtain the original topic content representation of the target node; compress the original topic content representation of the target node using a preset compression strategy to obtain a new topic content representation of the target node; the token length of the new topic content representation is less than a preset ratio of the token length of the latest topic content representation; store the new topic content representation of the target node as the latest topic content representation of the target node in the updated context view tree.

[0131] The compressed version chain of the topic thread node stores all versions of the topic's general description from its creation to the present.

[0132] The original topic content representation can include the content representations of all rounds under that topic (each round's content representation includes the start information and the content representations of all action steps belonging to that round), or it can refer to the text that provided a comprehensive summary of the topic in the last iteration. The original topic content representation is obtained by backtracking the content representations of all rounds and all action steps in the L0 version of the topic content representation to the L0 version.

[0133] Among them, the associated round node is the round node associated with the original topic content under the topic thread node.

[0134] Among them, the associated action step node is the action step node associated with the original round content under the associated round node.

[0135] The over-limit ratio refers to the proportion by which a node's current token length exceeds its maximum token length limit.

[0136] The preset compression strategy refers to the compression strategy for the subordinate nodes of the topic thread node. When there are round nodes 1, 2, 3, and 4 under the topic thread node, the preset compression strategy can be used to compress and merge round nodes 1 and 2, but leave round nodes 3 and 4 unprocessed. Alternatively, round nodes 1, 2, 3, and 4 can all be compressed and merged.

[0137] Optionally, when the pressure coefficient indicates that topic thread nodes need to be compressed, and multiple topic nodes exceed the limit simultaneously, the server adopts a priority strategy, calculates the over-limit ratio of each over-limit node, and selects the node with the highest ratio as the target node for priority processing. It obtains the compressed version chain of the target node from the updated context view tree, and obtains the compressed version chains of each associated round node and each associated action step node from the source interaction data tree. Based on the compressed version chains of the target node, the compressed version chains of each associated round node, and the compressed version chains of each associated action step node, it obtains the most detailed original topic content representation of the topic (i.e., the set of all original rounds under the topic and all original action steps involved in all original rounds). Then, it performs topic-level compression, generates a new compression result (i.e., a new topic summary), and uses it to replace the latest topic content representation of the topic thread node in the context view tree. The new topic content representation of the topic thread node is then stored in the updated context view tree as the latest topic content representation of the target node.

[0138] In this embodiment, by implementing topic-level source compression and adopting an over-limit ratio priority strategy, the management of multi-topic dialogue context is achieved. When the dialogue involves multiple topics and all generate a large amount of content, this method can accurately locate the most bloated topic that contributes the most to the context pressure and prioritize its reduction. By deeply summarizing the original material of the entire topic, the space occupied by the topic in the context can be reduced to the greatest extent while preserving its core semantics. This ensures that each topic can exist in a concise form within a limited context window, maintaining the structure of multi-threaded dialogue. This allows the model to clearly distinguish the boundaries and history of different topics, thereby enabling more accurate contextual association and understanding when facing new tasks with interwoven multi-topic information.

[0139] In one embodiment, the method further includes: determining whether the number of topic thread nodes in the updated context view tree exceeds a preset threshold; if so, determining the topic thread node with the lowest importance score from the updated context view tree as the first topic thread node, and determining other topic thread nodes whose topics are most similar to the first topic thread node as the second topic thread node; merging the first topic thread node and the second topic thread node to generate a new topic thread and a topic content representation corresponding to the new topic thread; and updating the updated context view tree based on the topic content representation corresponding to the new topic thread.

[0140] The preset threshold is the maximum number of topics that the system allows to be active at the same time, which is used to prevent the context structure from becoming too scattered due to too many topics.

[0141] Among them, the topic similarity is determined by calculating the semantic similarity between the compressed text corresponding to the topic thread node, and the topic with the highest similarity is the most similar topic.

[0142] Optionally, the server continuously monitors the number of topics in the context view tree. When the number of topics exceeds a preset threshold (e.g., 5), a topic merging process is triggered. First, the topic with the lowest current importance score is found (the first topic thread node), which usually means that the topic is the least discussed or has the lowest importance. Then, the semantic similarity between this topic and all other topics is calculated, and the topic most similar to it is found as the second topic thread node. Next, all nodes under these two topics are integrated, summarized, and a new topic thread description (i.e., a new topic content representation) is generated. Finally, the original two nodes are replaced with this new topic node, and the topic association relationship in the context view tree is updated synchronously.

[0143] In this embodiment, by introducing a topic quantity threshold and a similar topic merging mechanism, the complexity of the dialogue context is effectively controlled. This solves the problem that in very long, free-form dialogues, the model may become distracted and lose comprehension due to the need to pay attention to too many independent topic cues at the same time. Merging the least active and semantically similar topics not only simplifies the context structure but also organically integrates the historical information of related topics, avoiding information fragmentation. This ensures that the context provided to the model always maintains a limited, clear, and aggregated topic structure, greatly improving the model's ability to focus on core issues, make accurate connections, and respond when dealing with complex, multi-topic intertwined new tasks.

[0144] This application provides an interactive data acquisition and structuring module, serving as the system's entry point. This module is responsible for converting the raw event stream during the dialogue process into structured Turn and Action Step (AS) data objects, and completing initialization calculations and caching. This module provides a unified data input for subsequent modules such as dual-tree management, topic recognition, and compression decision-making.

[0145] In practical applications, the system listens to the raw event stream during the dialogue process and identifies and classifies the event types as shown in Table 1.

[0146] Table 1

[0147]

[0148] The rules for determining the boundaries of rounds include: new user input triggering a new round, sub-agent startup triggering a new round, and sub-agent return triggering a new round. Specifically, a new user input triggering a new round occurs when a user input event is detected; the system immediately closes the current round node (if any) and creates a new round node, recording the user input text in the `event.text` field. A sub-agent startup triggering a new round occurs when the main agent calls a sub-agent; the system creates an independent new round for the sub-agent's execution context, setting the event type `event_type` to `SUBAGENT_START`, forming a branching structure in the source interaction data tree when the main agent calls multiple sub-agents. A sub-agent return triggering a new round occurs when the sub-agent completes execution and returns a result; the system creates a new round node to record the returned information and merges branches in the source interaction data tree (if any).

[0149] During the lifecycle of a round, the system continuously listens for and collects Action Steps (AS), structures them, and appends them to the AS sequence (i.e., as_sequence) of the current round. This includes AS node creation, payload filling, token calculation and caching, and sequence appending. When an action step node is created, each action step event triggers the creation of a new action step node. A unique as_id is assigned to each new action step node, and compress_level=0 and origin_as_id=as_id are set. When the payload is filled, the payload fields are filled according to the action step type. Specifically, the ASSISTANT_MSG field corresponds to raw_text, which is filled with the model's returned text; the TOOL_CALL field corresponds to raw_text, which is filled with the calling expression; the tool field is filled with the tool name and parameters; the TOOL_RESULT field corresponds to raw_text, which is filled with the return result; the tool.result field is filled with the structured result; the ERROR field corresponds to raw_text, which is filled with the error description; the error field is filled with the error type and stack trace; and the SYSTEM field corresponds to raw_text, which is filled with the system message content. During token calculation and caching, a tokenizer is calculated for the payload.raw_text of each action step node, and the result is cached in the token_len field to avoid duplicate calculations. When appending to the sequence, the as_id of the new action step node is appended to the end of the action step sequence (i.e., as_sequence) list of the current round, and the token_len of the current round is updated synchronously (accumulating the token_len of the new action step node).

[0150] The conditions used to determine whether the current round has ended include: detection of a new round trigger event (new user input, sub-agent startup, sub-agent return), session timeout (configurable idle timeout threshold), and explicit round end signal (such as a specific system message). At the end of the current round, the system performs the following solidification operations: action step sequence freezing, meaning that the action step sequence (i.e., as_sequence) of the current round will no longer accept new action steps; token total quantity verification, i.e., recalculating the token_len of the current round (event.text + the sum of token_len of all ASs); and status marking, marking Turn as completed, allowing subsequent modules to perform topic identification and round slicing.

[0151] This application employs a source-back compression strategy (core rule) to perform source-back compression operations, as shown in Figure 10. To suppress drift caused by secondary compression, [the following is implemented / implemented]. Set a length limit (e.g., not exceeding) A certain proportion of the length (the proportion is configurable), when the input to be compressed contains When extracting the summary content, the system prioritizes returning to the source based on the mapping pointer and expanding that part to a lower level (preferred). (Original text), then compressed. If returning to the original source... This causes the input to the compressed model to exceed its context limits, then from Step-by-step rollback , …until the compression model context constraints are met; if they are still not met, compression is performed directly using the existing content in the context view tree.

[0152] The compression action types include action step-level compression (intra-AS compression), round-level compression (intra-Turn merge compression), topic-level compression (intra-Thread merge compression), and inter-topic compression (optional).

[0153] Action step compression is triggered when the token_len of the action step node exceeds its... The action to be performed is to compress and rewrite the payload.raw_text of the action step node, generate the next compression level version of the action step node (e.g., L1 is generated from L0), and connect the version chain through next_level_as_id. The output format is that the number of action step nodes remains unchanged, and the same action step node generates a new compressed version on the version chain.

[0154] Round-level compression (intra-turn merge compression) is triggered when the token_len of a node in a certain round exceeds its threshold. The action to be performed is to find the importance score within this round node. The smallest action step node is merged with its adjacent, less important action steps to generate a Digest Action Step node (DAS, step_type=DIGEST), as shown in Figure 11. The origin_as_id of the merged action step is recorded in the digest source node. This merging process is repeated until the token_len of the round node meets the target compression requirement. Meanwhile, because the startup information is relatively important, during round-level compression, compression is only performed when the round node has reached the target compression requirement. At or higher levels, event.text (startup information) is compressed, and the output format remains the same in terms of the number of round nodes, but some action steps in the action step sequence within the round node are replaced by summary action step nodes, thus reducing the number of action steps; at the same time, a new compressed version of the round node is generated ( / …), the version chain is concatenated by next_level_turn_id.

[0155] Topic-level compression (intra-thread merge compression) is triggered when the token_len of a certain topic thread node exceeds its limit. The action performed is to merge low-importance content within the scope of the topic thread node (across rounds) using a similar round-level strategy. When they are the same, merge them first. Smaller value topic thread nodes, When the two are the same, merge first. Larger topic thread nodes can generate summary round nodes (event_type=DIGEST), and the origin_turn_id of the merged round nodes is recorded in the summary source node; merging is repeated until the token_len of the topic thread node meets the target compression requirements. The output format is that the number of topic thread nodes remains unchanged, but some round nodes in the round sequence within the topic thread node are replaced by summary round nodes, thereby reducing the number of round nodes; at the same time, the topic thread node generates a new compression level version ( / …), and the compressed version chain of the Thread level can be chained together using next_level_thread_id.

[0156] Inter-topic compression (optional) is triggered when inter-thread compression is enabled and the number of topic threads exceeds the set threshold for the number of topic threads in the context view tree. The action performed is to assign an importance score. The smallest topic thread is found and merged with another topic thread whose topic is most similar to its own. During the merge, thread-level compression is performed simultaneously, and the final number of tokens for the generated topic thread should meet the following requirements. Compression requirements. The output format is a reduction in the number of topic threads, with the origin_thread_id of the merged topic threads stored in the digest source node.

[0157] The update rule for compression level k (compression count and level evolution) is to maintain the concept of compression count / level in the system. When two elements of different L are compressed together, the compressed level can be the smaller of the two levels + 1 (for example, after L3 and L1 are compressed together, the result is L2). This rule is used in conjunction with the source compression strategy.

[0158] Among them, the least disruptive execution order is to perform compression in the following order to minimize semantic disruption when adding new content causes the soft limit to be exceeded (or when the number of topics is exceeded when inter-thread compression is enabled): (1) If there is an excess If the action step node exceeds the limit, then perform action step level compression on all over-limit action step nodes. (2) After completing step (1), if there are still over-limit action step nodes... If the round node exceeds the limit, then perform round-level compression on all round nodes that exceed the limit. (3) After completing step (2), if there are still more than the limit, then perform round-level compression on all round nodes that exceed the limit. If the topic thread node has the largest excess ratio, then the topic thread node with the largest excess ratio will be selected first to perform thread-level compression. (4) After completing step (3), if there are still excess ratios, then the thread node with the largest excess ratio will be selected first to perform thread-level compression. If the topic thread node is not satisfied, then repeat step (3) until all topic thread nodes satisfy the condition. ; If necessary, trigger inter-thread compression. (5) When inter-thread compression is enabled, if the number of topic thread nodes exceeds the set threshold after step (4), then trigger thread-level compression: select The smallest topic thread node is merged with the other topic thread node whose topic is most similar to it, and after merging, it returns to step (3) for re-examination. At the same time, in order to avoid compression affecting the continuity and available information of the current task, the system configuration parameter keep_k_newest marks the latest keep_k_newest action steps (AS) as protected areas; when making compression decisions, compression is only performed on action step nodes / round nodes / topic thread nodes outside the protected areas.

[0159] This application provides a large model context processing system, as shown in Figure 12. Functionally, it may include, but is not limited to, the following modules (each module can be a software functional unit or a combination of software and hardware): an interaction acquisition and structuring module, used to structure events in the dialogue process into Turns and Actions, and generate / update Action sequences; calculate or cache the token_len and reward_R of each Action / Turn; a dual-tree cross structure management module, used to maintain the source interaction tree and the context view tree, and maintain the side-link relationship between multi-topic turn nodes and single-topic turn slice nodes; used to maintain the compressed version chain of Actions / Turns / Threads, including updating the origin_*_id, compress_level, and next_level_*_id pointers; and a topic identification and thread management module, used to call the large language model (LLM) to determine the topic attribution of a turn (or the content representation after the turn), output thread_id or topic description, and maintain the Topic. The system includes a thread list and thread count limit strategy; a round-slicing module to generate single-topic round-slice nodes when the round-slice triggering conditions are met, and to attach these nodes to the corresponding topic thread nodes. Round-slicing is not executed until the current round node ends. Multi-topic judgment and round-slice node generation / attaching are performed only after the round node ends and the action step sequence stabilizes, with single-topic round-slice nodes serving as the origin return endpoint; an importance assessment module to output a reward value R based on the reward model, and to calculate #Step using global_step-created_step, further calculating the importance score I; and a pressure coefficient and tiered quota module to calculate the pressure coefficient P(t) and the soft caps Cap_thread / Cap_turn for each tier. / Cap_AS; The source compression module is used to trigger compression in layers according to AS / Turn / Thread and execute in the order of least destruction: (1) Perform AS-level compression on all ASs that exceed Cap_AS; (2) If there are still Turns that exceed Cap_turn, perform Turn-level compression on all Turns that exceed the limit; (3) If there are still threads that exceed Cap_thread, prioritize the Thread with the largest excess ratio to perform Thread-level compression; (4) Repeat (3) until all threads meet Cap_thread, and trigger inter-Thread compression if necessary; (5) (If inter-Thread compression is enabled) If the number of Threads exceeds the threshold, select the Thread with the least importance to perform inter-Thread compression and then return to (3).Before compressing a specific AS / Turn / Thread, the summary content containing L≥1 in the input to be compressed is expanded back to the source before compression; when the content returned to the source exceeds the context limit of the compression model, a step-by-step fallback strategy is executed; where Shard is the endpoint of the back-to-source process.

[0160] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0161] Based on the same inventive concept, this application also provides a large model context processing apparatus for implementing the large model context processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more large model context processing apparatus embodiments provided below can be found in the limitations of the large model context processing method described above, and will not be repeated here.

[0162] The large model context processing apparatus provided in the embodiments of this application is described below. The large model context processing apparatus has the same inventive concept as the large model context processing method described above. The solution to the problem provided by the apparatus is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the large model context processing apparatus provided below can be referred to the limitations of the large model context processing method above. The large model context processing apparatus described below and the large model context processing method described above can be referred to each other, and will not be repeated here.

[0163] In an exemplary embodiment, FIG13 is a schematic diagram of the structure of a large model context processing device provided in an embodiment of this application. As shown in FIG13, the large model context processing device includes: a construction module 1302, an update module 1304, a determination module 1306, a compression module 1308, and a generation module 1310, wherein:

[0164] Module 1302 is used to build the source interaction data tree and context view tree for the current dialogue event stream;

[0165] The update module 1304 is used to obtain new action step requests belonging to the current dialogue event stream, update the context view tree and source interaction data tree based on the new action step requests, and determine the pressure coefficient of the current context based on the updated context view tree.

[0166] The determination module 1306 is used to determine whether there are nodes to be compressed in the updated context view tree based on the pressure coefficient.

[0167] Compression module 1308 is used to perform a back-to-source compression operation on the node to be compressed, if it exists, by combining the updated source interaction data tree and the updated context view tree, to update the updated context view tree and the updated source interaction data tree, and return the step of determining the pressure coefficient of the current context based on the updated context view tree, until there is no node to be compressed in the updated context view tree.

[0168] The generation module 1310 is used to expand the updated context view tree into context content and input it into the large language model, so that the large language model can combine the context content to output the request response result for the new action step request.

[0169] In one embodiment, the context view tree organizes topic thread nodes according to topic type; each topic thread node is attached with the latest round content representation of its own round nodes, and each round node is attached with the latest action step content representation of its own action step nodes; each action step node records the request-response result of each action step request; the determination module 1306 is specifically used to determine the importance score of each topic thread node in the updated context view tree, and determine the token length limit of each topic thread node based on the importance score and pressure coefficient of each topic thread node; determine the importance score of each round node in the updated context view tree, and determine the token length limit of each topic thread node based on the importance score of each round node. Determine the upper limit of the token length for each round node, based on the upper limit of the token length of the topic thread node to which each round node belongs; determine the importance score of each action step node in the updated context view tree, and determine the upper limit of the token length for each action step node based on the importance score of each action step node and the upper limit of the token length of the round node to which each action step node belongs; determine the token length of each topic thread node, each round node, and each action step node in the updated context view tree, and determine whether there are any nodes to be compressed in the updated context view tree based on the token length and upper limit of the token length of each topic thread node, the token length and upper limit of the token length of each round node, and the token length and upper limit of the token length of each action step node.

[0170] In one embodiment, the source interaction data tree mounts the content representations of each round node in the order of interaction time, and each round node mounts the content representations of each action step node in the order of its own action step nodes; the source interaction data tree maintains the compressed version chain of each action step node; the compression module 1308 is specifically used to, if the node to be compressed is an action step node, obtain the compressed version chain of the action step node from the source interaction data tree, and obtain the original action step content representation of the action step node based on the compressed version chain; compress the original action step content representation to obtain a new action step content representation of the action step node; the token length corresponding to the new action step content representation is less than a preset ratio of the token length corresponding to the latest action step content representation of the action step node; replace the latest action step content representation of the action step node in the updated context view tree with the new action step content representation of the action step node, and record the new action step content representation of the action step node in the updated source interaction data tree.

[0171] In one embodiment, the source interaction data tree mounts the content representations of each round node in the order of interaction time; the source interaction data tree maintains a compressed version chain of each round node; each round node corresponds to a multi-topic round, a single-topic round, or a single-topic round slice; the single-topic round slice is obtained by slicing the action step requests in a multi-topic round into topics; the compression module 1308 is further used to return the steps of determining the importance scores and token lengths of each topic thread node, each round node, and each action step node in the updated context view tree, and if it is determined that there are still nodes to be compressed in the updated context view tree and the nodes to be compressed are round nodes. Obtain the compressed version chain of the round node and the compressed version chain of each associated action step node involved in the round node from the source interaction data tree; based on the compressed version chain of the round node and the compressed version chain of each associated action step node, obtain the original round content representation of the round node; compress the original round content representation to obtain the new round content representation of the round node; the token length corresponding to the new round content representation is less than a preset ratio of the token length corresponding to the latest round content representation of the round node; replace the latest round content representation of the round node in the updated context view tree with the new round content representation of the round node, and record the new round content representation of the round node in the updated source interaction data tree.

[0172] In one embodiment, the updated context view tree records the content representation of each topic thread node in each iteration and maintains the compressed version chain of each topic thread node. The compression module 1308 is further configured to return the steps of determining the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree, and, if there are nodes to be compressed in the updated context view tree and these nodes are topic thread nodes, select the topic thread node with the largest token length exceeding the limit from among the topic thread nodes to be compressed as the target node; obtain the compressed version chain of the target node from the updated context view tree; and obtain the compressed version chain of the target node from the source interaction data tree. Obtain the compressed version chains of all associated round nodes involved in the target node and the compressed version chains of all associated action step nodes involved in each associated round node; based on the compressed version chains of the target node, the compressed version chains of all associated round nodes, and the compressed version chains of all associated action step nodes, obtain the original topic content representation of the target node; compress the original topic content representation of the target node using a preset compression strategy to obtain a new topic content representation of the target node; the token length of the new topic content representation is less than a preset ratio of the token length of the latest topic content representation; store the new topic content representation of the target node as the latest topic content representation of the target node in the updated context view tree.

[0173] In one embodiment, the apparatus further includes: a judgment module, specifically configured to determine whether the number of topic thread nodes in the updated context view tree exceeds a preset threshold; if so, to determine the topic thread node with the lowest importance score from the updated context view tree as the first topic thread node, and to determine other topic thread nodes whose topics are most similar to the first topic thread node as the second topic thread node; to merge the first topic thread node and the second topic thread node to generate a new topic thread and a topic content representation corresponding to the new topic thread; and to update the updated context view tree based on the topic content representation corresponding to the new topic thread.

[0174] In one exemplary embodiment, this application also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of any of the large model context processing methods described above.

[0175] In one exemplary embodiment, this application also provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the large model context processing methods described above.

[0176] In one exemplary embodiment, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the large model context processing methods described in the above embodiments.

[0177] Schematably, as shown in FIG14, FIG14 is a schematic diagram of the internal structure of a computer device 1400 provided in an embodiment of the present application. The computer device 1400 can be provided as a server. Referring to FIG14, the computer device 1400 includes a processing component 1402, which further includes one or more processors, and memory resources represented by memory 1401 for storing instructions executable by the processing component 1402, such as application programs. The application programs stored in memory 1401 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1402 is configured to execute instructions to perform the large model context processing method of any of the above embodiments.

[0178] Computer device 1400 may also include a power supply component 1403 configured to perform power management of computer device 1400, a wired or wireless network interface 1404 configured to connect computer device 1400 to a network, and an input / output (I / O) interface 1405. Computer device 1400 may operate on an operating system stored in memory 1401, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or similar.

[0179] Those skilled in the art will understand that the structure shown in Figure 14 is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or may combine certain components, or may have different component arrangements.

[0180] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0181] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

[0182] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing the context of a large model, characterized in that, The method includes: constructing a source interaction data tree and a context view tree for the current dialogue event stream; organizing topic thread nodes according to topic type; each topic thread node attaching the latest round content representation belonging to its own round nodes, and each round node attaching the latest action step content representation belonging to its own action step nodes; each action step node recording the request-response result of each action step request; obtaining new action step requests belonging to the current dialogue event stream; updating the context view tree and the source interaction data tree based on the new action step requests; and adjusting the updated context view tree accordingly. The context tree is used to determine the pressure coefficient of the current context. Based on the pressure coefficient, it is determined whether there are nodes to be compressed in the updated context view tree. Specifically, this includes: determining the importance score of each topic thread node in the updated context view tree, and determining the upper limit of the token length of each topic thread node based on the importance score of each topic thread node and the pressure coefficient; determining the importance score of each round node in the updated context view tree, and determining the upper limit of the token length of each round node based on the importance score of each round node and the upper limit of the token length of the topic thread node to which each round node belongs. The importance score of each action step node in the updated context view tree is determined, and the upper limit of the token length of each action step node is determined based on the importance score of each action step node and the upper limit of the token length of the round node to which each action step node belongs; the token length of each topic thread node, each round node, and each action step node in the updated context view tree is determined, and the updated context view tree is determined based on the token length and upper limit of each topic thread node, the token length and upper limit of each round node, and the token length and upper limit of each action step node. Does the node to be compressed exist? If it does, then perform a back-to-source compression operation on the node to be compressed by combining the updated source interaction data tree and the updated context view tree, so as to update the updated context view tree and the updated source interaction data tree, and return to the step of determining the pressure coefficient of the current context based on the updated context view tree, until the node to be compressed does not exist in the updated context view tree; based on the updated context view tree, expand it into context content and input it into the large language model, so that the large language model can output the request response result for the new action step request by combining the context content.

2. The method according to claim 1, characterized in that, The source interaction data tree is loaded with the content representations of each round node in the order of interaction time, and each round node is loaded with the content representations of each action step node in the order of its own action step nodes; the source interaction data tree maintains a compressed version chain of each action step node; the step of performing a back-to-source compression operation on the node to be compressed by combining the updated source interaction data tree and the updated context view tree to update the updated context view tree and the updated source interaction data tree includes: if the node to be compressed is the action step node, then obtaining the compressed version of the action step node from the source interaction data tree. This chain, based on the compressed version chain, obtains the original action step content representation of the action step node; compresses the original action step content representation to obtain a new action step content representation of the action step node; the token length corresponding to the new action step content representation is less than a preset ratio of the token length corresponding to the latest action step content representation of the action step node; the latest action step content representation of the action step node in the updated context view tree is replaced with the new action step content representation of the action step node, and the new action step content representation of the action step node is recorded in the updated source interaction data tree.

3. The method according to claim 2, characterized in that, The source interaction data tree is mounted with the content representations of each round node in the order of interaction time; the source interaction data tree maintains the compressed version chain of each round node; each round node corresponds to a multi-topic round, a single-topic round, or a single-topic round slice; the single-topic round slice is obtained by performing topic slicing on each action step request in a multi-topic round; After the step of recording the new action step content representation of the action step node in the updated source interaction data tree, the method further includes: returning to the step of determining the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree; and if it is determined that the updated context view tree still contains the node to be compressed and the node to be compressed is the round node, obtaining the compressed version chain of the round node and the compressed version chain of each associated action step node involved in the round node from the source interaction data tree; obtaining the original round content representation of the round node based on the compressed version chain of the round node and the compressed version chain of each associated action step node; compressing the original round content representation to obtain the new round content representation of the round node; the token length corresponding to the new round content representation is less than a preset ratio of the token length corresponding to the latest round content representation of the round node; The latest round content representation of the round node in the updated context view tree is replaced with the new round content representation of the round node, and the new round content representation of the round node is recorded in the updated source interaction data tree.

4. The method according to claim 3, characterized in that, The updated context view tree records the past topic content representations of each topic thread node and maintains the compressed version chain of each topic thread node; After the step of recording the new round content representation of the round node in the updated source interaction data tree, the method further includes: returning to the step of determining the importance score and token length of each topic thread node, each round node, and each action step node in the updated context view tree, and if there is a node to be compressed in the updated context view tree and the node to be compressed is a topic thread node, selecting the topic thread node with the largest token length exceeding the limit from each topic thread node to be compressed as the target node; The process involves obtaining the compressed version chain of the target node from the updated context view tree, and obtaining the compressed version chains of each associated round node and each associated action step node involved in the target node from the source interaction data tree. Based on the compressed version chains of the target node, each associated round node, and each associated action step node, the process obtains the original topic content representation of the target node. The original topic content representation of the target node is compressed using a preset compression strategy to obtain a new topic content representation of the target node. The token length of the new topic content representation is less than a preset ratio of the token length of the latest topic content representation. The new topic content representation of the target node is stored as the latest topic content representation of the target node in the updated context view tree.

5. The method according to any one of claims 2-4, characterized in that, The method further includes: determining whether the number of topic thread nodes in the updated context view tree exceeds a preset threshold; if so, determining the topic thread node with the lowest importance score from the updated context view tree as the first topic thread node, and determining other topic thread nodes whose topics are most similar to the first topic thread node as the second topic thread node; merging the first topic thread node and the second topic thread node to generate a new topic thread and a topic content representation corresponding to the new topic thread; and updating the updated context view tree based on the topic content representation corresponding to the new topic thread.

6. A large model context processing device, characterized in that, The device includes: a construction module for constructing a source interaction data tree and a context view tree for the current dialogue event stream; the context view tree organizes topic thread nodes according to topic type; each topic thread node is attached with the latest round content representation of its own round nodes, and each round node is attached with the latest action step content representation of its own action step nodes; each action step node records the request-response result of each action step request; and an update module for obtaining new action step requests belonging to the current dialogue event stream, updating the context view tree and the source interaction data tree based on the new action step requests, and updating according to the updated... The updated context view tree is used to determine the pressure coefficient of the current context. A determining module is used to determine whether there are nodes to be compressed in the updated context view tree based on the pressure coefficient. Specifically, this includes: determining the importance score of each topic thread node in the updated context view tree, and determining the upper limit of the token length of each topic thread node based on the importance score and the pressure coefficient; determining the importance score of each round node in the updated context view tree, and determining the token length of each round node based on the importance score and the upper limit of the token length of the topic thread node to which each round node belongs. The text describes various steps and their implications, including: determining the importance score of each action step node in the updated context view tree; determining the upper limit of the token length of each action step node based on its importance score and the upper limit of the token length of the round node to which it belongs; determining the token length of each topic thread node, round node, and action step node in the updated context view tree; and determining whether the updated context view tree contains the specified token length based on the token length and upper limit of each topic thread node, round node, and action step node. A node to be compressed; a compression module, used to perform a back-to-source compression operation on the node to be compressed, if it exists, by combining the updated source interaction data tree and the updated context view tree, to update the updated context view tree and the updated source interaction data tree, and return to the step of determining the pressure coefficient of the current context based on the updated context view tree, until the node to be compressed does not exist in the updated context view tree; a generation module, used to expand the updated context view tree into context content and input it into the large language model, so that the large language model can output a request response result for the new action step request by combining the context content.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Multi-user large model interaction method, device and platform based on tree structure

    CN120234397A

  • Session processing method, system and equipment based on large language model

    CN120973889A