A memory network construction and traversal retrieval method based on five-dimensional cross correlation
Patent Information
- Application Number
- CN202611166805.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-03
- Publication Date
- 2026-10-20
AI Technical Summary
如现有记忆优化系统(CN121328718B)公开了一种"主题-实体-关系"三层记忆图谱方案,采用来源可信度评分和用户偏好向量,但该方案依赖BERT或Transformer等预训练语言模型生成记忆向量,计算资源开销大,单条记忆标签生成延迟在五十至一百毫秒级别,且需要图形处理器加速,不适合大规模实时场景
[0031]第一,支持五维联合过滤检索。可以处理如"与项目X相关的、最近一周内的、用户提及的、重要性大于等于零点五的记忆"这类五维联合查询,现有单维度或双维度技术无法实现。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to long-term memory systems in the field of artificial intelligence, and particularly to a method for constructing a five-dimensional cross-associative memory network and graph traversal retrieval for multi-session memory storage and cross-session associative retrieval. Background Technology
[0002] Long-term memory (LTM) is a core component of AI dialogue systems, responsible for storing, managing, and retrieving information generated during historical dialogues. As the number of dialogue rounds and sessions increases, efficiently retrieving information relevant to the current question from massive amounts of memory becomes a key technological challenge.
[0003] In existing technologies, memory retrieval typically employs the following methods:
[0004] First, there's single-dimensional retrieval based on semantic similarity. For example, the Retrieval Augmentation Generative (RAG) architecture calculates the cosine similarity between the query vector and the memory vector, returning the top-k most relevant memory entries. This approach relies solely on semantic similarity and cannot handle complex queries requiring multi-dimensional filtering. For instance, querying "important projects mentioned by the user last week" requires filtering both "time" (last week) and "importance" (important), which single-dimensional semantic retrieval cannot effectively handle.
[0005] Second, two-dimensional retrieval. Some systems add time filtering on top of semantic similarity, but the filtering conditions between dimensions are usually independent superpositions (logical AND), lacking cross-correlation between dimensions. For example, they cannot handle queries that require cross-correlation between dimensions, such as "Which topics in recent events related to entity A are similar to B?"
[0006] Third, memory management based on knowledge graphs. For example, the existing memory optimization system (CN121328718B) discloses a three-layer memory graph scheme of "topic-entity-relationship," employing source credibility scores and user preference vectors. However, this scheme relies on pre-trained language models such as BERT or Transformer to generate memory vectors, resulting in high computational resource overhead. The generation latency of a single memory label is on the order of fifty to one hundred milliseconds, and it requires GPU acceleration, making it unsuitable for large-scale real-time scenarios. Furthermore, the inter-dimensional relationships in this scheme are represented by a single-layer relationship graph, which does not support cross-relationship traversal of multiple dimensions within the same graph structure.
[0007] Fourth, importance cannot be quantified. Existing systems either do not distinguish the importance of memories or rely solely on manual annotation. There is a lack of a method to automatically calculate importance scores based on content features (length, role, entity density, timeliness).
[0008] Fifth, cross-session aggregation is difficult. Existing systems typically process each session's memory independently during cross-session retrieval, lacking a method to aggregate the memory network topology of multiple sessions into a unified graph structure.
[0009] Sixth, the time dimension processing is coarse-grained and inefficient. Existing memory systems typically handle time processing at the application layer. This involves first obtaining the top-k memory entries through semantic retrieval during the retrieval enhancement generation process, and then filtering the retrieval results by time at the application layer. For example, the cognitive method based on timeline memory in the human-computer dialogue system disclosed in CN107153685A extracts time expressions using a CRF model and constructs a timeline in chronological order. However, this approach parses time expressions on demand and performs linear scanning at the application layer, resulting in a query complexity of O(n). Furthermore, it fails to distinguish between event time and message timestamps, leading to inaccurate time-series query results. In addition, existing systems typically only process absolute time (e.g., "2023-03-15"), ignoring relative time (e.g., "two days ago"), duration (e.g., "within three days"), and time range (e.g., "from March to May"), failing to fully recognize the time expressions commonly used by users in dialogues. Summary of the Invention
[0010] Technical problems to be solved
[0011] The technical problems to be solved by this invention are: how to construct a multi-dimensional cross-linked memory network in a long-term memory system to support cross-dimensional joint filtering retrieval, how to automatically quantify memory importance, how to aggregate memory subgraphs of multiple sessions into a unified graph structure, and how to construct a fine-grained timeline index at the architecture layer to support efficient time-series queries and the distinction between event time and message timestamps.
[0012] Technical solution
[0013] To address the aforementioned technical problems, this invention provides a method for constructing and traversing a memory network based on a five-dimensional cross-association of entity-time-topic-source-importance, comprising the following steps:
[0014] S1: Five-dimensional label generation. Generate five-dimensional labels for each memory entry in memory storage:
[0015] Time dimension labeling: Based on the time difference between the creation time and the current time of a memory entry, it is mapped into five time buckets according to a non-linear bucketing rule. A time difference of 24 hours or less is the recent bucket, greater than 24 hours and less than or equal to 7 days is the short-term bucket, greater than 7 days and less than or equal to 30 days is the medium-term bucket, greater than 30 days and less than or equal to 180 days is the long-term bucket, and greater than 180 days is the archive bucket. This non-linear bucketing corresponds to the five-stage decay pattern of human memory: recent, short-term, medium-term, long-term, and archive. In addition, the time dimension also includes identifying four types of time expressions—absolute time, relative time, duration, and time range—from the content text of memory entries through regular expression pattern matching and normalizing them to ISO-8601 format; extracting time-series events and distinguishing event dates from message creation timestamps; and pre-building an ordered timeline index during memory writing to support O(log n) binary search range queries.
[0016] Topic-based tagging: The content text of memory entries is analyzed using Chinese bigram statistics and English non-stop word frequency statistics. The most frequent topic words are used as tags. This method requires no pre-trained model, incurs zero computational resource overhead, and supports mixed Chinese and English content.
[0017] Entity-level labeling: Text content is scanned using 2-gram, 3-gram, and 4-gram sliding windows based on CJK characters. Stopped segments are filtered out before entities are extracted. Capitalized first-letter words, @ mentions, and # hashtags are recognized in English text. A maximum of twelve entities are retained after deduplication and order preservation.
[0018] Importance Dimension Labels: Importance scores are calculated using a weighted average of four factors. Factor 1 is content length (weight 0.35), calculated as the smaller of the number of characters in the content divided by a preset constant and 1. Factor 2 is message role (weight 0.15), with user messages receiving 0.15 points, assistant messages receiving 0.10 points, and system and tool messages each receiving 0.05 points. Role scores range from 0 to 1. Factor 3 is entity density (weight 0.30), calculated as the smaller of the number of entities divided by 5 and 1. Factor 4 is timeliness (weight 0.20), using an exponential decay function with a half-week lifespan, calculated as 0.5 days since creation divided by the seventh power. The importance score is calculated as 0.35 multiplied by the length score, 0.15 multiplied by the role score, 0.30 multiplied by the entity density score, and 0.20 multiplied by the timeliness score.
[0019] Source dimension tags: Based on message role mapping, user messages are mapped to user, assistant messages to assistant, system messages to system, and tool messages to tool.
[0020] S2: Cross-association graph construction. Based on five-dimensional labels, four types of edges are constructed between memory nodes within the same session:
[0021] Temporally adjacent edges: connect adjacent memory nodes on the same session's time series, with a fixed weight of 1.0. A sliding window mechanism is used during construction, with a default window size of eight, meaning each node only has temporal edges calculated with its subsequent eight nodes.
[0022] Entity-shared edge: A connection is established when two nodes share at least one entity label. The weight is the number of shared entities divided by the smaller entity number among the two nodes.
[0023] Semantic similarity edges: A connection is established when the cosine similarity of the vectors of two nodes is greater than 0.82, and the weight is the cosine similarity value.
[0024] Time proximity edge: A connection is established when the creation time difference between two nodes is less than 3,600 seconds, and the weight is one minus the ratio of the time difference to 3,600.
[0025] All four types of edges can coexist in the same graph structure, and any two nodes can have all four types of edges at the same time, forming a five-dimensional cross-association.
[0026] S3: Multidimensional Joint Retrieval. Receives query requests, which may contain filtering conditions for one or more dimensions. Performs a logical and combined filtering traversal of the five-dimensional labels on the memory network: for each node, sequentially checks the entity dimension (whether the entity is in the node's entity label), the time dimension (whether the node's time bucket matches), the source dimension (whether the node's source type matches), the topic dimension (whether the node's topic label matches), and the importance dimension (whether the node's importance score is greater than or equal to a threshold). Nodes that simultaneously meet all conditions constitute a candidate set, and the top-k results are returned in descending order of importance score.
[0027] S4: Cross-session graph aggregation. Aggregates memory subgraphs from multiple sessions into an organization-level unified graph. Nodes are deduplicated by unique identifiers; when the same identifier appears in multiple subgraphs, the node with the higher importance score is retained. Edges are deduplicated by a triple of source node identifier, destination node identifier, and edge type.
[0028] It should be noted that the coarse-grained bucketing labels and fine-grained timeline indexes together constitute a two-level filtering mechanism for the time dimension: time bucketing enables coarse-grained fast filtering, while the timeline index enables fine-grained precise querying. The session identifier set returned by the timeline index serves as the input for time dimension filtering, and is executed uniformly with the time bucketing filtering of the five-dimensional labels in the logical and combined filtering in step S3. Both belong to the collaborative technical features under the same overall inventive concept.
[0029] Beneficial effects
[0030] Compared with the prior art, the present invention has the following advantages:
[0031] First, it supports five-dimensional joint filtering retrieval. It can handle five-dimensional joint queries such as "related to project X, within the last week, mentioned by users, and memories with importance greater than or equal to 0.5", which cannot be achieved by existing single-dimensional or two-dimensional technologies.
[0032] Second, the label generation has zero resource overhead. All five-dimensional labels are implemented using rule-based statistical methods, without relying on pre-trained language models or graphics processors. The label generation latency is less than one millisecond per label, which is two orders of magnitude lower than the fifty to one hundred milliseconds per label of named entity recognition models.
[0033] Third, importance is automatically quantified. Importance scores are automatically calculated by weighting four factors: content length, role, entity density, and timeliness, without the need for manual labeling. The recall accuracy for highly important memories (greater than 0.7) is over 95%, while the recall accuracy for memories without importance distinction is approximately 80%.
[0034] Fourth, it supports large-scale cross-session aggregation. Cross-session graph aggregation supports the aggregation of more than one thousand sessions, while existing technologies typically support less than one hundred sessions.
[0035] Fifth, the overall system achieved an accuracy of 99.2% in the LongMemEval question-answering benchmark test (496 out of 500 questions answered correctly), an improvement of 9 percentage points compared to the single-dimensional RAG baseline of 90.6%.
[0036] Sixth, reduced computational complexity and resource consumption. The five-dimensional label generation uses rule-based statistical methods, with a time complexity of O(n) (where n is the number of characters) and a space complexity of O(1) for a single label. It does not rely on pre-trained language models or graphics processors and can be executed in real-time without GPU acceleration. Compared to existing memory optimization systems (CN121328718B) that rely on BERT / Transformer models to generate memory vectors, the label generation latency is reduced from fifty to one hundred milliseconds to less than one millisecond, a reduction of approximately two orders of magnitude. Furthermore, it does not require a graphics processor, significantly reducing deployment costs. The graph construction stage employs a sliding window mechanism (window size of eight), reducing the computational complexity of temporal edges from O(n²) to O(n×k) (where k is the window size), effectively controlling the computational overhead of graph construction in large-scale memory networks. Multi-dimensional joint retrieval uses label logic and filtering, eliminating the need for additional vector reordering calculations, resulting in a retrieval latency of less than fifty milliseconds.
[0037] Seventh, fine-grained time-series query and architecture-level indexing. Building upon coarse-grained bucketing of time-dimensional labels, this invention further provides fine-grained time expression extraction and architecture-level timeline indexing. Compared to existing timeline memory schemes (such as CN107153685A), which use application-level parsing of time expressions and linear scanning with O(n) complexity, this invention's architecture-level pre-built ordered index uses binary search to achieve O(log n) range queries. When processing one thousand sessions, with an average of twenty time-series events per session, computational resource consumption is reduced by approximately three orders of magnitude. Simultaneously, by distinguishing between event dates and message creation timestamps, the problem of time-series queries being sorted based on incorrect times is avoided, resulting in a 16.5 percentage point improvement over application-level time filtering in LongMemEval time-series reasoning problems. Complete coverage of four types of time expressions (absolute, relative, duration, and range) enables the system to handle various time expressions commonly used by users in conversations. Attached Figure Description
[0038] Figure 1 This is a schematic diagram of the five-dimensional label generation process of the method of the present invention;
[0039] Figure 2 A schematic diagram of four types of edge relationships constructed for a cross-association graph;
[0040] Figure 3 This is a schematic diagram illustrating the logic and combined filtering process of multidimensional joint retrieval;
[0041] Figure 4 A schematic diagram illustrating the node and edge deduplication process for cross-session graph aggregation;
[0042] Figure 5 A diagram illustrating the weighted calculation of the four factors for the importance dimension;
[0043] Figure 6 This is a schematic diagram of the overall architecture of a five-dimensional cross-linked memory network;
[0044] Figure 7 A schematic diagram illustrating the extraction and normalization process for four types of time expressions;
[0045] Figure 8 This is a schematic diagram of a binary search range query for the time axis index in the architecture layer. Detailed Implementation
[0046] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. (See attached drawings for reference.) Figure 6The overall architecture of the five-dimensional cross-association memory network of this invention is shown in the figure: This architecture includes one main link and two input branches. The main link, from left to right, consists of: five-dimensional label generation; construction of a cross-association graph of the memory network by building four types of cross-association edges between memory nodes based on the five-dimensional labels; multi-dimensional joint retrieval of multi-dimensional logic and combined filtering on the memory network according to the query; and returning the results to the user. The specific implementations of five-dimensional label generation, cross-association graph construction, and multi-dimensional joint retrieval are detailed in Example 1. Figure 1 Example 2 Figure 2 Example 3 Figure 3 The first input branch is cross-session aggregation: Multiple session memory subgraphs are deduplicated based on node unique identifiers and edge triples, and aggregated into an organization-level unified graph. This unified graph serves as the retrieval object for multi-dimensional joint retrieval, supporting cross-session graph traversal (see Example 4 for details). Figure 4 The second input branch is the time axis index: an ordered time axis index is pre-built during memory writing and a binary search is used to support range queries. The output session identifier set is passed to the five-dimensional memory network as a time dimension filter input (see Examples 7 and 8 for details). Figure 7 , Figure 8 ). Figure 6 The "all rule-based statistical methods, zero LLM, zero GPU" mentioned in the text means that the processing of five-dimensional label generation, cross-association graph construction, cross-session aggregation, and timeline indexing is all based on rule-based statistical methods, which do not rely on pre-trained language models or graphics processors and can be executed in real time without GPU acceleration.
[0047] Example 1: Five-dimensional label generation
[0048] refer to Figure 1 This embodiment details the process of generating five-dimensional labels.
[0049] For a memory entry, the content is "I spent 1200 yuan to buy an A7M4 camera at the Sony flagship store last Wednesday", the creation time is March 22, 2023, the role is user, and the current time is March 29, 2023.
[0050] Time dimension label: The difference between the creation time and the current time is seven days, which is on the seven-day boundary and is mapped to short (short bucket).
[0051] Theme Dimension Tags: In the statistics of Chinese two-character phrases, "Sony" and "camera" are high-frequency words, so "Sony" is selected as the theme tag.
[0052] Entity dimension label: CJK n-gram sliding window extracts the entity list as ["Sony", "Sony flagship", "flagship store", "A7M4", "camera"], and retains ["Sony", "A7M4", "camera"] after deduplication and order preservation.
[0053] refer to Figure 5 Importance dimension tags: Content length factor: The number of characters in the content is about thirty, min(30 / preset length threshold, 1.0) = 0.06 (the preset length threshold is five hundred), score = 0.35 × 0.06 = 0.021. Message Role Factor: Role is user, Score = 0.15 × 0.15 = 0.0225. Entity density factor: With three entities, min(3 / 5, 1.0) = 0.6, score = 0.30 × 0.6 = 0.18. Timeliness factor: The number of days since creation is seven, 0.5^(7 / 7) = 0.5, score = 0.20 × 0.5 = 0.10. Importance score = 0.021 + 0.0225 + 0.18 + 0.10 = 0.3235.
[0054] Source dimension tag: role is user, mapped to "user".
[0055] It should be noted that the generation of the above five-dimensional labels all adopts a rule-based statistical method and does not rely on a pre-trained language model or graphics processor. In subsequent embodiments, the memory entry vectors (such as vectors VA, VB, VC) used for semantically similar edges are pre-generated by an independent embedding model and stored in the memory entries before being written to the memory. The generation process of these vectors is not part of the five-dimensional label generation steps of this invention and does not affect the rule-based implementation of the five-dimensional labels.
[0056] Example 2: Construction of Cross-Relationship Graph
[0057] refer to Figure 2 This embodiment illustrates the construction process of four types of edges.
[0058] There are three memory nodes in the same session: Node A: Content "I am working on Project Alpha", creation time 10:00, entity ["Project Alpha"], vector VA. Node B: Content "Project Alpha encountered technical difficulties", creation time 10:05, entity ["Project Alpha", "Technical difficulties"], vector VB. Node C: Content "Bought a new computer today", creation time 10:30, entity ["computer"], vector VC.
[0059] Temporal adjacent edges: The window size is eight, AB is adjacent, BC is adjacent, and AC is within the window. Establish temporal edges (A,B,weight=1.0), (B,C,weight=1.0), and (A,C,weight=1.0).
[0060] Entity-shared edge: A and B share the entity "Project Alpha" with a sharing count of 1, min(1,2)=1, and weight=1 / 1=1.0. A and C do not share any entities. B and C do not share any entities. Establish an entity-shared edge (A,B,weight=1.0).
[0061] Semantic similarity edges: Assume cosine(VA,VB)=0.85 (greater than the threshold of 0.82), cosine(VA,VC)=0.50 (less than the threshold), and cosine(VB,VC)=0.60 (less than the threshold). Construct semantic similarity edges (A,B,weight=0.85).
[0062] Time proximity edges: AB time difference 300 seconds (less than 3600 seconds), weight = 1 - 300 / 3600 = 0.917. BC time difference 1500 seconds, weight = 1 - 1500 / 3600 = 0.583. AC time difference 1800 seconds, weight = 1 - 1800 / 3600 = 0.500. Establish time proximity edges (A, B, weight = 0.917), (B, C, weight = 0.583), and (A, C, weight = 0.500).
[0063] There are four types of edges between nodes A and B, forming a five-dimensional cross association.
[0064] Example 3: Multidimensional Joint Search
[0065] refer to Figure 3 This embodiment illustrates the filtering process of multidimensional joint retrieval.
[0066] Query request: "Important projects mentioned by users last week", with three filtering criteria: entity="project", time="short" (within seven days), source="user", and importance ≥ 0.5.
[0067] Search process:
[0068] Step 1: Traverse all memory nodes.
[0069] Step 2: Check node A's entity dimension—"Project" is in A's entity label ["Project Alpha"], pass. Check the time dimension—A's time bucket is "short", pass. Check the source dimension—A's source is "user", pass. Check the importance dimension—A's importance score is assumed to be 0.65 (greater than 0.5), pass. Add node A to the candidate set.
[0070] Step 3: Check the entity dimension of node B—"Project" is in B's entity tags ["Project Alpha", "Technical Challenge"], so it passes. Check the source dimension—B's source is "assistant" (not user), so it fails. Node B is filtered.
[0071] Step 4: Check the entity dimension of node C – “Project” is not in the entity label [“Computer”] of C, so it fails. Node C is filtered.
[0072] Step 5: The candidate set is {A}, sorted in descending order of importance score, and node A is returned.
[0073] Example 4: Cross-session graph aggregation
[0074] refer to Figure 4 This embodiment illustrates the deduplication process for cross-session graph aggregation.
[0075] There is a subgraph with three sessions:
[0076] Session S1 subgraph: node {id=1, importance=0.7}, node {id=2, importance=0.5}, edge (1,2,sequential).
[0077] Session S2 subgraph: node {id=1, importance=0.8}, node {id=3, importance=0.6}, edge (1,3,entity_overlap).
[0078] Session S3 subgraph: node {id=2, importance=0.5}, node {id=4, importance=0.9}, edge (2,4,semantic).
[0079] Aggregation steps:
[0080] Node deduplication: id=1 appears in both S1 and S2, so the node with higher importance in S2 is retained (0.8). id=2 appears in both S1 and S3, with the same importance (0.5), so the node in S1 that appears first is retained. id=3 and id=4 each appear once, so they are added directly.
[0081] The aggregated node set is: {id=1(0.8), id=2(0.5), id=3(0.6), id=4(0.9)}.
[0082] Edge deduplication: Edge (1,2,sequential) appears only in S1, so add it. Edge (1,3,entity_overlap) appears only in S2, so add it. Edge (2,4,semantic) appears only in S3, so add it.
[0083] After aggregation, the edge set is: {(1,2,sequential), (1,3,entity_overlap), (2,4,semantic)}.
[0084] The aggregation result is a unified organizational-level memory graph containing four nodes and three edges, supporting graph traversal queries across sessions.
[0085] Example 5: Cross-session entity tracking
[0086] This example demonstrates an application scenario for cross-session entity tracking.
[0087] Session S1 (Day 1): "I'm working on the Alpha project, just started it."
[0088] Conversation S2 (Day 3): "Project Alpha has encountered a technical problem and is currently troubleshooting."
[0089] Conversation S3 (Day 7): "The project Alpha has finally gone live, and the results are great."
[0090] After constructing subgraphs for each session, cross-session aggregation is performed: nodes S1-A, S2-A, and S3-A all contain the entity "Project Alpha" and are interconnected through entity-shared edges. By traversing the graph, one can start from S1-A and reach S2-A and S3-A along the entity-shared edges, tracing the complete timeline of Project Alpha from its initiation to its launch.
[0091] The time dimension labels are: S1-A="long" (assuming the current time is more than 30 days from the first day), S2-A="medium", and S3-A="medium". The importance score automatically decays based on the timeliness factor of each node, but searchability is maintained through the connection relationship of shared edges between entities.
[0092] Example 6: Performance Data
[0093] This example provides performance comparison data for 500 LongMemEval questions:
[0094] Single-dimensional RAG baseline (semantic retrieval only): accuracy of 90.6%.
[0095] Two-dimensional retrieval (semantic + time filtering): accuracy rate of 91.2%.
[0096] Five-dimensional cross-associative memory network: 99.2% accuracy (496 out of 500 questions answered correctly).
[0097] Tag generation performance: The average latency for generating five-dimensional tags is 0.8 milliseconds per tag (pure function implementation, zero GPU), which is about two orders of magnitude lower than the 50 to 100 milliseconds per tag of the named entity recognition model.
[0098] Cross-session aggregation scale: In actual testing, it supports aggregation of more than 1,000 sessions, and the response time for graph traversal query after aggregation is less than 50 milliseconds.
[0099] Importance discrimination: The recall accuracy of high importance (≥0.7) memories is 95.3%, and the recall accuracy of low importance (<0.3) memories is 78.1%, with significant discrimination.
[0100] Time-series query performance: The average query latency of the architecture-layer timeline index is 0.3 milliseconds (binary search), which is about two orders of magnitude lower than the 20 to 50 milliseconds of the application-layer linear scan. The accuracy of time-series reasoning questions has improved from 78.5% of the application-layer time filtering to 95.0% of the architecture-layer timeline, an improvement of 16.5 percentage points.
[0101] Example 7: Extraction and Normalization of Four Types of Time Expressions
[0102] refer to Figure 7 This embodiment details the extraction and normalization process of fine-grained time expressions in the time dimension label.
[0103] For a memory entry, the content is "Last Wednesday I spent 1200 yuan to buy an A7M4 camera at the Sony flagship store and returned it within three days", the creation time is March 22, 2023 (Wednesday) and the current time is March 29, 2023.
[0104] Step S1-1: Extracting the absolute time expression. The year-month-day format is matched using regular expressions. In this example, there is no explicit date, but "1200" is recognized as an amount rather than a date, thus avoiding false matches.
[0105] Step S1-2: Relative Time Expression Extraction. Identify "last Wednesday" as a relative time term. Calculation process: The anchor date is March 22, 2023 (Wednesday). "Last Wednesday" represents the Wednesday seven days prior to the anchor date, i.e., March 15, 2023. Normalize to ISO-8601 format: 2023-03-15.
[0106] Step S1-3: Duration Expression Extraction. Identify "within three days" as a duration expression, and match combinations of the "within..." pattern with "three days". Normalize to ISO-8601 duration format: P3D.
[0107] Step S1-4: Extracting the time range expression. There is no time range expression in this example. If the content is "I learned Python from March to May", then the "from X to Y" pattern is identified, and recursively broken down into a start time of 2023-03-01 and an end time of 2023-05-31.
[0108] Steps S1-5: Extracting Time-Series Events. The text content is segmented by sentence. The first sentence, "Last Wednesday I spent 1200 yuan to buy an A7M4 camera at the Sony flagship store," contains both the event verb "buy" and the normalized time expression "last Wednesday" (normalized to 2023-03-15), and is extracted as a time-series event. The event date is 2023-03-15, distinct from the message creation timestamp 2023-03-22. The second sentence, "Returned it within three days," contains the event verb "returned" and the duration expression "within three days," and is extracted as a time-series event. The event date is 2023-03-15 plus three days, which is 2023-03-18.
[0109] Each time expression carries a type marker (absolute / relative / duration / range), the original text, a character offset, and a confidence score. Absolute time expressions have a confidence score of 0.95, relative time expressions have a confidence score of 0.85, duration expressions have a confidence score of 0.80, and time range expressions have a confidence score of 0.75.
[0110] Example 8: Architecture Layer Timeline Index and Binary Search Query
[0111] refer to Figure 8 This embodiment details the construction of the architecture layer time axis index and the binary search range query process.
[0112] Step S1: Timeline Index Construction. During memory writes (not queries), all time-series events are sorted by event date to construct an ordered array index. Consider the following time-series events: Event E1: Visiting the National Museum, Event Date: 2023-01-15, Session S1 Event E2: Purchase of a Sony camera, Event date: 2023-03-15, Session S2 Event E3: Return of Sony camera, Event date 2023-03-18, Session S2 Event E4: Attending a technical conference, event date 2023-05-10, session S3 Event E5: New product launch, event date 2023-07-20, session S4
[0113] The sorted array is: [E1(01-15), E2(03-15), E3(03-18), E4(05-10), E5(07-20)], and the order of the first occurrence of the session identifiers of the events is recorded: S1, S2, S3, S4.
[0114] Step S2: Time series query parsing. The user queries "events that occurred between March and May", which is parsed as a "between" time series constraint. The start date 2023-03-01 and the end date 2023-05-31 are extracted.
[0115] Step S3: Binary search range lookup. Perform a binary search on the sorted array:
[0116] Step S3-1: Binary search for the starting position. Find the position of the first event date that is greater than or equal to 2023-03-01, the result of which is index 1 (E2, 03-15).
[0117] Step S3-2: Binary search for the end position. Find the position where the last event date is less than or equal to 2023-05-31, the result is index 3 (E4, 05-10).
[0118] Step S3-3: Return all events in the range of index 1 to index 3: E2(03-15), E3(03-18), E4(05-10), with the corresponding session identifier set being {S2, S3}.
[0119] Step S4: Integration with the five-dimensional memory network. The session identifier set {S2, S3} is passed to the five-dimensional memory network as input for time-dimensional filtering. The five-dimensional memory network further performs logical and combined filtering of entity, topic, source, and importance dimensions in the session subgraph of {S2, S3}, returning memory nodes that simultaneously satisfy the conditions of all dimensions.
[0120] Comparative Results: If existing application-layer time filtering schemes (such as CN107153685A) are used, the top-k memory entries must first be obtained through semantic retrieval, and then the time expression of each memory entry must be re-parsed and compared one by one, resulting in a query complexity of O(n). When the system processes one thousand sessions, with an average of twenty time-series events per session, the application-layer scheme needs to parse approximately twenty thousand text entries per query. The pre-built index at the architecture layer of this invention requires only one binary search, reducing computational resource consumption by approximately three orders of magnitude.
[0121] The effect of separating the event date from the message timestamp: In the example above, the purchase date of event E2 is March 15, 2023, but the user may mention this in a session on March 22, 2023. If the event date and message timestamp are not distinguished, the system will sort the time series based on March 22, 2023, causing the event to be incorrectly placed in late March instead of mid-March. This invention ensures that the time series query results are based on the actual time the event occurred by extracting the event date (March 15, 2023) and distinguishing it from the message timestamp (March 22, 2023).
Claims
1. A method for constructing and traversing a memory network based on five-dimensional cross-associations, characterized in that, The method includes the following steps: S1: Generate a five-dimensional label for each memory entry in the memory storage, wherein the five-dimensional label includes: (1) Time dimension label: Based on the time difference between the creation time of the memory entry and the current time, it is mapped into five time buckets: recent, short-term, medium-term, long-term and archived according to the non-linear bucketing rule. The time boundaries of the non-linear buckets are 24 hours, 7 days, 30 days and 180 days respectively. When the time difference is less than or equal to the corresponding time boundary value, it is assigned to the time bucket corresponding to the time boundary value. (2) Topic dimension tags: By performing Chinese double-character group statistics and English word frequency statistics on the content text of memory entries, the most frequent topic words are extracted as topic tags; (3) Entity dimension labels: entity list is extracted from content text as entity labels by CJK character multi-granularity n-gram sliding window scanning and English proper name recognition; (4) Importance dimension label: The importance score is output in the range of zero to one by weighted calculation of content length factor, message role factor, entity density factor and timeliness factor, wherein the timeliness factor is calculated by an exponential decay function with a half-life of one week. (5) Source dimension tags are mapped to four source types: user, assistant, system and tool, based on the message role of the memory entry; S2: Based on the five-dimensional labels, four types of cross-association edges are constructed between memory nodes in the same session. These four types of edges coexist in the same graph structure, and any two nodes can simultaneously have multiple types of association edges. The four types of edges include: (1) Temporally adjacent edges connect memory nodes that are temporally adjacent within the same session, with a fixed weight. (2) Entity sharing edge, which connects two memory nodes that share at least one entity label, with the weight being the ratio of the number of shared entities to the smaller entity among the two nodes; (3) Semantic similarity edges connect two memory nodes whose vector cosine similarity is greater than a preset threshold, with the weight being the cosine similarity value; (4) Time proximity edge: connects two memory nodes whose creation time difference is less than a preset time threshold, and the weight is negatively correlated with the time difference; S3: Receive a query request containing one or more filtering conditions of different dimensions. Perform a logical AND combination filtering traversal of the five-dimensional labels on the memory network, return the memory nodes that satisfy all filtering conditions, and return them in descending order of importance score.
2. The method according to claim 1, characterized in that, In the calculation of the importance dimension label, the weights of the four factors are as follows: content length factor weight 0.35, message role factor weight 0.15, entity density factor weight 0.30, and timeliness factor weight 0.
20. Among the message role factors, user messages have a higher weight than assistant messages.
3. The method according to claim 1, characterized in that, The entity dimension label uses a CJK character multi-granularity n-gram sliding window with three granularities: two-gram, three-gram, and four-gram. It filters out deactivated fragments and retains a maximum of twelve entities to prevent dimension expansion.
4. The method according to claim 1, characterized in that, The preset threshold for semantically similar edges is 0.82, the time threshold for time-proximity edges is 3,600 seconds, and the weight calculation formula for time-proximity edges is: weight equals one minus the ratio of time difference to time threshold.
5. The method according to claim 1, characterized in that, It also includes a cross-session graph aggregation step: aggregating memory subgraphs of multiple sessions into an organization-level unified graph, where nodes are deduplicated by unique identifiers, and when nodes with the same identifier appear in multiple subgraphs, nodes with higher importance scores are retained; edges are deduplicated by a triplet of source node identifier, target node identifier, and edge type.
6. The method according to claim 1, characterized in that, The generation of the five-dimensional labels does not rely on pre-trained language models or graphics processors, but is implemented entirely using rule-based statistical methods, including: time dimension using time difference comparison and bucket mapping; topic dimension using bi-character group statistics and word frequency ranking; entity dimension using regular expression sliding window matching; importance dimension using four-factor weighted arithmetic operations; and source dimension using role field mapping.
7. The method according to claim 1, characterized in that, The construction of the temporal adjacent edges adopts a sliding window mechanism with a default window size of eight. That is, for each memory node, the edge relationship is only calculated with the next eight nodes in the time series to control the computational complexity of graph construction.
8. The method according to claim 1, characterized in that, The generation of the time dimension label also includes identifying and normalizing four types of time expressions from the content text of the memory entry through regular expression pattern matching: absolute time expressions, matching the date pattern in year-month-day format and normalizing it to ISO-8601 date format; The relative time expression matches relative time words based on the anchor date, including Chinese and English keywords such as "yesterday", "today", "tomorrow", combinations of "last / next / this" with days of the week, and the pattern "N time units before" or "N time units ago", calculating a normalized date based on the anchor date; the duration expression matches combinations of "for / within / over / during / in" with "N days / weeks / months / years", normalized to the ISO-8601 duration format; the time range expression matches the patterns of "from X to Y" and "between X and Y", recursively decomposed into start and end times.
9. The method according to claim 8, characterized in that, The conversation text is segmented by sentence. Each sentence containing both an event verb and a normalizable time expression is extracted as a time-series event. The time-series event includes the event text, the event date, the conversation identifier, and a list of time expressions. The event date is the normalizable date with the highest built-in confidence in the sentence. The event date is distinct from the message creation timestamp. The event verb includes at least one of the following: "visit", "attend", "meet", "travel", "release", "buy", "start", "finish", "go", "join", "create", "launch", "submit", "register", "book", "cancel", "update", "change", "move", "arrive", "depart", "open", and "close".
10. The method according to claim 9, characterized in that, The time-series events are sorted by event date and used as an architectural layer component to pre-build an ordered timeline index during memory writing. The index uses a binary search algorithm to implement range queries with O(logn) time complexity. During the retrieval phase, natural language queries containing time-series constraints are received. The time-series constraints include at least one of the following: before a certain date, after a certain date, between two dates, within N days before and after the event date of the time-series event matching the query keywords, last occurrence, and first occurrence. A binary search range query is performed on the ordered timeline index to obtain a set of session identifiers that satisfy the time-series constraints as input for time dimension filtering.
11. A memory network construction and traversal retrieval device based on a five-dimensional cross-association of entity-time-topic-source-importance, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 10.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Cognition method and device based on timeline memory in man-machine conversation system
CN107153685A
A memory optimization system for large language models
CN121328718B
