A method for optimizing a context window for a large model based on cognition

By establishing a directed association structure graph and using the PageRank algorithm to update entry weights, combined with finite state machine filtering and aggregation of contextual information, the problem of inadequate information management in existing technologies is solved, achieving more efficient information processing and output consistency.

CN122114175APending Publication Date: 2026-05-29BEIJING INFORMATION TECH BOTE INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING INFORMATION TECH BOTE INTELLIGENT TECH CO LTD
Filing Date
2026-02-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively manage information under limited context window lengths, leading to redundant, expired, or weakly related information consuming computational resources, poor consistency between output results and task objectives, frequent forgetting and repeated queries during multi-round interactions, and high computational costs.

Method used

By building a directed association structure graph around context entries, updating entry weights using the PageRank algorithm, generating an importance table, and combining a finite state machine to filter eligible entries, the system performs sorting and aggregation to form a hierarchical context.

Benefits of technology

It increases the focus on key information during the model inference stage, reduces the overhead of invalid inference and computational cost, improves the consistency between the output results and the task objectives, and reduces the probability of forgetting and repeated queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122114175A_ABST
    Figure CN122114175A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of context management, in particular to a method for optimizing a context window of a large model based on cognition. In the application, a PageRank algorithm is used to perform iterative updating on a directional correlation weight and output an entry importance distribution, the ratio of importance to length is entered into sorting and reserved items are selected under capacity constraints, multiple conclusion dependent evidence is entered into a forced reserved path, contradictory evidence is entered into an exclusive selection and replacement numbering registration path, a finite state machine is used to filter windowable entries according to a context stage identifier, and a life cycle marker and version number are linked to exclude expired conflict content, conclusion numbers are aggregated to form aggregated units and an index placeholder is written for excessive units, non-referenced units are executed to reserve index mapping, the probability of forgetting and repeatedly asking in cross-round interaction is reduced, window occupancy fluctuation converges, invalid reasoning overhead and calculation cost are reduced, and the proportion of task target related information is increased, thereby improving output consistency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of context management technology, and in particular to a cognitive-based method for optimizing the context window of a large model. Background Technology

[0002] The field of context management technology aims to establish an executable method for organizing, selecting, compressing, and sorting information around the set of information required by a computer system during reasoning or interaction, under the condition of limited context window length. By evaluating the importance of candidate context items, assigning priorities, and controlling budgets, it suppresses redundant, expired, or weakly related information from occupying computing resources, improves the consistency between model output and task objectives, factual consistency, and interaction continuity, while reducing invalid reasoning overhead and controlling computing costs.

[0003] A cognitive-based method for optimizing the context window of a large model aims to improve the consistency between the output and the task objective, reduce the probability of factual deviation, and decrease the incidence of forgetting and repeated questioning in multi-turn interactions, while maintaining stable quality under limited computational resources, under the constraint that the length of the context window of a large model is fixed and non-scalable. This is achieved by constructing a cognitive decision-making mechanism centered on the task objective and supported by dialogue state and evidence constraints. The method performs hierarchical screening, priority ranking, and budget allocation on candidate context items, and improves the attention to key information during the model inference stage as the control objective.

[0004] Existing technologies primarily focus on importance assessment and budget control. Importance is derived from single-round scoring and linear weighting. There is a lack of unified, structured expression for citation and constraint relationships between items. Conclusion-dependent evidence chains lack traceable indexes. Key evidence is easily squeezed out during window truncation, and backfilling paths are missing. For example, in multi-round question answering, the same conclusion depends on multiple pieces of evidence across rounds. After budget contraction, only summary fragments are retained, losing evidence location, leading to evidence gaps in subsequent generation and triggering repeated follow-up questions. Existing technologies tend to maintain windows with full rearrangement or coarse-grained replacement. There is a lack of linkage constraints between the dialogue stage and the item lifecycle. Conflicting statements coexist and trigger oscillating outputs. Furthermore, existing technologies often use simple weight reduction or mixed retention for conflicting evidence, lacking mutually exclusive retention and substitution mapping. Conflicting items create mutual pull after entering the window. Existing technologies are inadequate in managing aggregation and index space. Excess content removal tends to be direct deletion. The lack of consecutive round criteria for uncited content judgments and missing index mappings increase traceability costs. For example, in follow-up question scenarios, the window only retains the conclusion item, lacking evidence numbers and location clues, requiring context reorganization and leading to response fluctuations and increased costs. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by proposing a cognitive-based method for optimizing the context window of a large model.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a method for optimizing the context window of a large model based on cognition, comprising the following steps: S1: Based on the directed association structure of context entries, assign numbers to the target, constraint, evidence, and conclusion entries within the window, record the relationship between the reference position and the constraint position, register the dependency index in the order of appearance, and establish an association structure diagram; S2: Based on the aforementioned association structure diagram, reference pointers are assigned level values ​​according to explicit identifiers, phrase identifiers, and pronoun identifiers, and the number of times is accumulated. Limit pointers are assigned level values ​​according to constraint strength, and the coverage ratio is calculated. Using the PageRank algorithm, the weights of multiple entries are summarized and updated according to the inbound weights until the stopping condition is met, and an importance table is generated. S3: Based on the importance table, sort the evidence items according to the ratio of importance to space length, select the items to be retained, force the retention of evidence that depends on multiple conclusions, perform single selection on contradictory evidence, and generate an evidence retention set; S4: Based on the evidence retention set, a finite state machine is used to filter eligible entries according to the context stage identifier, remove elimination markers and exclude old version entries, rearrange the numbering sequence according to the target segment, constraint segment, evidence segment, conclusion segment and change log segment, compare the current round sequence with the previous round sequence and form an insertion, deletion and movement set, and generate a window sequence. S5: Based on the window sequence, aggregate entries by conclusion number, sort aggregate units, write index placeholders for units exceeding capacity, perform rollback on units that are no longer referenced, and establish hierarchical context.

[0007] As a further embodiment of the present invention, the association structure graph includes an item number set, a reference edge set, a constraint edge set, an edge weight level table, an inbound edge list, and an outbound edge list; the importance table includes an item number list, an importance value list, a normalization coefficient, an iteration round marker, and a stopping condition marker; the evidence retention set includes a retained evidence number set, a discarded evidence number set, a bridging evidence number set, a mutually exclusive pair number set, and a substitute evidence number mapping; the window sequence includes a target segment number sequence, a constraint segment number sequence, an evidence segment number sequence, a conclusion segment number sequence, and a change log number sequence; and the hierarchical context includes a root summary field set, a local summary field set, a leaf item number set, a number mapping table, an index placeholder item set, and a rollback retained number set.

[0008] As a further aspect of the present invention, the specific steps for generating the associated structure diagram are as follows: Based on the directed association structure around the context entries, a unique number is assigned to each target entry, constraint entry, evidence entry, and conclusion entry in the window. The sequential position and type identifier of each entry in the window are recorded to obtain the entry number set. Based on the set of entry numbers, the reference position pointing relationship and the limited position pointing relationship are registered one by one, the preceding number and the following number are recorded according to the pointing direction, and the dependency order is written into the index list to establish the association structure graph.

[0009] As a further aspect of the present invention, the specific steps for generating the importance table are as follows: Based on the aforementioned association structure diagram, each reference pointing record is read one by one. For each pointing record, it is determined whether it contains a clear number, continuous text fragments, or cross-sentence reference markers. The corresponding markers are mapped to different level values. The number of times the same source entry repeatedly points to the same target entry is accumulated. The pointing number, level value, and accumulated number are written into a unified record table to obtain the reference weight set. Based on the reference weight set, each limited pointing record is read one by one, and strength values ​​are assigned to the mandatory, prohibited, should, and optional identifiers respectively. At the same time, the ratio of the number of constrained fields to the total number of fields in the limited entries is counted. The strength values ​​and coverage ratios are written into the limited record and associated with the corresponding entry number to obtain the limited weight set. Based on the defined weight set, the PageRank algorithm is used to summarize all incoming reference values ​​and defined values ​​for each item, perform multiple rounds of weight updates and record the changes in values ​​after each round of updates. When the changes in two consecutive rounds are lower than the set difference condition, the update stops, and the final weight and item number are written into the result table to generate an importance table.

[0010] As a further aspect of the present invention, the PageRank algorithm first reads the node set and the directed edge set, reads the weight value of each directed edge, calculates the edge weight sum for each starting node, and normalizes the outgoing edge weights to obtain the transfer ratio. A damping coefficient is set, and the initial weight vector is set to the uniform value of all nodes. A new weight vector is calculated according to the iteration rounds. The new weight vector is obtained by adding the damping coefficient to the basic term, multiplying by the product of the weight of the incoming edge source node and the transfer ratio, and summing the results. After completing one round of iteration, the sum of the differences between the old and new vectors is calculated and written into the change record table. When the sum of the differences for two consecutive rounds is lower than the set difference condition, the iteration stops. The weight vector of the stopped round is written into the result table according to the item number to form an importance table.

[0011] As a further aspect of the present invention, the specific steps for generating the evidence retention set are as follows: Based on the importance table, the importance value and place length value of each evidence item are read one by one, the corresponding ratio is calculated and arranged according to the ratio, and the items pointed to by multiple conclusion numbers are marked to obtain the evidence ranking table. Based on the evidence ranking table, under the window capacity limit, the items ranked first are selected, items with multiple conclusion dependencies are directly retained, items with contradictory markers are individually removed and their replacement numbers are registered, and an evidence retention set is generated.

[0012] As a further aspect of the present invention, the specific steps for generating the window sequence are as follows: Based on the evidence retention set, a finite state machine is used to read the entry number one by one and match it with the current context stage identifier. Entries that are not allowed to enter the current stage are directly removed. At the same time, the life cycle mark is checked to see if it is in the obsolescence state and the version number is compared to see if it is the latest. The entry set that can be entered is obtained by summarizing the entry numbers checked. Based on the set of windowable items, the item numbers are arranged in the order of target segment, constraint segment, evidence segment, conclusion segment, and change log segment, and the segment position index is recorded for each number to form the current round window number sequence list. At the same time, the previous round window number sequence list is retained to obtain the current window sequence. Based on the current window sequence, it is compared item by item with the previous round of window number sequence to identify newly added numbers, disappeared numbers, and numbers whose positions have changed. The three types of numbers are written into the difference record table as the output of the current round of window update results, and a window sequence is generated.

[0013] As a further aspect of this invention, a finite state machine is employed. First, a set of pre-defined states is established, including target setting state, constraint clarification state, reasoning execution state, and result confirmation state. A set of pre-defined events is established, including new target instruction, new constraint instruction, error correction statement, confirmation statement, and follow-up statement. The current state identifier is read, input statements are read and categorized according to the event set, and the presence or absence of new constraint and error correction flags is checked. The next state identifier is obtained by looking up a table based on the event type, adding new constraint and error correction flags, and updating the current state identifier. The set of allowed entry types for the next state is read, and the entry type corresponding to each entry number and the set of allowed states are read one by one, with matching judgments performed. Entries with failed matches are written to a removal list, while those with successful matches enter a candidate list and continue to be marked as eliminated and their version number as latest. Entries that meet the judgment criteria are written to the set of eligible entries.

[0014] As a further aspect of the present invention, the specific steps for generating the hierarchical context are as follows: Based on the window sequence, aggregate entries with the same conclusion number, write the associated evidence number and constraint number into the same aggregation unit, and record the number of numbers for each aggregation unit to obtain an aggregation unit set; Based on the aggregated unit set, index placeholder records are written for units that exceed the window capacity, and units that have not been referenced for multiple consecutive rounds are removed while retaining the index mapping, thus forming a hierarchical context.

[0015] As a further aspect of the present invention, the step of writing the associated evidence number and constraint number into the same aggregation unit, wherein the set of fields written in the aggregation unit specifically includes the conclusion number, the set of evidence numbers associated with the conclusion number, the set of constraint numbers associated with the conclusion number, the entry type identifier corresponding to each number, the version number identifier corresponding to each number, and the paragraph position index of each number in the window sequence. The conclusion number is used as the primary key field of the aggregation unit, the set of evidence numbers and the set of constraint numbers are stored as subordinate fields, the version number and the lifecycle marker are used to distinguish entries with the same number but different states, and the paragraph position index is used to identify the arrangement position of the entry in the window.

[0016] Compared with the prior art, the advantages and positive effects of the present invention are as follows: In this invention, a traceable link is formed by registering entry numbers and dependency indexes around a restricted context window. The reference position and the restricted position are entered into the same directed association expression. The weight of the reference edge is determined by the explicit identifier phrase identifier, the identifier level value, and the superimposed reference count. The consistency judgment result participates in the weight correction. The weight of the restricted edge is composed of the constraint strength and the coverage ratio. In this invention, the PageRank algorithm is used to iteratively update the directed association weights and output the importance distribution of the items. The ratio of importance to occupancy length is used for sorting and retention items are selected under capacity constraints. Evidence with multiple conclusions depends on each other and is forced to be retained. Conflicting evidence is selected and replaced by alternative numbering. In this invention, a finite state machine is used to filter windowable entries based on context stage identifiers and link lifecycle markers and version numbers to exclude expired and conflicting content. The differences between the current round sequence and the previous round sequence are transcribed into an insertion, deletion, and movement set and executed under restrictions. Conclusion numbers are aggregated to form aggregation units, and excess units are written with index placeholders. Units that are no longer referenced are rolled back to retain the index mapping. The frequency of information entering the window is more stable, the probability of evidence chain breakage decreases, the probability of forgetting and repeated questioning in cross-round interactions decreases, window occupancy fluctuations converge, invalid reasoning overhead and computational cost decrease, the proportion of task objective-related information increases, and output consistency increases. Attached Figure Description

[0017] Figure 1 This is a schematic diagram of the main steps of the present invention. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0019] Example 1 Please see Figure 1This invention provides a technical solution: a method for optimizing the context window of a large model based on cognition, comprising the following steps: S1: Based on the directed association structure of context entries, assign numbers to the target, constraint, evidence, and conclusion entries within the window, record the relationship between the reference position and the constraint position, register the dependency index in the order of appearance, and establish an association structure diagram; S2: Based on the association structure graph, references are assigned level values ​​and their counts are accumulated according to explicit identifiers, phrase identifiers, and pronoun identifiers. Limitations are assigned level values ​​according to constraint strength and their coverage ratio is calculated. The PageRank algorithm is used to summarize and update the weights of multiple entries according to the inbound weights until the stopping condition is met, and an importance table is generated. S3: Based on the importance table, sort the evidence items according to the ratio of importance to space length, select the items to be retained, force the retention of evidence that depends on multiple conclusions, perform single selection on contradictory evidence, and generate an evidence retention set; S4: Based on the evidence retention set, a finite state machine is used to filter eligible entries according to the context stage identifier, remove elimination markers and exclude old version entries, rearrange the numbering sequence according to the target segment, constraint segment, evidence segment, conclusion segment, and change log segment, compare the current round sequence with the previous round sequence to form an insertion, deletion, and movement set, and generate a window sequence. S5: Based on the window sequence, aggregate entries by conclusion number, sort aggregated units, write index placeholders for units exceeding capacity, perform rollback on units that are no longer referenced, and establish hierarchical context.

[0020] The association structure graph includes an item number set, a reference edge set, a constraint edge set, an edge weight level table, an inbound edge list, and an outbound edge list. The importance table includes an item number list, an importance value list, normalization coefficients, iteration round markers, and stopping condition markers. The evidence retention set includes a retained evidence number set, a discarded evidence number set, a bridging evidence number set, a mutually exclusive pair number set, and a substitute evidence number mapping. The window sequence includes a target segment number sequence, a constraint segment number sequence, an evidence segment number sequence, a conclusion segment number sequence, and a change log number sequence. The hierarchical context includes a root summary field set, a local summary field set, a leaf item number set, a number mapping table, an index placeholder item set, and a rollback retained number set.

[0021] The specific steps for generating the association structure diagram are as follows: Based on the directed association structure around the context entries, a unique number is assigned to each target entry, constraint entry, evidence entry, and conclusion entry in the window. The sequential position and type identifier of each entry in the window are recorded to obtain the entry number set. Based on the item number set, the reference position pointing relationship and the limited position pointing relationship are registered item by item, the preceding number and the following number are recorded according to the pointing direction, and the dependency order is written into the index list to establish the association structure graph. Based on the directed association structure around context items, the sequential numbering method is adopted to traverse the target items, constraint items, evidence items, and conclusion items in the window one by one. The starting value of the number is set to 1 and incremented in the traversal order. The window position index is read and written to the sequential position field, the item type identifier is read and written to the type field, a window position to number mapping table is established and the number value is written, a number duplication check is performed and duplicate number records are removed, and the number mapping table, sequential position field, and type field are summarized to generate an item number set. Based on the item number set, a directed relation graph construction method is used to read the reference position markers of the conclusion items one by one and locate the evidence item numbers. The reference edge list is written according to the previous number pointing to the next number. Similarly, the constraint position markers of the constraint items one by one and locate the conclusion item numbers are read. The constraint edge list is written according to the constraint number pointing to the conclusion number. The direction identifier and edge type identifier of each edge are recorded and written into the edge record table. The edge is written into the dependency order index list according to the registration order. The node number set, reference edge list, constraint edge list, and dependency order index list are summarized to establish an association structure graph.

[0022] The specific steps for generating the importance table are as follows: Based on the association structure graph, the reference pointing record is read one by one. For each pointing record, it is determined whether it contains a clear number, continuous text fragments or cross-sentence reference markers. The corresponding markers are mapped to different level values. The number of times the same source entry repeatedly points to the same target entry is accumulated. The pointing number, level value and accumulated number are written into a unified record table to obtain the reference weight set. Based on the reference weight set, the limited pointing record is read one by one, and the intensity value is assigned to the mandatory, prohibited, should, and optional flags respectively. At the same time, the ratio of the number of constrained fields to the total number of fields in the limited entry is counted. The intensity value and the coverage ratio are written into the limited record and associated with the corresponding entry number to obtain the limited weight set. Based on a limited weight set, the PageRank algorithm is used to summarize all incoming reference values ​​and limited values ​​for each item, perform multiple rounds of weight updates and record the changes in values ​​after each round of updates. When the changes in two consecutive rounds are lower than the set difference condition, the update stops and the final weight and item number are written into the result table to generate an importance table. Based on the association structure graph, a reference weight calculation method is adopted. The reference pointing record is read one by one and the pointing text position is parsed. Cases containing explicit numbers are marked as high level, cases containing continuous text segments are marked as medium level, and cases containing cross-sentence reference marks are marked as low level. The level marks are converted into preset numerical ranges and written into the level field. At the same time, the number of times the same source entry points to the same target entry is accumulated. The upper limit of the number of times is set to a fixed integer value and stops increasing after the upper limit is reached. The pointing number, level value, and accumulated number of times are written into a unified record table row by row to generate a reference weight set. Based on the reference weight set, a limited weight mapping method is adopted to read the limited pointing record one by one and parse the constraint identifier content. High intensity values ​​are assigned to the required identifier, high intensity values ​​are assigned to the prohibited identifier, medium intensity values ​​are assigned to the required identifier, and low intensity values ​​are assigned to the optional identifier. At the same time, the number of constrained fields in the limited entries is counted one by one and the total number of fields is counted. The ratio of the number of fields to the total number of fields is calculated and the maximum ratio threshold is limited. The intensity value and the coverage ratio are written into the limited record table and associated with the corresponding entry number to generate the limited weight set. Based on a limited weight set, the PageRank algorithm is used to read all item numbers and initialize the weight values ​​to uniformly distributed values. The damping coefficient is set as a fixed constant and written into the control field. For each item, all incoming reference weight values ​​and limited weight values ​​are summarized. Weight updates are performed in the order of iteration rounds, and the changes in weight values ​​in the current round are recorded after each round. When the change value is lower than the set difference threshold for two consecutive rounds, the update stops. The weight value corresponding to the stopped round and the item number are written into the result record table one by one to generate an importance table.

[0023] The PageRank algorithm first reads the set of nodes and the set of directed edges, reads the weight value of each directed edge, calculates the weight sum of the edges for each starting node, and normalizes the weights of the outgoing edges to obtain the transfer ratio. It sets a damping coefficient and sets the initial weight vector to the uniform value of all nodes. It calculates the new weight vector according to the iteration round. The new weight vector is obtained by adding the damping coefficient to the basic term, multiplying it by the product of the weight of the source node of the incoming edge and the transfer ratio, and summing the results. After completing one round of iteration, it calculates the sum of the differences between the old and new vectors and writes it into the change record table. When the sum of the differences is lower than the set difference condition for two consecutive rounds, it stops the iteration. The weight vector of the stopped round is written into the result table according to the item number to form the importance table. The PageRank algorithm, according to the formula: in: Indicates the first Context entries after round weight update Cognitive importance value within the context window of the large model. Indicates the first After the round weight is updated, it is consistent with the context entry. Context entries with reference associations exist The cognitive importance value, This indicates the target context entry number whose cognitive importance is being calculated. Indicates the target context entry The context entry number that forms the incoming reference. This indicates the context entry within the context window. A set of multiple entries that form a semantic or logical reference relationship. Indicates context entry Creates a set of multiple entries with outgoing references within the context window. Indicates context entry Pointing to context entry Reference strength value This indicates that the context entry is based on cognitive constraints. Pointing to context entry The assigned weight values Indicates context entry The sum of all outgoing reference strength values ​​and the limit weight value. This represents the damping coefficient used to adjust the proportion of cognitive propagation within the context window. This represents the total number of context items involved in the cognitive importance calculation. Indicates the iteration round number for updating cognitive importance; Execution process: Within the large model context window, number the multiple context entries involved in context management as follows: Initialize the cognitive importance value corresponding to each context entry. And based on the semantic sequence, logical reference, or instruction dependency relationships between context entries, an inbound reference set is constructed. With outgoing reference set In each iteration, for any context entry traverse its ingress reference set Read each incoming context entry Cognitive importance value in the previous iteration and context entries Pointing to context entry Reference strength value With limited weight values After accumulation, according to the context entries The sum of all outgoing reference strengths and the defined weight values ​​is normalized, and then the damping coefficient is adjusted accordingly. Under control, a weighted summation of each input contribution is performed, while introducing a method based on the total number of entries. The basic cognitive distribution term yields the first... Renewed cognitive importance value After updating all context entries, the change in cognitive importance between two consecutive rounds is calculated. The iteration is terminated when the change in two consecutive rounds is lower than a preset threshold. The final stable cognitive importance value is used as the sorting basis for context entries in the large model context window to determine the context retention, compression or priority scheduling strategy.

[0024] The specific steps for generating the evidence reserve set are as follows: Based on the importance table, the importance value and place length value of each evidence item are read one by one, the corresponding ratio is calculated and arranged according to the ratio, and the items pointed to by multiple conclusion numbers are marked to obtain the evidence ranking table. Based on the evidence ranking table, under the window capacity limit, select the items ranked first, directly retain items with multiple conclusion dependencies, and perform single-item elimination and register replacement numbers for items with contradictory markers to generate the evidence retention set; Based on the importance table, the value-cost ranking method is adopted. The importance value and the placeholder length value of each evidence item are read one by one. The importance value is used as the value item and the placeholder length value is used as the cost item. For each evidence item, the value item is divided by the cost item to calculate the ratio value. The item number and the ratio value are written into the ranking record table and sorted in descending order according to the ratio value. At the same time, the conclusion number pointing relationship table is traversed. Evidence items that are pointed to by two or more conclusion numbers are marked with a multi-dependency mark. The ranking results and dependency marks are summarized to generate the evidence ranking table. Based on the evidence sorting table, a capacity constraint selection method is adopted. A window capacity limit value is set and the occupied capacity value is initialized. Evidence item numbers and placeholder length values ​​are read one by one in sorting order. The placeholder length values ​​are accumulated to the occupied capacity value and compared with the capacity limit value. Items that do not exceed the limit are written to the retention list, and items that exceed the limit are written to the candidate elimination list. Evidence items marked with multiple dependencies are directly written to the retention list. At the same time, the conflict relationship record table is traversed. Evidence items with conflict indicators are retained individually and their alternative number mappings are registered. The retention list and alternative number mappings are summarized to generate the evidence retention set.

[0025] The specific steps for generating a window sequence are as follows: Based on the evidence retention set, a finite state machine is used to read the entry number one by one and match it with the current context stage identifier. Entries that are not allowed to enter the current stage are directly removed. At the same time, the life cycle mark is checked to see if it is in the obsolescence state and the version number is compared to see if it is the latest. The entry set that can enter the window is obtained by summarizing the entry numbers checked. Based on the set of windowable items, the item numbers are arranged in the order of target segment, constraint segment, evidence segment, conclusion segment, and change log segment, and the segment position index is recorded for each number to form the current round window number sequence list. At the same time, the previous round window number sequence list is retained to obtain the current window sequence. Based on the current window sequence, it is compared item by item with the previous round of window number sequence to identify newly added numbers, disappeared numbers and numbers whose positions have changed. The three types of numbers are written into the difference record table as the output of the current round of window update results, and a window sequence is generated. Based on the evidence retention set, a finite state machine is used. A pre-set state set is loaded with the current context stage identifier. The item number and corresponding item type identifier are read one by one. The item type identifier is matched with the current state's allowed entry type set. At the same time, the life cycle flag field is read and it is determined whether it is equal to the elimination state. The version number field is read and compared with the largest version number of the same type of item. Only the item numbers that match, have a life cycle that is not elimination, and have the latest version number are written into the candidate list. The remaining item numbers are written into the elimination list. The item numbers in the candidate list are summarized to generate a set of items that can enter the window. Based on the set of windowable entries, a paragraph order arrangement method is adopted. Preset paragraph order rules are read and the order of target paragraph, constraint paragraph, evidence paragraph, conclusion paragraph, and change log paragraph is loaded. The set of windowable entries is traversed paragraph by paragraph and the corresponding paragraph number sequence is written according to the entry type. At the same time, the intra-segment position index value is written for each number and the global order index value is recorded. The current round of paragraph number sequence and intra-segment position index are summarized and stored, and the previous round of window number order list is read synchronously to generate the current window sequence. Based on the current window sequence, the shortest editing script is used to read the current round window number sequence list and the previous round window number sequence list item by item, build the number alignment relationship, and compare whether the number exists in the other list step by step. Numbers that only exist in the current round list are recorded as insertion numbers, numbers that only exist in the previous round list are recorded as deletion numbers, and numbers that exist at the same time but have different sequence indices are recorded as movement numbers. The insertion numbers, deletion numbers, and movement numbers are written into the difference record table and their corresponding sequence index information are attached. The contents of the difference record table are summarized to generate the window sequence.

[0026] Using a finite state machine, the following steps are taken: First, a set of predefined states is set as target setting state, constraint clarification state, reasoning execution state, and result confirmation state. A set of predefined events is set as new target instruction, new constraint instruction, error correction statement, confirmation statement, and follow-up statement. The current state identifier is read, the input statement is read and the event is classified according to the event set. The presence of new constraint markers and error correction markers is checked. The next state identifier is obtained by looking up the table according to the event type, and the current state identifier is updated. The set of allowed entry types for the next state is read. The entry type corresponding to the entry number and the set of allowed states are read one by one and a matching judgment is performed. The entry number of the failed match is written to the elimination list. The entry number of the matched entry enters the candidate list and continues to be marked as elimination judgment and the version number is the latest judgment. The entry number that meets the judgment is written to the set of entries that can be entered into the window. Finite state machines, according to the formula: in: Indicates the context entry number is The value of the window entry determination result, This indicates the context entry number that is processed one by one in the evidence retention set. This indicates an indicator function, and the result calculated within the parentheses is 1 if it is greater than zero, otherwise it is 0. This represents the weight coefficient value corresponding to the stage matching item. This represents the weight coefficient value corresponding to the lifecycle item. This represents the weighting coefficient value corresponding to the version consistency item. This represents the weight coefficient value corresponding to the state stability term. Represents a continuous compression function and takes the form of This indicates that the finite state machine is in state Lower input receiver The output value after the state transition, This indicates the finite state machine state identifier corresponding to the current context phase. Indicates context entry The corresponding stage triggers the input value. Indicates the current context phase The corresponding stage tolerance offset parameter value, Indicates context entry The lifecycle elimination flag is set and takes a value of 0 or 1. Indicates context entry The lifecycle buffer enhancement parameter value, Indicates context entry Version number value, Indicates context entry A set of entries with the same evidence identifier. Represents a set The maximum value of the version number of the entry. This indicates the value of the version freshness index parameter. Indicates context entry The state transition friction parameter values, This indicates the value of the threshold parameter for entering the window; Execution process: First, during the scheduling of the large model context window, the context entry numbers are read one by one from the evidence reserve set. And obtain the stage trigger input corresponding to the entry. Simultaneously, it reads the cognitive stage of the current context window and maps it to obtain the current state of the finite state machine. Then and Input to the finite state machine state transition function The stage matching results are calculated by introducing a stage tolerance offset parameter. The state transition result is shifted and corrected, and then passed through a continuous compression function. Convert to a smooth stage-matched cognitive score, then read contextual entries. Lifecycle obsolescence marker ,exist Introducing a lifetime buffer enhancement parameter when indicating a non-obsolescence state It also calculates the lifecycle effectiveness score, directly weakening the overall cognitive score of an item when its lifecycle is in an obsolescence state, and then reads the context of the item. Version number value and in the set of entries with the same evidence identifier. The maximum version number is calculated as the normalization benchmark, and the parameter is amplified by the version freshness index. The version ratio is exponentially amplified to emphasize the advantage of the latest version, and then the context entries are calculated. Friction parameters of state transition during the cognitive stage transition process Furthermore, the tendency of frequently cross-stage entries to enter the window is suppressed by using an exponential decay function. Then, the stage matching score, lifecycle score, version freshness score, and state stability score are respectively weighted by their corresponding coefficients. , , , Multiply and sum to get the entries. The comprehensive cognitive score is then compared with the entry threshold parameter. Compare and use as an indicator function The input is the windowing condition, and the output is the windowing feasibility judgment value. Otherwise output Finally, all of them The context entry numbers are aggregated to form a set of windowable entries, which is used to guide the content retention, eviction, and scheduling strategies of the large model context window.

[0027] The specific steps for generating a hierarchical context are as follows: Based on the window sequence, aggregate entries with the same conclusion number, write the associated evidence number and constraint number into the same aggregation unit, and record the number of numbers for each aggregation unit to obtain an aggregation unit set; Based on the aggregated unit set, index placeholder records are written to units that exceed the window capacity, and units that have not been referenced for multiple consecutive rounds are removed while retaining the index mapping, thus forming a hierarchical context. Based on window sequences, a conclusion aggregation construction method is adopted. The item numbers in the window sequence are read one by one and the corresponding conclusion number fields are parsed. Items with the same conclusion number are written into the same aggregation buffer. An evidence number list and a constraint number list are established in the aggregation buffer. The associated evidence number is appended to the evidence list in the order of reading and the associated constraint number is appended to the constraint list in the order of reading. At the same time, a number counter is maintained for each aggregation buffer and the count value is incremented each time it is written. The conclusion number, evidence number list, constraint number list and number count value are written into the aggregation record table. After all items are traversed, the contents of the aggregation record table are summarized to generate an aggregation unit set. Based on the set of aggregated units, a hierarchical compression organization method is adopted. The count value of the aggregated unit number is read one by one and compared with the preset window capacity limit. For aggregated units that exceed the capacity limit, an index placeholder record is generated and written to the index mapping table. For aggregated units that do not exceed the capacity limit, they are directly written to the window retention list. At the same time, the reference count record of the aggregated unit is read and the value of consecutive unreferenced cycles is accumulated. When the value of consecutive unreferenced cycles reaches the preset threshold, the corresponding aggregated unit is removed from the window retention list and only the index mapping relationship is retained. The contents of the window retention list and the index mapping table are summarized to form a hierarchical context.

[0028] The associated evidence number and constraint number are written into the same aggregation unit. The set of fields written into the aggregation unit specifically includes the conclusion number, the set of evidence numbers associated with the conclusion number, the set of constraint numbers associated with the conclusion number, the entry type identifier corresponding to each number, the version number identifier corresponding to each number, and the paragraph position index of each number in the window sequence. The conclusion number is used as the primary key field of the aggregation unit, and the set of evidence numbers and the set of constraint numbers are stored as subordinate fields. The version number and lifecycle flag are used to distinguish entries with the same number but different states, and the paragraph position index is used to identify the arrangement position of the entry in the window.

[0029] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A cognitive-based method for optimizing the context window of a large model, characterized in that, Includes the following steps: S1: Based on the directed association structure of context entries, assign numbers to the target, constraint, evidence, and conclusion entries within the window, record the relationship between the reference position and the constraint position, register the dependency index in the order of appearance, and establish an association structure diagram; S2: Based on the aforementioned association structure diagram, reference pointers are assigned level values ​​according to explicit identifiers, phrase identifiers, and pronoun identifiers, and the number of times is accumulated. Limit pointers are assigned level values ​​according to constraint strength, and the coverage ratio is calculated. Using the PageRank algorithm, the weights of multiple entries are summarized and updated according to the inbound weights until the stopping condition is met, and an importance table is generated. S3: Based on the importance table, sort the evidence items according to the ratio of importance to space length, select the items to be retained, force the retention of evidence that depends on multiple conclusions, perform single selection on contradictory evidence, and generate an evidence retention set; S4: Based on the evidence retention set, a finite state machine is used to filter eligible entries according to the context stage identifier, remove elimination markers and exclude old version entries, rearrange the numbering sequence according to the target segment, constraint segment, evidence segment, conclusion segment and change log segment, compare the current round sequence with the previous round sequence and form an insertion, deletion and movement set, and generate a window sequence. S5: Based on the window sequence, aggregate entries by conclusion number, sort aggregate units, write index placeholders for units exceeding capacity, perform rollback on units that are no longer referenced, and establish hierarchical context.

2. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The association structure graph includes an item number set, a reference edge set, a constraint edge set, an edge weight level table, an inbound edge list, and an outbound edge list. The importance table includes an item number list, an importance value list, a normalization coefficient, an iteration round marker, and a stopping condition marker. The evidence retention set includes a retained evidence number set, a discarded evidence number set, a bridging evidence number set, a mutually exclusive pair number set, and a substitute evidence number mapping. The window sequence includes a target segment number sequence, a constraint segment number sequence, an evidence segment number sequence, a conclusion segment number sequence, and a change log number sequence. The hierarchical context includes a root summary field set, a local summary field set, a leaf item number set, a number mapping table, an index placeholder item set, and a rollback retained number set.

3. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The specific steps for generating the aforementioned association structure diagram are as follows: Based on the directed association structure around the context entries, a unique number is assigned to each target entry, constraint entry, evidence entry, and conclusion entry in the window. The sequential position and type identifier of each entry in the window are recorded to obtain the entry number set. Based on the set of entry numbers, the reference position pointing relationship and the limited position pointing relationship are registered one by one, the preceding number and the following number are recorded according to the pointing direction, and the dependency order is written into the index list to establish the association structure graph.

4. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The specific steps for generating the importance table are as follows: Based on the aforementioned association structure diagram, each reference pointing record is read one by one. For each pointing record, it is determined whether it contains a clear number, continuous text fragments, or cross-sentence reference markers. The corresponding markers are mapped to different level values. The number of times the same source entry repeatedly points to the same target entry is accumulated. The pointing number, level value, and accumulated number are written into a unified record table to obtain the reference weight set. Based on the reference weight set, each limited pointing record is read one by one, and strength values ​​are assigned to the mandatory, prohibited, should, and optional identifiers respectively. At the same time, the ratio of the number of constrained fields to the total number of fields in the limited entries is counted. The strength values ​​and coverage ratios are written into the limited record and associated with the corresponding entry number to obtain the limited weight set. Based on the defined weight set, the PageRank algorithm is used to summarize all incoming reference values ​​and defined values ​​for each item, perform multiple rounds of weight updates and record the changes in values ​​after each round of updates. When the changes in two consecutive rounds are lower than the set difference condition, the update stops, and the final weight and item number are written into the result table to generate an importance table.

5. The method for optimizing the context window of a large model based on cognition according to claim 4, characterized in that, The PageRank algorithm first reads the set of nodes and the set of directed edges, reads the weight value of each directed edge, calculates the weight sum of the edges for each starting node, and normalizes the weights of the outgoing edges to obtain the transfer ratio. It sets a damping coefficient and sets the initial weight vector to the uniform value of all nodes. It calculates the new weight vector according to the iteration round. The new weight vector is obtained by adding the damping coefficient to the basic term, multiplying it by the product of the weight of the source node of the incoming edge and the transfer ratio, and summing the results. After completing one round of iteration, it calculates the sum of the differences between the old and new vectors and writes it into the change record table. When the sum of the differences for two consecutive rounds is lower than the set difference condition, it stops iterating. The weight vector of the stopped round is written into the result table according to the item number to form an importance table.

6. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The specific steps for generating the evidence retention set are as follows: Based on the importance table, the importance value and place length value of each evidence item are read one by one, the corresponding ratio is calculated and arranged according to the ratio, and the items pointed to by multiple conclusion numbers are marked to obtain the evidence ranking table. Based on the evidence ranking table, under the window capacity limit, the items ranked first are selected, items with multiple conclusion dependencies are directly retained, items with contradictory markers are individually removed and their replacement numbers are registered, and an evidence retention set is generated.

7. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The specific steps for generating the window sequence are as follows: Based on the evidence retention set, a finite state machine is used to read the entry number one by one and match it with the current context stage identifier. Entries that are not allowed to enter the current stage are directly removed. At the same time, the life cycle mark is checked to see if it is in the obsolescence state and the version number is compared to see if it is the latest. The entry set that can be entered is obtained by summarizing the entry numbers checked. Based on the set of windowable items, the item numbers are arranged in the order of target segment, constraint segment, evidence segment, conclusion segment, and change log segment, and the segment position index is recorded for each number to form the current round window number sequence list. At the same time, the previous round window number sequence list is retained to obtain the current window sequence. Based on the current window sequence, it is compared item by item with the previous round of window number sequence to identify newly added numbers, disappeared numbers, and numbers whose positions have changed. The three types of numbers are written into the difference record table as the output of the current round of window update results, and a window sequence is generated.

8. The method for optimizing the context window of a large model based on cognition according to claim 7, characterized in that, Using a finite state machine, the following steps are taken: First, a set of predefined states is set as target setting state, constraint clarification state, reasoning execution state, and result confirmation state. A set of predefined events is set as new target instruction, new constraint instruction, error correction statement, confirmation statement, and follow-up statement. The current state identifier is read, the input statement is read and the event is classified according to the event set. The presence of new constraint markers and error correction markers is checked. The next state identifier is obtained by looking up the table according to the event type, and the current state identifier is updated. The set of allowed entry types for the next state is read. The entry type and the set of allowed states corresponding to the entry number are read one by one and a matching judgment is performed. The entry number of the failed match is written to the elimination list. The entry number of the matched entry enters the candidate list and continues to be marked as elimination judgment and the version number is the latest judgment. The entry number that meets the judgment is written to the set of entries that can be entered into the window.

9. The method for optimizing the context window of a large model based on cognition according to claim 1, characterized in that, The specific steps for generating the hierarchical context are as follows: Based on the window sequence, aggregate entries with the same conclusion number, write the associated evidence number and constraint number into the same aggregation unit, and record the number of numbers for each aggregation unit to obtain an aggregation unit set; Based on the aggregated unit set, index placeholder records are written for units that exceed the window capacity, and units that have not been referenced for multiple consecutive rounds are removed while retaining the index mapping, thus forming a hierarchical context.

10. The method for optimizing the context window of a large model based on cognition according to claim 9, characterized in that, The process of writing the associated evidence number and constraint number into the same aggregation unit is described. The set of fields written into the aggregation unit specifically includes the conclusion number, the set of evidence numbers associated with the conclusion number, the set of constraint numbers associated with the conclusion number, the entry type identifier corresponding to each number, the version number identifier corresponding to each number, and the paragraph position index of each number in the window sequence. The conclusion number is used as the primary key field of the aggregation unit, and the set of evidence numbers and the set of constraint numbers are stored as subordinate fields. The version number and lifecycle marker are used to distinguish entries with the same number but different states, and the paragraph position index is used to identify the arrangement position of the entry in the window.