KV cache intelligent scheduling and semantic structure compression method and system based on knowledge graph

By introducing a knowledge graph structure and intelligent scheduling algorithm, the granularity limitations and static scheduling bottlenecks of the KV caching mechanism are solved, enabling efficient cache management and dynamic context understanding, thereby improving cache storage efficiency and the continuity of user interaction.

CN121900931APending Publication Date: 2026-04-21BEIJING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING UNIV OF TECH
Filing Date
2025-11-13
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing key-value caching mechanisms suffer from problems such as excessively fine caching granularity, severe redundancy, lack of structural semantic understanding, poor adaptability to dynamic scenarios, and weak semantic aggregation capabilities, resulting in wasted cache space, low hit rate, and limited context expansion capabilities.

Method used

A knowledge graph structure is introduced, and a knowledge graph is constructed through named entity recognition and relation extraction. Graph neural networks are used to embed nodes, and combined with structure compression algorithms and multi-semantic domain scheduling strategies, high-level semantic understanding and dynamic scheduling are achieved, optimizing cache granularity and semantic aggregation.

Benefits of technology

By reducing redundant storage, improving cache hit rate and response efficiency, enhancing adaptability to dynamic contexts, and improving the long text processing capabilities of large language models and the continuity of user interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121900931A_ABST
    Figure CN121900931A_ABST
Patent Text Reader

Abstract

The invention discloses a KV cache intelligent scheduling and semantic structure compression method and system based on a knowledge graph, and the method comprises the steps: firstly, extracting entities and relationships from an input text to construct the knowledge graph, and then employing a graph embedding and structure compression algorithm to aggregate nodes with similar semantics into a high-density semantic KV item, so as to eliminate redundancy, and improve the KV cache intelligent scheduling and semantic structure compression efficiency. And then constructing a semantic scheduling graph, and dynamically loading the most relevant semantic sub-graph cache through a semantic migration mechanism. According to the method, the problems of semantic redundancy, lack of structural understanding, poor dynamic adaptability and the like in a traditional KV cache are effectively solved, the cache utilization rate, semantic consistency and long-range context processing capacity are remarkably improved, and the method is suitable for scenes such as large language model reasoning acceleration and intelligent dialogue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer artificial intelligence, specifically to a method and system for intelligent scheduling and semantic structure compression of KV cache based on knowledge graphs. Background Technology

[0002] In the current field of artificial intelligence, especially in tasks such as large language models (LLM), intelligent question answering systems and semantic search, the key-value (KV) caching mechanism has become an important means to improve inference efficiency and extend the length of context. KV caching avoids repeated calculations by storing intermediate calculation results (such as key and value vectors of attention layers) during the inference process. It is widely used in the Transformer structure to support long context processing and streaming generation.

[0003] However, existing key-value caching mechanisms generally suffer from the following technical bottlenecks: The caching granularity is too fine, resulting in severe redundancy. Current systems typically construct key-value items at the token level, leading to the multiple storage of semantically duplicated or equivalent information, such as synonyms, references, and entity aliases. This not only causes significant waste of cache space but also limits the ability to extend the context.

[0004] Lacking structural semantic understanding, existing cache scheduling strategies are usually based on sequence, timestamp, or simple frequency models, lacking the ability to perceive the semantic structure of the context. Their semantic understanding is weak, and they cannot identify entity relationships, topic evolution, or user intent migration between information, resulting in low accuracy of scheduling decisions.

[0005] The traditional key-value (KV) mechanism has poor adaptability to dynamic scenarios. In tasks such as dialogue systems, multi-turn retrieval, and interactive recommendation, users' semantic needs and concerns are dynamically changing. The traditional KV mechanism lacks support for semantic evolution or domain switching, lacks intelligent scheduling mechanisms, and has rigid caching strategies. It cannot dynamically migrate and replace according to user intent or context changes, resulting in low cache hit rate, rigid update strategies, and an inability to intelligently adapt to context scenario migration.

[0006] The semantic aggregation capability is weak. KV caches usually adopt a linear sequence structure and do not have the ability to aggregate semantics across sentences, paragraphs or entities, resulting in fragmented information expression and limiting the model's comprehensive reasoning and long-term memory performance. Summary of the Invention

[0007] The technical problem to be solved by this invention is to address the shortcomings of the existing technology by proposing a knowledge graph-based KV cache intelligent scheduling and semantic structure compression method and system. This invention introduces a knowledge graph structure to achieve a higher level of semantic understanding and cache aggregation, breaks through the granularity limitations and static scheduling bottlenecks of traditional KV cache, reduces memory overhead, and improves response efficiency. It is particularly suitable for artificial intelligence applications that require high semantic consistency and dynamic contextual understanding.

[0008] To achieve the above objectives, the technical solution adopted by this invention is as follows: Step 1: Extract key information from the input raw text or context, including entities, relationships, and events, and construct a knowledge graph representing semantics; Step 2: Map the nodes and subgraph structures in the knowledge graph to the vector space, combine the semantic structure and computational structure, and reduce redundant representations through a graph compression algorithm to output high-density, structured semantic key-value pairs; Step 3: Based on semantic structure and contextual evolution, perform semantic partitioning and dynamic scheduling of semantic key-value pairs; Step 4: Dynamically update the knowledge graph and key-value cache during the reasoning process to achieve continuous evolution of semantic state.

[0009] Furthermore, the construction of the knowledge graph in step one specifically includes: The text is structured and parsed using named entity recognition, relation extraction, and event extraction techniques. Construct a knowledge graph G(V, E), where V represents semantic entities and E represents semantic relationships between entities; A context window mechanism is introduced to construct local subgraphs by paragraph, cycle, and topic. Named entity recognition and relation extraction techniques are used to extract entities and relations from the text. The output structured semantic graph G(V, E) is used as the input for the next module, graph embedding and cache mapping.

[0010] Furthermore, step two, mapping the nodes and subgraph structures in the knowledge graph to the vector space, specifically includes: embedding the nodes using a graph neural network to obtain h. v ∈R d , where h v R represents the embedding vector of a specific node v in a knowledge graph. d The set consisting of all d-dimensional real vectors; Using a structural compression algorithm, graph aggregation is performed on a subgraph basis, and multiple nodes with similar structures and semantics are aggregated into a semantically compressed key-value item. A key-value cache is constructed based on semantically compressed key-value items, mapping each compressed unit to a set of (KV items). i V iK represents the semantic index, and V represents the aggregated semantic representation vector.

[0011] The input to the structure compression algorithm is: The subgraph G′=(V′, E′) is a graph subgraph, and the graph nodes are embedded in h. v ∈R d The original set of key-value pairs {(K i V i )}, path set P(v); The structural compression algorithm includes the following steps: Step 1, Similar Subgraph Identification: Calculate the comprehensive similarity S between any two nodes. SPCS (i, j), the formula is as follows: , Among them, cos(h i h j ): Cosine similarity of node semantic embeddings, h i h j These are the i-th and j-th semantic nodes in the knowledge graph, respectively. Jaccard(N(i), N(j)): Neighbor structure similarity, where N(i) and N(j) represent the set of neighbor nodes of the i-th and j-th nodes in the knowledge graph; PathSim(v i v j ): Structural-semantic path consistency similarity indicates whether the semantic path patterns of nodes in the graph are consistent. Specifically, it encodes these paths into discrete semantic fragments using n-gram path representation and introduces soft-overlap similarity. , P represents the set of semantic paths corresponding to nodes in the knowledge graph, v i v j P(v) represents a semantic entity node in a knowledge graph. i That is, i semantic entity nodes v in the knowledge graph i The set consisting of all corresponding graph semantic paths, The parameter α+β+γ=1 controls the weights of the three components; Step 2, based on S SPCS Similarity matrix, perform graph-aware clustering, divide into semantically consistent sub-graph clusters C1, C2, ... Semantic key-value fusion, for each cluster C k Aggregate the key-value representations of its member nodes: , , Key and Value are merged using the mean; Step 3: Aggregate the Key vectors and Value vectors of all the original KV pairs corresponding to the nodes within the same clustering cluster respectively to construct an aggregated index mapping table, generate a compressed KV item representing this cluster, and the set of compressed KV items: , where m < n, indicating that effective compression is completed.

[0012] Furthermore, in Step 3, specifically, use the embedding results to construct a semantic similarity matrix, cluster it into multiple semantic subspaces, and apply a multi-semantic domain scheduling strategy. The multi-semantic domain scheduling strategy constructs a semantic domain scheduling graph. Through semantic walks, starting from the previously hit subgraph, jump and select along the high-weight paths in the graph to dynamically load the next relevant semantic domain; The multi-semantic domain scheduling strategy includes the following steps: Construct a directed scheduling graph G=(V, E, w), where V is the compressed semantic subgraph, E is the semantic transfer edge, and w(g i , g j ) is the edge weight, representing the semantic coherence or historical transfer probability from semantic domain g i to g j ; Initialize the starting point. If it is the initial round, select the default starting node g0, otherwise start from the previously hit node g prev ; Generate semantic walk candidates, obtain all the neighbor nodes N(g prev ), and for each neighbor g prev , calculate the scheduling score: j , where w() is the edge weight in the graph, δ(E input , g j ) is the matching degree between the input entity and the entities in g j , and λ is the scheduling weight for entity matching; Select candidate nodes and load the cache. Select the top m subgraphs with the highest scores as the scheduling targets, and load the KV compression blocks corresponding to the scheduling targets into the cache to complete cache dynamic replacement and merging.

[0013] Furthermore, the dynamic update in Step 4 specifically includes: using graph reasoning techniques based on rules or neural networks to supplement new entities and relationships, and applying the structure compression algorithm to the new content to generate new aggregated KV items; According to the drift situation of the current semantic context, use the scheduling strategy to allocate the new KV items to appropriate semantic subspaces.

[0014] A knowledge graph-based KV cache intelligent scheduling and semantic structure compression system, characterized in that the system includes: The semantic extraction and knowledge graph construction module extracts key information from the input raw text or context, including entities, concepts, relationships and events, and constructs a knowledge graph representing the semantic structure. The graph embedding and KV fusion module maps the nodes and subgraph structures in the knowledge graph to the vector space, combines semantic structure and computational structure, and reduces redundant representations through graph compression algorithms to output high-density, structured semantic KV pairs. The intelligent scheduling and multi-semantic space management module performs semantic partitioning and dynamic scheduling of the KV cache based on semantic structure and context evolution; The online reasoning and dynamic update module dynamically updates the knowledge graph and key-value cache during the reasoning process, enabling the continuous evolution of semantic state.

[0015] Compared with existing technologies, this invention achieves the following technical effects: By introducing a knowledge graph structure, it breaks through the granularity limitations and static scheduling bottlenecks of traditional KV caching; by using a structure compression algorithm, it reduces cache redundancy caused by token-level storage and synonym duplication, thereby improving storage efficiency; relying on the entity associations and semantic structures of the knowledge graph, it organizes the context into semantic subgraphs, realizing semantic domain-level KV access, optimizing the semantic fit of cache loading and replacement, and improving hit accuracy and retrieval speed; at the same time, it enhances the continuity of large model dialogue and the ability to maintain context through scheduling graph-driven semantic walks, and its scheduling strategy relies solely on the structured graph and historical trajectories to complete dynamic scheduling, significantly reducing semantic computation costs; the incremental construction and structure migration characteristics of the knowledge graph, combined with graph embedding and entity expansion mechanisms, can adapt to resource-constrained edge computing scenarios. Attached Figure Description

[0016] For ease of explanation, the present invention will be described in detail below with reference to specific embodiments and accompanying drawings.

[0017] Figure 1 A flowchart of a knowledge graph-based KV cache intelligent scheduling and semantic structure compression method provided in this embodiment of the invention; Figure 2 This is a schematic diagram of a knowledge graph-based KV cache intelligent scheduling and semantic structure compression system provided in an embodiment of the present invention. Detailed Implementation

[0018] The following are specific embodiments of the present invention, described in conjunction with the accompanying drawings, to further illustrate the technical solutions of the present invention. However, the present invention is not limited to these embodiments. Specific details, such as particular configurations, are provided in the following description merely to aid in a comprehensive understanding of the embodiments of the present invention. Therefore, those skilled in the art should understand that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention.

[0019] This embodiment provides a knowledge graph-based KV cache intelligent scheduling and semantic structure compression method to improve the long text processing capability and caching efficiency of large language models, such as... Figure 1 The workflow of the present invention is shown.

[0020] Step 1: Extract key information from the input raw text or context, including entities, relationships, and events, and construct a knowledge graph representing semantics.

[0021] Contextual semantic compression based on knowledge graph structure is implemented. The original text input (such as long documents or multi-turn dialogue history) is received and the entities and semantic relationships between them are extracted from the text using technologies such as Named Entity Recognition (NER) and Relation Extraction (RE). A structured knowledge graph G(V, E) is constructed. This graph transforms the original linear text sequence into a network rich in semantic relationships, providing a foundation for subsequent structural merging.

[0022] Specifically, building a knowledge graph includes using techniques such as named entity recognition, relation extraction, and event extraction to perform structured parsing of text.

[0023] Construct a knowledge graph G(V, E), where V represents semantic entities and E represents semantic relationships between entities.

[0024] A context window mechanism is introduced to construct local subgraphs by paragraph, turn, and topic. Named entity recognition and relation extraction technologies are used to extract entities and relations from the text. Local knowledge subgraphs are constructed by dividing by context window, dialogue turn, or topic.

[0025] Output a structured semantic graph G(V, E).

[0026] Step 2: Map the nodes and subgraph structures in the knowledge graph to the vector space, combine the semantic structure and computational structure, and reduce redundant representations through a graph compression algorithm to output high-density, structured semantic key-value pairs.

[0027] The graph embedding and key-value fusion module begins its work, performing compression aggregation based on the semantic similarity of the subgraph structure. It first uses a graph neural network to embed each node in the knowledge graph into a low-dimensional vector space, obtaining h. v ∈R dThe SKVM (Structured Subgraph Graph) algorithm is activated. Instead of simply comparing individual tokens, SKVM identifies repetitive or highly similar substructures before semantic subgraph compression. It calculates the overall similarity S between any two nodes (i, j). SPCS (i, j), this similarity innovatively integrates three parts: the cosine similarity of the node embedding vectors cos(h i h j The algorithm uses the Jaccard similarity of neighboring node sets and the PathSim similarity, which reflects the consistency of semantic path patterns between two nodes in the graph, to cluster nodes based on the comprehensive similarity matrix, grouping nodes with similar semantics and structures into the same cluster C. k In this process, the identification of semantically repetitive subgraphs was achieved, laying the foundation for subsequent fusion.

[0028] The structural compression algorithm performs graph aggregation on a subgraph basis, aggregating multiple nodes with similar structures and semantic relevance into a semantically compressed key-value item. A key-value cache is then constructed based on these items, mapping each compression unit to a set of (KV) keys. i V i K represents the semantic index, and V represents the aggregated semantic representation vector; The input to the structural compression algorithm is: a graph subgraph G′=(V′, E′), and graph node embeddings h. v ∈R d The original set of key-value pairs {(K i V i )}, path set P(v); The structure compression algorithm includes the following steps: Step 1, Similar Subgraph Identification: Calculate the comprehensive similarity S between any two nodes. SPCS (i, j), the formula is as follows: (1) Among them, cos(h i h j ): Cosine similarity of node semantic embeddings, h i h j These are the i-th and j-th semantic nodes in the knowledge graph, respectively. Jaccard(N(i), N(j)): Neighbor structure similarity, where N(i) and N(j) represent the set of neighbor nodes of the i-th and j-th nodes in the knowledge graph; PathSim(v i v j): Structural-semantic path consistency similarity, which indicates whether the semantic path patterns of nodes in the graph are consistent. Specifically, these paths are encoded as discrete semantic fragments using the n-gram path representation method, and the soft-overlap similarity is introduced: , P represents the set of semantic paths corresponding to nodes in the knowledge graph, and v i , v j represents the semantic entity nodes in the knowledge graph. P(v i ) is the set of all graph semantic paths corresponding to the i-th semantic entity node v i in the knowledge graph, The parameters α + β + γ = 1 to control the weights of the three; Step 2: Based on the S SPCS similarity matrix, perform graph-aware clustering and divide it into sub-graph clusters C1, C2,... for semantic KV fusion. For each cluster C k , aggregate the KV expressions of its member nodes: , (3) , (4) Key and Value are fused using the mean; Step 3: Aggregate the Key vectors and Value vectors of the original KV pairs corresponding to all nodes within the same clustering cluster respectively, construct an aggregated index mapping table, generate a compressed KV item representing the cluster, and the set of compressed KV items: , (5) where m < n, indicating that effective compression is completed.

[0029] Step 3: According to semantic structure and context evolution, perform semantic partitioning and dynamic scheduling on the semantic KV pairs.

[0030] Generate a Key-Value compressed storage structure that combines the semantic center and the graph structure. For each semantic node cluster C obtained in the above steps k , the system performs structure-level merging: Aggregate the original and scattered KV pairs (K i , V i ) corresponding to all member nodes within the cluster; specifically, calculate the mean of the Key vectors and Value vectors of these nodes respectively to generate a new compressed KV item (K k , V k ) representing the overall semantics of the cluster, where K k is used as the index of this semantic center, and V kThis is the aggregated semantic representation vector; it realizes the structural merging of key-value information and the deduplication of duplicate information, and extracts the semantic center, ultimately generating a high-density, non-redundant compressed storage structure, which greatly improves the density of KV usage and avoids repeated calls and redundant calculations.

[0031] Subsequently, a multi-semantic scheduling strategy for semantic graphs is implemented for dynamic management. Based on their semantic features, all compression items are clustered and divided into multiple semantic subspaces (i.e., semantic domains). The core innovation lies in constructing a semantic domain scheduling graph G=(V, E, w), where node V is a semantic subgraph g. i Edge E represents the association between subgraphs, and edge weight w represents semantic similarity or historical transition probability. When the cache needs to be loaded, a semantic walk is performed: starting from the currently active subgraph node g... prev Starting from the left, it traverses its neighbors and calculates the scheduling score of each neighbor node (considering the edge weight and the matching degree between the entity in the new input query and the subgraph). It selects the top K subgraphs with the highest scores and dynamically loads their corresponding compressed KV blocks into the cache or replaces the old cache. The multi-semantic scheduling strategy realizes precise dynamic loading and replacement at the semantic subgraph level based on context logic, rather than the traditional linear or simple frequency strategy. Specifically, the multi-semantic domain scheduling strategy includes the following steps: Construct a directed scheduling graph G=(V,E,w), where V is a compressed semantic subgraph, E is a semantic transition edge, and w(g) = (V,E,w). i g j Let ) be the edge weight, indicating the weight from the semantic domain g. i to g j Semantic coherence or historical transition probability; Initialize the starting point. If it is the initial round, select the default starting node g0; otherwise, start from the node g that was hit in the previous round. prev Set off; Semantic walk candidate generation, obtaining g prev All neighboring nodes N(g) prev For each neighbor g j Calculate the scheduling score: (6) Where w() is the edge weight in the graph, δ(E) input g j ) is the input entity and g j The degree of matching between entities, where λ is the scheduling weight for entity matching; Candidate nodes are selected and cached. The top m subgraphs with the highest scores are selected as scheduling targets. The KV compressed blocks corresponding to the scheduling targets are loaded into the cache to complete the dynamic replacement and merging of the cache.

[0032] Step 4: Dynamically update the knowledge graph and key-value cache during the reasoning process to achieve continuous evolution of semantic state.

[0033] During the reasoning process, the input is continuously monitored, new entities and relationships are dynamically identified, and the knowledge graph is updated. For new content, rule-based or neural network-based graph reasoning techniques are used to complete the new entities and relationships. The structure compression algorithm described above is applied to the new content to generate new aggregated key-value items. Based on the current semantic context drift, the scheduling strategy is used to allocate the new key-value items to appropriate semantic subspaces and update the scheduling graph structure.

[0034] The present invention provides a knowledge graph-based KV cache intelligent scheduling and semantic structure compression method, which constitutes an overall technical solution that can continuously evolve and dynamically adapt. This enables dynamic updates and incremental learning of the KV cache, supporting complex application scenarios involving long-range contextual understanding and user intent migration.

[0035] Furthermore, this embodiment of the invention takes a multimodal nonverbal emotion expression system for social robots as an example. This embodiment integrates three nonverbal channels: eye lighting (L), voice tone (T), and body movement (G), and integrates three modalities: vision, hearing, and physical action. Through a neural network structure and a timing control mechanism, it constructs empathetic robot emotional feedback behavior, realizes natural, synchronous, and coherent nonverbal expression, makes the robot's emotional feedback closer to that of humans, and enhances the empathy and naturalness of human-computer interaction.

[0036] In the emotion recognition and language perception stage, the robot captures the user's speech, frowning expression and pacing posture when they are insomnia and irritable. It extracts emotional entities such as insomnia and irritability through named entity recognition, extracts clear insomnia-trigger-irritability associations through relation extraction, and constructs a local knowledge graph subgraph containing emotions, scene entities and relationships to complete text understanding-graph modeling.

[0037] Graph neural networks (GCN, R-GCN) are used to embed nodes into the subgraph of the constructed emotion knowledge graph, transforming entities such as insomnia and irritability into high-dimensional semantic vectors (h). v ∈R d At the same time, the Structure Compression (SKVM) algorithm is introduced to calculate the comprehensive similarity S between entities. SPCS (i,j) – This considers both the cosine similarity of entity semantic embedding (e.g., the semantic proximity of irritability and anxiety), as well as the similarity of neighbor structure (e.g., whether the association between insomnia and health problems is consistent with the association between dizziness and health problems) and the semantic consistency of paths (e.g., the similarity of the path pattern between user-insomnia-induced irritability and user-stress-induced irritability). Based on similarity, entities are clustered to form a negative emotion-physical condition semantic cluster. The original key-value pairs within the cluster are merged to generate compressed key-value items, thus solving the problem of redundancy in traditional caches.

[0038] A semantic similarity matrix is ​​constructed based on the embedded vectors of compressed key-value items. The semantic space of the robot's emotion expression is divided into multiple subspaces, each of which serves as an independent scheduling unit. When the system receives a compressed key-value item, it calculates the similarity between the key-value item and the cluster centers of each subspace through a multi-semantic domain scheduling strategy, assigns it to the relevant subspace, and loads the associated historical key-value items within that subspace. Finally, based on the loaded compressed key-value items, multimodal nonverbal expression vectors are generated, namely eye lighting vectors, voice tone vectors, and body movement vectors, ensuring that the expression vectors are highly matched with the user's emotional semantics.

[0039] A semantic domain scheduling graph is constructed. When a user adds relevant health questions later, a semantic walk is performed starting from the current subspace. The scheduling scores of adjacent subspaces are calculated, relevant subspace key-value items are loaded, and the original non-verbal expression vectors are dynamically adjusted to achieve natural switching through temporal smoothing.

[0040] During the behavior generation phase, while outputting non-verbal expressions, user feedback is monitored, implicit relationships are completed using graph reasoning, the graph is updated and new compressed key-value items are generated, and they are assigned to corresponding subspaces in conjunction with emotion drift to complete dynamic cache updates and achieve continuous evolution.

[0041] Through this entire process, the social robot's non-verbal emotional expressions can accurately match the user's dynamic emotions and scenario needs. The system can also quickly respond to changes in emotional semantics through dynamic scheduling of the semantic subspace, maintaining the coherence and consistency of non-verbal expressions. This demonstrates the key supporting role of knowledge graph-based KV caching intelligent scheduling and semantic structure compression methods in improving the long-range understanding and dynamic context perception capabilities of intelligent systems, and significantly enhances the empathetic experience of robot-user interaction.

[0042] The following describes the knowledge graph-based KV cache intelligent scheduling and semantic structure compression system provided by the embodiments of the present invention. The knowledge graph-based KV cache intelligent scheduling and semantic structure compression system described below can be referred to in correspondence with the knowledge graph-based KV cache intelligent scheduling and semantic structure compression method described above.

[0043] Combination Figure 2 This paper introduces a knowledge graph-based KV cache intelligent scheduling and semantic structure compression system, such as... Figure 2 As shown, this knowledge graph-based KV cache intelligent scheduling and semantic structure compression system may include: The semantic extraction and knowledge graph construction module 100 is used to extract key information from the input raw text or context, including entities, concepts, relationships and events, and to construct a knowledge graph representing the semantic structure. The graph embedding and KV fusion module 200 is used to map the nodes and subgraph structures in the knowledge graph to the vector space and interface with the KV caching system. The intelligent scheduling and multi-semantic space management module 300 is used to perform semantic division and dynamic scheduling of KV cache according to semantic structure and context evolution, so as to realize cache management according to semantic field; The online reasoning and dynamic update module 400 is used to dynamically identify newly emerging semantic nodes and relationships during user interaction or text evolution, and update the knowledge graph and key-value cache.

[0044] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined with each other.

[0045] Those skilled in the art to which this application pertains may make various modifications or additions to the specific embodiments described, or adopt similar methods to replace them, without departing from the inventive concept of this application or exceeding the scope defined by the appended claims.

Claims

1. A knowledge graph-based KV cache intelligent scheduling and semantic structure compression method, characterized in that, It includes the following steps: Step 1: Extract key information from the input original text or context, including entities, relationships, and events, and construct a knowledge graph representing semantics. Step 2: Map the nodes and subgraph structures in the knowledge graph to a vector space, combine the semantic structure and computational structure, and reduce redundant representations through a graph compression algorithm to output high-density, structured semantic KV pairs. Step 3: Perform semantic partitioning and dynamic scheduling on the semantic KV pairs according to the semantic structure and context evolution. Step 4: Dynamically update the knowledge graph and KV cache during the reasoning process to achieve continuous evolution of the semantic state.

2. The method for intelligent scheduling and semantic structure compression of KV cache based on knowledge graph as described in claim 1, characterized in that, Specifically, constructing the knowledge graph in Step 1 includes: Structurally parse the text using named entity recognition, relationship extraction, and event extraction technologies. Construct a knowledge graph G(V, E), where V represents semantic entities and E represents semantic relationships between entities. Introduce a context window mechanism, construct local subgraphs according to paragraphs, turns, and themes, and use named entity recognition and relationship extraction technologies to extract entities and relationships from the text. Output the structured semantic graph G(V, E) as the input for the next module's graph embedding and cache mapping.

3. The method for intelligent scheduling and semantic structure compression of KV cache based on knowledge graph as described in claim 1, characterized in that, Step two, mapping nodes and subgraph structures in the knowledge graph to a vector space, specifically includes: embedding nodes using a graph neural network to obtain h. v ∈R d , where h v R represents the embedding vector of a specific node v in a knowledge graph. d The set of all d-dimensional real vectors; Use a structure compression algorithm to perform graph aggregation in units of subgraphs, and aggregate multiple nodes with similar structures and related semantics into one semantic KV pair. Construct a key-value cache based on semantic key-value pairs, mapping each compression unit to a set (KV). i V i K represents the semantic index, and V represents the aggregated semantic representation vector. Among them, the input of the structure compression algorithm is: The subgraph G′=(V′, E′) is a graph subgraph, and the graph nodes are embedded in h. v ∈R d The original set of key-value pairs {(K i V i )}, path set P(v); The structure compression algorithm includes the following steps: Step 1, Similar Subgraph Identification: Calculate the comprehensive similarity S between any two nodes. SPCS (i, j), the formula is as follows: , Among them, cos(h i h j ): Cosine similarity of node semantic embeddings, h i h j These are the i-th and j-th semantic nodes in the knowledge graph, respectively. Jaccard(N(i), N(j)): Neighbor structure similarity, where N(i) and N(j) represent the neighbor node sets of the i-th and j-th nodes in the knowledge graph. PathSim(v i v j ): Structural-semantic path consistency similarity indicates whether the semantic path patterns of nodes in the graph are consistent. Specifically, it encodes these paths into discrete semantic fragments using n-gram path representation and introduces soft-overlap similarity. , P represents the set of semantic paths corresponding to nodes in the knowledge graph, v i v j P(v) represents a semantic entity node in a knowledge graph. i That is, i semantic entity nodes v in the knowledge graph i The set consisting of all corresponding graph semantic paths, Parameters α + β + γ = 1 to control the weights of the three. Step 2, based on S SPCS Similarity matrix, perform graph-aware clustering, divide into semantically consistent sub-graph clusters C1, C2, ... Semantic key-value fusion, for each cluster C k Aggregate the key-value representations of its member nodes: , , Key and Value use mean fusion. Step 3: Aggregate the Key vectors and Value vectors of the original KV pairs corresponding to all nodes within the same clustering cluster respectively, construct an aggregated index mapping table, generate a compressed KV item representing the cluster, and the set of compressed KV items: , Among them, m < n indicates that effective compression is completed.

4. The method for intelligent scheduling and semantic structure compression of KV cache based on knowledge graph as described in claim 1, characterized in that, Specifically, Step 3 uses the embedding results to construct a semantic similarity matrix, clusters it into multiple semantic subspaces, and applies a multi-semantic domain scheduling strategy. The multi-semantic domain scheduling strategy constructs a semantic domain scheduling graph, and through semantic walks, starting from the previously hit subgraph, jumps and selects along the high-weight paths in the graph to dynamically load the next relevant semantic domain. The multi-semantic domain scheduling strategy includes the following steps: Construct a directed scheduling graph G=(V,E,w), where V is a compressed semantic subgraph, E is a semantic transition edge, and w(g) = (V,E,w). i g j Let ) be the edge weight, indicating the weight from the semantic domain g. i to g j Semantic coherence or historical transition probability; Initialize the starting point. If it is the initial round, select the default starting node g0; otherwise, start from the node g that was hit in the previous round. prev Set off; Semantic walk candidate generation, obtaining g prev All neighboring nodes N(g) prev For each neighbor g j Calculate the scheduling score: , Where w() is the edge weight in the graph, δ(E) input g j ) is the input entity and g j The degree of matching between entities, where λ is the scheduling weight for entity matching; Select candidate nodes and load the cache, select the top m subgraphs with the highest scores as scheduling targets, and load the KV compression blocks corresponding to the scheduling targets into the cache to complete cache dynamic replacement and merging.

5. The method for intelligent scheduling and semantic structure compression of KV cache based on knowledge graph as described in claim 1, characterized in that, The dynamic update in Step 4 specifically includes: Using graph reasoning technologies based on rules or neural networks to supplement new entities and relationships, and applying the structure compression algorithm to the new content to generate new aggregated KV items. According to the drift situation of the current semantic context, use the scheduling strategy to allocate the new KV items to appropriate semantic subspaces.

6. A knowledge graph-based KV cache intelligent scheduling and semantic structure compression system, characterized in that, The system includes: A semantic extraction and knowledge graph construction module that extracts key information from the input original text or context, including entities, concepts, relationships, and events, and constructs a knowledge graph representing semantic structure. The graph embedding and KV fusion module maps the nodes and subgraph structures in the knowledge graph to the vector space, combines semantic structure and computational structure, and reduces redundant representations through graph compression algorithms to output high-density, structured semantic KV pairs. The intelligent scheduling and multi-semantic space management module performs semantic partitioning and dynamic scheduling of the KV cache based on semantic structure and context evolution; The online reasoning and dynamic update module dynamically updates the knowledge graph and key-value cache during the reasoning process, enabling the continuous evolution of semantic state.