A method and system for context memory management in adaptive multi-turn dialogue interaction

By adopting an adaptive multi-turn dialogue interaction context memory management method, and using a vector database and time decay factor to dynamically update context records, the problems of inaccurate intent parsing and insufficient context memory are solved, thereby improving the user interaction experience.

CN122132437APending Publication Date: 2026-06-02SHENZHEN SDMC TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN SDMC TECH CO LTD
Filing Date
2026-02-03
Publication Date
2026-06-02

Smart Images

  • Figure CN122132437A_ABST
    Figure CN122132437A_ABST
Patent Text Reader

Abstract

This application relates to a context memory management method and system for adaptive multi-turn dialogue interaction. The method includes: querying a vector database for several historical intent vectors with the highest semantic similarity to the intent vector of the current user input, and returning a candidate vector ID list composed of candidate vector IDs of each historical intent vector; obtaining the context ID corresponding to each candidate vector ID in the candidate vector ID list, and obtaining the context record corresponding to the candidate vector ID based on the context ID; calculating the time decay factor of each context record based on the timestamp; calculating the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record; determining whether the highest weight exceeds a set threshold, if so, using the user input as a continuation of the corresponding context record and updating the corresponding context record; otherwise, using the user input as a new context record and saving the new context record.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of context memory management technology, and in particular to a context memory management method and system for adaptive multi-turn dialogue interaction. Background Technology

[0002] With the development of artificial intelligence technology, natural language understanding and multi-turn dialogue systems are gradually being widely applied in scenarios such as smart speakers, intelligent customer service, and in-vehicle voice interaction. However, existing technologies have the following problems in practical applications: 1. Inaccurate intent parsing: Current natural language understanding models are prone to ambiguity parsing errors when faced with conversational and complex natural language inputs, resulting in system responses that do not meet the user's actual needs.

[0003] 2. Insufficient context memory management: In multi-turn dialogues, the system often has a rigid memory of historical dialogue information and cannot dynamically adjust according to the user's real-time context, which can easily lead to context breaks and affect the continuous interactive experience.

[0004] 3. Lack of targeted proactive services and recommendations: Existing proactive push or service recommendations are mostly static or based on single-dimensional information, lacking scene awareness and personalization capabilities, often failing to match users' real-time needs, thus reducing user experience and the level of device intelligence. Summary of the Invention

[0005] Based on this, an adaptive multi-turn dialogue interaction context memory management scheme is provided to solve the problems of accurate intent parsing, inflexible context memory management, and lack of targeted proactive services in the existing technology, thereby comprehensively improving the user interaction experience.

[0006] Firstly, an adaptive multi-turn dialogue interaction context memory management method is provided, including: S1: Vectorize the acquired user input to obtain the current intent vector; S2: Query the vector database to find the historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector. S3: Obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains a corresponding timestamp; S4: Calculate the time decay factor of each context record based on the timestamp; calculate the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record; S5: Determine whether the highest weight exceeds the set threshold. If so, treat the user input as a continuation of the corresponding context record and update the corresponding context record; otherwise, treat the user input as a new context record and save the new context record.

[0007] Preferably, the step of vectorizing the acquired user input to obtain the current intent vector includes: The acquired user input is processed by a semantic encoder to obtain the current intent vector.

[0008] Preferably, the vector database includes: Several historical intent vectors, candidate vector IDs corresponding to each historical intent vector, and context IDs corresponding to each candidate vector ID.

[0009] Preferably, obtaining the context record corresponding to the candidate vector ID based on the context ID includes: Retrieve the context record corresponding to the candidate vector ID from the context data table based on the context ID; The context data table includes the context ID, weight, context content, timestamp, and candidate vector ID corresponding to each context record.

[0010] Preferably, the weights of context records are calculated based on the semantic similarity and time decay factor corresponding to the context records, including: Get the dialogue rounds list of the current session and each historical session, and calculate the user feedback signal based on the number of dialogue rounds in the current session, the minimum number of dialogue rounds in each historical session, and the maximum number of dialogue rounds in each historical session. The weight of the context record is calculated by weighting and summing the semantic similarity, time decay factor and user feedback signal corresponding to the context record.

[0011] Preferably, the formula for calculating the weight of the context record is: ; ; in, Indicates the weight of the context record. This represents the similarity weight coefficient. Represents cosine similarity. This represents the current intent vector. Represents the historical intent vector. This represents the time decay weighting coefficient. This represents the difference between the current timestamp and the timestamp of the most recent update of the context record. Indicates the time decay factor. This represents the weighting coefficient of user feedback. This indicates user feedback signals. This indicates the number of rounds in the current conversation. This represents the minimum number of rounds required for dialogue across all historical sessions, after removing the minimum value. This indicates the maximum number of dialogue rounds in each historical session, with the maximum value removed.

[0012] Preferably, updating the context record includes: In the context data table, update the weight of the context record using the following formula: ; in, This indicates the updated weight of the context record. This indicates the weight of the earlier record in the context. This represents the learning rate parameter; The update timestamp is recorded in the corresponding context record; The user input is used as a continuation of the corresponding context record. The context content with newly added content is vectorized to obtain an updated context content vector. The corresponding historical intent vector in the vector database is replaced based on the updated context content vector.

[0013] Preferably, the user input is recorded as a new context record, and the new context record is saved, including: The current intent vector is stored in the vector database, and a corresponding candidate vector ID is generated; In the context data table, a new context record is generated for the user input. The context content in the new context record is the user input and its response text. The context ID in the new context record is associated with the candidate vector ID of the current intent vector.

[0014] Preferably, the method further includes periodically calculating the memory decay factor of each context record based on the time decay factor and weight of each context record in the context data table, using the following formula: ; in, This represents the memory decay factor of the i-th context record. This represents the weight of the i-th context record. Indicates the attenuation coefficient. This represents the difference between the current timestamp and the most recently updated timestamp of the i-th context record; When the memory decay factor of a context record is less than a second preset threshold, the corresponding context record is deleted from the context data table and added to the history database.

[0015] On the other hand, a context memory management system for implementing the above-described method is provided, comprising: The encoding module is used to vectorize the acquired user input to obtain the current intent vector; The retrieval module is used to query the vector database for several historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector. The context record extraction module is used to obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and to obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains a corresponding timestamp. The weight calculation module is used to calculate the time decay factor of each context record based on the timestamp; and to calculate the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record. The context record update module is used to determine whether the highest weight exceeds a set threshold. If so, the user input is used as a continuation of the corresponding context record, and the corresponding context record is updated; otherwise, the user input is used as a new context record, and the new context record is saved.

[0016] Beneficial effects: This method queries a vector database to find several historical intent vectors with the highest semantic similarity to the current user input intent vector, and returns a candidate vector ID list composed of candidate vector IDs of each historical intent vector; obtains the context ID corresponding to each candidate vector ID in the candidate vector ID list, and obtains the context record corresponding to the candidate vector ID based on the context ID; calculates the time decay factor of each context record based on the timestamp; calculates the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record; determines whether the highest weight exceeds a set threshold, if so, the user input is used as a continuation of the corresponding context record and the corresponding context record is updated; otherwise, the user input is used as a new context record and the new context record is saved. This solves the problems of inaccurate intent parsing, inflexible context memory management, and lack of targeted proactive services in existing technologies, and achieves flexible context memory management, comprehensively improving the user interaction experience. Attached Figure Description

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

[0018] Figure 1 This is a flowchart of the context memory management method for adaptive multi-turn dialogue interaction in the embodiments of this application. Detailed Implementation

[0019] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the specific embodiments of this application are described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.

[0020] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0021] like Figure 1 As shown, this embodiment provides a context memory management method for adaptive multi-turn dialogue interaction, including: S1: Vectorize the acquired user input to obtain the current intent vector.

[0022] Optionally, the step of vectorizing the acquired user input to obtain the current intent vector includes: The acquired user input is processed by a semantic encoder to obtain the current intent vector.

[0023] S2: Query the vector database to find the historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector.

[0024] Optionally, the vector database includes: Several historical intent vectors, candidate vector IDs corresponding to each historical intent vector, and context IDs corresponding to each candidate vector ID.

[0025] Optional, an example of a vector database is: {"vector_id": "vec_987654321", "vector": [0.123, 0.532, -0.221, ...], "context_id": "session123_round5"}.

[0026] Where vector_id represents the candidate vector ID, context_id represents the context ID, and vector represents the historical intent vector.

[0027] S3: Obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains the corresponding timestamp.

[0028] Specifically, obtaining the context record corresponding to the candidate vector ID based on the context ID includes: Retrieve the context record corresponding to the candidate vector ID from the context data table based on the context ID; The context data table includes the context ID, weight, context content, timestamp, and candidate vector ID corresponding to each context record.

[0029] Optionally, the context data can be represented as follows: {"context_id": "session123_round5", …, "W": 0.85, "timestamp": "2025-08-28T19:30:12", "vector_id": "vec_987654321"}.

[0030] Where context_id represents the context ID, W represents the weight, timestamp represents the timestamp, and vector_id represents the candidate vector ID.

[0031] By using the context ID and candidate vector ID, a bidirectional association is established between the context data table and the vector database, i.e.: Context data table → vector_id → vector database; Vector database → context_id → context data table.

[0032] S4: Calculate the time decay factor of each context record based on the timestamp; calculate the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record.

[0033] A dynamic weighting mechanism is introduced to flexibly select whether to retain or update contextual information based on dialogue turn, contextual relevance, and real-time interaction needs, achieving seamless connection of continuous contexts. Weights are assigned to each context record based on factors including semantic similarity, time decay factor, and user feedback signals.

[0034] Specifically, based on the semantic similarity and time decay factor corresponding to the context records, the weights of the context records are calculated, including: Get the dialogue rounds list of the current session and each historical session, and calculate the user feedback signal based on the number of dialogue rounds in the current session, the minimum number of dialogue rounds in each historical session, and the maximum number of dialogue rounds in each historical session. The weight of the context record is calculated by weighting and summing the semantic similarity, time decay factor and user feedback signal corresponding to the context record.

[0035] Optionally, the user feedback signal can also be a simple feedback signal, such as 1 for feedback and 0 for no feedback.

[0036] Furthermore, the formula for calculating the weight of the context record is: ; ; in, Indicates the weight of the context record. This represents the similarity weight coefficient, which is used to adjust the importance of the similarity between the current intent vector and the historical intent vector in the total weight; Represents cosine similarity. This represents the current intent vector. Represents the historical intent vector. This represents the time decay weighting coefficient, used to adjust the importance of the time factor in the total weight; This represents the difference between the current timestamp and the timestamp of the most recent update of the context record. Indicates the time decay factor. This represents the user feedback weighting coefficient, used to adjust the importance of user feedback in the overall weighting. This indicates user feedback signals. This indicates the number of rounds in the current conversation. This represents the minimum number of rounds required for dialogue across all historical sessions, after removing the minimum value. This indicates the maximum number of dialogue rounds in each historical session, with the maximum value removed.

[0037] Semantic similarity, its function is to determine the relevance of the context to the prompt words, so that the system can find and return meaningful context, rather than just relying on keyword matching. By calculating the cosine similarity through semantic vectors, the distance between two rounds of dialogue in the "semantic space" can be obtained, making context matching more accurate, reducing the overhead of redundant matching, and improving the retrieval hit rate.

[0038] The time decay factor determines the timeliness of context, automatically reducing the weight of historical contexts in the system over time. In multi-turn or long conversations, contexts stored for longer periods are generally less relevant. Using the time decay factor to match and filter contexts can improve real-time response and context matching accuracy, while reducing interference from invalid context.

[0039] User feedback signals serve to: determine the credibility of the context, allow the system to learn and remember from user behavior, dynamically change the context weights according to user behavior, dynamically strengthen valuable contexts and weaken invalid contexts, improve the accuracy of context matching, accurately continue intent, and enhance personalization.

[0040] S5: Determine whether the highest weight exceeds the set threshold. If so, treat the user input as a continuation of the corresponding context record and update the corresponding context record; otherwise, treat the user input as a new context record and save the new context record.

[0041] Specifically, updating the context record includes: In the context data table, update the weight of the context record using the following formula: ; in, This indicates the updated weight of the context record. This indicates the weight of the earlier record in the context. This represents the learning rate parameter, which controls the sensitivity of the dialogue to new input. Record the update timestamp in the corresponding context record; and update the round record in the dialogue round list. The user input is used as a continuation of the corresponding context record. The context content with newly added content is vectorized to obtain an updated context content vector. The corresponding historical intent vector in the vector database is replaced based on the updated context content vector.

[0042] Optionally, the updated context content vector can be directly stored in the vector database, and the generated candidate vector ID can be associated with the candidate vector ID of the corresponding historical intent vector.

[0043] Furthermore, the user input is recorded as a new context record, and the new context record is saved, including: The current intent vector is stored in the vector database, and a corresponding candidate vector ID is generated; In the context data table, a new context record is generated for the user input. The context content in the new context record is the user input and its response text. The context ID in the new context record is associated with the candidate vector ID of the current intent vector. Update the turn record in the dialogue turn list;

[0044] This embodiment also includes step S6: Based on the time decay factor and weight of each context record in the context data table, the memory decay factor of each context record is periodically calculated, and the calculation formula is as follows: ; in, The memory decay factor of the i-th context record is used to reflect the retention value of the i-th context record in the current dialogue. This represents the weight of the i-th context record. This represents the decay coefficient, used to reflect the rate at which historical records decay over time; the larger the value, the faster the decay. This represents the difference between the current timestamp and the most recently updated timestamp of the i-th context record; When the memory decay factor of a context record is less than a second preset threshold, the corresponding context record is deleted from the context data table and added to the history database.

[0045] Through an elimination mechanism, dynamic memory elimination is achieved, and the system can determine the appropriate elimination method based on the system's performance. The value dynamically determines whether to evict old context records, rather than cleaning them up at fixed intervals.

[0046] This embodiment provides a list of dialogue rounds for a single session, as shown in the following example: {"turn_id": "int type data, the current dialogue turn number, for example, 1, 2, 3...", "context_id": "String type data, session ID, used to distinguish different conversations". "user_id": "String type data, a unique identifier for the user". "role": "string type data, role (user / assistant / system)" "input_text": "String type data, the user's original input text", "intent_vector": "array[float] type data, the current input intent vector (embedding)", "parsed_intent": "String type data, the intent label after NLU parsing, such as (query the weather)". "response_text": "String type data, the answer generated or retrieved by the model", …, "feedback_signal": "Int type data, user feedback (1=positive, 0=neutral, -1=negative)", "is_contextual": "boolean type data, indicating whether it is considered a continuation of the context."

[0047] This embodiment also provides a context memory management system for implementing the above-described adaptive multi-turn dialogue interaction, including: The encoding module is used to vectorize the acquired user input to obtain the current intent vector; The retrieval module is used to query the vector database for several historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector. The context record extraction module is used to obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and to obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains a corresponding timestamp. The weight calculation module is used to calculate the time decay factor of each context record based on the timestamp; and to calculate the weight of each context record based on the semantic similarity and time decay factor corresponding to the context record. The context record update module is used to determine whether the highest weight exceeds a set threshold. If so, the user input is used as a continuation of the corresponding context record, and the corresponding context record is updated; otherwise, the user input is used as a new context record, and the new context record is saved. The elimination module is used to periodically calculate the memory decay factor of each context record based on the time decay factor and weight of each context record in the context data table. When the memory decay factor of a context record is less than a second preset threshold, the corresponding context record is deleted from the context data table and added to the historical record library.

[0048] The adaptive multi-turn dialogue interaction context memory management method and system provided in this embodiment have the following beneficial effects: This solution addresses the issues of inaccurate intent parsing, inflexible context memory management, and lack of targeted proactive services in existing technologies by retrieving, updating, and eliminating context records. It achieves flexible context memory management and comprehensively enhances the user interaction experience.

[0049] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0050] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A context memory management method for adaptive multi-turn dialogue interaction, characterized in that, include: S1: Vectorize the acquired user input to obtain the current intent vector; S2: Query the vector database to find the historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector. S3: Obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains a corresponding timestamp; S4: Calculate the time decay factor for each context record based on the timestamp; The weight of each context record is calculated based on the semantic similarity and time decay factor corresponding to the context records. S5: Determine whether the highest weight exceeds the set threshold. If so, treat the user input as a continuation of the corresponding context record and update the corresponding context record; otherwise, treat the user input as a new context record and save the new context record.

2. The method according to claim 1, characterized in that, The process of vectorizing the acquired user input to obtain the current intent vector includes: The acquired user input is processed by a semantic encoder to obtain the current intent vector.

3. The method according to claim 1, characterized in that, The vector database includes: Several historical intent vectors, candidate vector IDs corresponding to each historical intent vector, and context IDs corresponding to each candidate vector ID.

4. The method according to claim 1, characterized in that, The step of obtaining the context record corresponding to the candidate vector ID based on the context ID includes: Retrieve the context record corresponding to the candidate vector ID from the context data table based on the context ID; The context data table includes the context ID, weight, context content, timestamp, and candidate vector ID corresponding to each context record.

5. The method according to claim 1, characterized in that, Based on the semantic similarity and time decay factor corresponding to the context records, the weights of the context records are calculated, including: Get the dialogue rounds list of the current session and each historical session, and calculate the user feedback signal based on the number of dialogue rounds in the current session, the minimum number of dialogue rounds in each historical session, and the maximum number of dialogue rounds in each historical session. The weight of the context record is calculated by weighting and summing the semantic similarity, time decay factor and user feedback signal corresponding to the context record.

6. The method according to claim 5, characterized in that, The formula for calculating the weight of a context record is: ; ; in, Indicates the weight of the context record. This represents the similarity weight coefficient. Represents cosine similarity. This represents the current intent vector. Represents the historical intent vector. This represents the time decay weighting coefficient. This represents the difference between the current timestamp and the timestamp of the most recent update of the context record. Indicates the time decay factor. This represents the weighting coefficient of user feedback. This indicates user feedback signals. This indicates the number of rounds in the current conversation. This represents the minimum number of rounds required for dialogue across all historical sessions, after removing the minimum value. This indicates the maximum number of dialogue rounds in each historical session, with the maximum value removed.

7. The method according to claim 4, characterized in that, Updating context records includes: In the context data table, update the weight of the context record using the following formula: ; in, This indicates the updated weight of the context record. This indicates the weight of the earlier record in the context. This represents the learning rate parameter; The update timestamp is recorded in the corresponding context record; The user input is used as a continuation of the corresponding context record. The context content with newly added content is vectorized to obtain an updated context content vector. The corresponding historical intent vector in the vector database is replaced based on the updated context content vector.

8. The method according to claim 4, characterized in that, The user input is recorded as a new context record, and the new context record is saved, including: The current intent vector is stored in the vector database, and a corresponding candidate vector ID is generated; In the context data table, a new context record is generated for the user input. The context content in the new context record is the user input and its response text. The context ID in the new context record is associated with the candidate vector ID of the current intent vector.

9. The method according to claim 4, characterized in that, It also includes periodically calculating the memory decay factor of each context record based on the time decay factor and weight of each context record in the context data table, using the following formula: ; in, This represents the memory decay factor of the i-th context record. This represents the weight of the i-th context record. Indicates the attenuation coefficient. This represents the difference between the current timestamp and the most recently updated timestamp of the i-th context record; When the memory decay factor of a context record is less than a second preset threshold, the corresponding context record is deleted from the context data table and added to the history database.

10. A context memory management system for implementing adaptive multi-turn dialogue interaction as described in claim 1, characterized in that, include: The encoding module is used to vectorize the acquired user input to obtain the current intent vector; The retrieval module is used to query the vector database for several historical intent vectors with the highest semantic similarity to the current intent vector, and return a list of candidate vector IDs composed of the candidate vector IDs of each historical intent vector. The context record extraction module is used to obtain the context ID corresponding to each candidate vector ID in the candidate vector ID list, and to obtain the context record corresponding to the candidate vector ID based on the context ID; each context record contains a corresponding timestamp. The weight calculation module is used to calculate the time decay factor of each context record based on the timestamp; The weight of each context record is calculated based on the semantic similarity and time decay factor corresponding to the context records. The context record update module is used to determine whether the highest weight exceeds the set threshold. If so, the user input is used as a continuation of the corresponding context record, and the corresponding context record is updated. Otherwise, the user input is recorded as a new context record, and the new context record is saved.