A method and system for cross-session text robot interaction based on unified memory bank
Patent Information
- Application Number
- CN202610146368.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-02
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2046-02-02
AI Technical Summary
这种设计不仅造成交互效率低下,影响用户体验的连贯性,更使得机器人难以基于对用户的长期了解提供真正个性化的服务,其服务深度和价值上限受到显著限制,难以满足用户对智能化服务日益增长的需求
[0006]通过采用上述技术方案,为每个用户构建一个独立于单次会话、持续演进的向量化统一记忆库,并在对话生成流程中嵌入“记忆检索-上下文增强-主动检测”机制,成功地使文本机器人突破了短期记忆的局限,实现了基于长期历史的深度个性化交互。该技术方案将碎片化的用户信息转化为可计算的结构化知识,利用语义向量检索技术精准激活相关记忆,通过精心设计的提示词工程为大型语言模型提供丰富的决策上下文,从而生成高度贴合用户个体情况的响应;更进一步,通过基于规则和AI推断的双重触发机制,赋予机器人从被动应答到主动关怀的能力。最终,该方案使机器交互具备了类似人类助理的连续性、预见性和深度关怀特性,显著增强了服务粘性与价值,提升了用户体验。
Smart Images

Figure CN122088685B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method and system for cross-conversation text robot interaction based on a unified memory bank. Background Technology
[0002] With the rapid development of artificial intelligence technology, especially the breakthroughs in natural language understanding and generation capabilities of large language models, text robots (chatbots) have been widely used in scenarios such as online customer service, intelligent question answering, and personal assistants. These systems are able to semantically understand user input and generate fluent and relevant single-turn responses based on powerful language models. They perform exceptionally well in handling explicit and independent user inquiries, greatly improving the efficiency of information acquisition and the level of automated services.
[0003] However, because traditional architectures typically limit sessions to a single connection cycle, the interaction context is often cleared once the session ends, leading to information silos between different sessions. When a user initiates interaction again, the system cannot recognize the user's identity or their historical interaction information, making each conversation feel like a first meeting, requiring the user to repeatedly provide personal information, preferences, or historical background. This design not only results in inefficient interaction and affects the consistency of the user experience, but also makes it difficult for the chatbot to provide truly personalized services based on a long-term understanding of the user. Its service depth and value ceiling are significantly limited, making it difficult to meet users' growing demand for intelligent services. Summary of the Invention
[0004] To address the aforementioned technical issues, this application provides a method and system for cross-session text robot interaction based on a unified memory.
[0005] Firstly, this application provides a cross-conversation text robot interaction method based on a unified memory, employing the following technical solution: A method for cross-session text robot interaction based on a unified memory, the method comprising: Receive a dialogue request initiated by a user, parse it to obtain the user identifier and the current query text; Load the corresponding unified memory according to the user identifier; wherein, the unified memory contains at least one structured memory unit, and each memory unit contains memory content represented by a vectorization; The current query text is converted into a query vector, the similarity between the query vector and each memory unit in the unified memory bank is calculated, and the K memory units with the highest similarity are retrieved as the related memory set. The relevant memory set is sorted by time order and relevance to generate structured background text, which is then concatenated with the current query text and the short-term context of the current session to form enhanced prompt words. The enhanced prompt words are input into the language model to generate the initial response text; Based on the user identifier, the relevant memory set, and the system time, detect the active service triggering conditions; If the active service triggering condition is met, an active service text is generated and merged with the initial response text to form the final response text.
[0006] By adopting the above technical solution, a vectorized unified memory bank is constructed for each user, independent of individual conversations and continuously evolving. A "memory retrieval-context enhancement-active detection" mechanism is embedded in the dialogue generation process, successfully enabling text robots to overcome the limitations of short-term memory and achieve deep personalized interaction based on long-term history. This technical solution transforms fragmented user information into computable structured knowledge, accurately activates relevant memories using semantic vector retrieval technology, and provides rich decision-making context for large language models through carefully designed prompt word engineering, thereby generating responses highly tailored to individual user situations. Furthermore, through a dual triggering mechanism based on rules and AI inference, the robot is endowed with the ability to move from passive response to proactive care. Ultimately, this solution endows machine interaction with the continuity, predictability, and deep care characteristics similar to human assistants, significantly enhancing service stickiness and value, and improving user experience.
[0007] Secondly, this application provides a cross-conversation text robot interaction system based on a unified memory, employing the following technical solution: A cross-session text-based robot interaction system based on a unified memory, the system comprising: The request parsing and user identification module is used to receive dialogue requests initiated by users, parse them to obtain user identifiers and current query text; A unified memory loading module is used to load the corresponding unified memory according to the user identifier; wherein, the unified memory contains at least one structured memory unit, and each memory unit contains memory content represented by a vectorization; The memory retrieval module is used to convert the current query text into a query vector, calculate the similarity between the query vector and each memory unit in the unified memory bank, and retrieve the K memory units with the highest similarity as the related memory set. The enhanced prompt word construction module is used to sort the relevant memory set according to time order and relevance, generate structured background text, and concatenate it with the current query text and the short-term context of the current session to form enhanced prompt words; An initial response generation module is used to input the enhanced prompt words into a language model to generate initial response text. The proactive service trigger detection module is used to detect proactive service trigger conditions based on the user identifier, the relevant memory set, and the system time. The final response generation module is used to generate active service text when the active service triggering conditions are met, and merge it with the initial response text to form the final response text.
[0008] Thirdly, this application provides a computer device, which adopts the following technical solution: A computer device includes a memory, a processor, and a computer program stored in the memory, the processor executing the computer program to perform the steps of the method as described in the first aspect.
[0009] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium storing a computer program that can be loaded by a processor and executed as in any of the methods in the first aspect. Attached Figure Description
[0010] Figure 1 This is a first flowchart illustrating a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application.
[0011] Figure 2 This is a second flowchart illustrating a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application.
[0012] Figure 3 This is a schematic diagram of the third process of a cross-conversation text robot interaction method based on a unified memory, which is one embodiment of this application.
[0013] Figure 4 This is a schematic diagram of the fourth process of a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application.
[0014] Figure 5 This is a fifth flowchart of a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application.
[0015] Figure 6 This is a schematic diagram of the sixth process of a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application.
[0016] Figure 7 This is a schematic diagram of the seventh process of a cross-conversation text robot interaction method based on a unified memory, according to one embodiment of this application. Detailed Implementation
[0017] To make the purpose, technical solution, and advantages of this application clearer, the following description is provided in conjunction with the appendix. Figures 1-7 The present application will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the application.
[0018] This application discloses a cross-conversation text robot interaction method based on a unified memory.
[0019] Reference Figure 1 A cross-session text robot interaction method based on a unified memory bank, specifically including: Step S101: Receive the dialogue request initiated by the user, and parse it to obtain the user identifier and the current query text; When a user initiates a request through a client (such as an app or web chat plugin), the system receives not only a piece of natural language text (the current query text), but more importantly, a user identifier bound to this transmission. This identifier (such as a user ID or OpenID) is a unique key assigned by the system during registration or the first interaction. Its core function is to accurately locate the interaction subject and associate the abstract dialogue request with a specific, historically continuous digital individual.
[0020] Furthermore, the parsing process is automatically completed by the backend service. It obtains the user identifier by parsing authentication information (such as a token) or session cookies in the network request message, and simultaneously extracts the clean current query text from the message payload. This step ensures that all subsequent personalized processing accurately applies to the target user's data space, which is the fundamental prerequisite for achieving "cross-session" capabilities. For example, when user "Zhang San" asks a question on a mobile app, his request includes an identifier uniquely pointing to the user "Zhang San" and the text he entered: "Help me check my health insurance policy."
[0021] Step S102: Load the corresponding unified memory according to the user identifier; wherein, the unified memory contains at least one structured memory unit, and each memory unit contains a vectorized representation of memory content; In this process, the system uses the user identifier obtained in the previous step as the primary key to load the user's unique unified memory from persistent storage (such as a vector database). This memory is not a chaotic collection of chat logs, but an organic whole composed of several structured memory units.
[0022] Specifically, each memory unit is an atomized encapsulation of valuable information generated during historical interactions. Its structural design embodies profound logic: the memory content (e.g., "user prefers coffee without sugar") is the semantic core of the information; type tags (e.g., "dietary preferences") facilitate categorized retrieval; timestamps and source session IDs record the spatiotemporal origin of the information, ensuring its traceability; and vectorized representation is the key technology for achieving intelligent retrieval. It maps textual semantics to dense vectors (a set of floating-point numbers) in a high-dimensional space through an embedding model, enabling computers to "understand" semantic relevance by calculating the distance between vectors (e.g., cosine similarity), rather than simply matching keywords. This design elevates fragmented user information into structured knowledge that can be directly processed and reasoned about by machines, laying the foundation for subsequent intelligent retrieval.
[0023] Step S103: Convert the current query text into a query vector, calculate the similarity between the query vector and each memory unit in the unified memory bank, and retrieve the K memory units with the highest similarity as the related memory set; In some embodiments, the steps of constructing a unified memory include: extracting user claims and preference information from historical session logs to generate a first type of memory unit; parsing the document content and extracting structured key-value pair data when a user uploads a document to generate a second type of memory unit; assigning a type label, timestamp, and source session identifier to each memory unit, and generating a vectorized representation through an embedding model.
[0024] The specific steps for retrieving relevant memory sets include: mapping the current query text to a high-dimensional vector using a pre-trained embedding model; calculating the cosine similarity between the high-dimensional vector and the vectors of each memory unit in the unified memory bank; sorting the memory units from high to low according to the cosine similarity value and returning the top K memory units.
[0025] Specifically, an approximate nearest neighbor search is performed in the high-dimensional semantic space to achieve context-aware memory activation. The system uses the same embedding model as when constructing memory units to convert the user's current query text into a query vector. This conversion process numerically represents the semantics of the text. Subsequently, the system calculates the similarity between the query vector and all memory unit vectors in the memory bank using a vector similarity algorithm (such as cosine similarity, which measures the difference in direction between two vectors; the closer the value is to 1, the more similar the semantics). This essentially compares the semantic strength of the association between "what the current user wants to ask" and "what is stored in memory".
[0026] Next, by sorting and selecting the K most similar memory units, the system does not simply retrieve historical chat records, but performs an intelligent filtering of historical knowledge most relevant to the current question, forming a dynamic set of relevant memories for this query. For example, when the user's current query is "recommend nearby restaurants", the system can automatically retrieve stored memory units such as "the user is a vegetarian" and "the user likes Southeast Asian cuisine", rather than irrelevant "the user's shopping records from last month".
[0027] Step S104: Sort the relevant memory set according to time order and relevance, generate structured background text, and concatenate it with the current query text and the short-term context of the current session to form enhanced prompt words; Since the retrieved relevant memory sets are fragmented, they need to be organized into a natural language description that a language model can efficiently understand.
[0028] In the embodiments of this application, sorting operations (such as prioritizing highly relevant information and more recent information) ensure that the most important and up-to-date information is presented first. The process of generating structured background text involves synthesizing discrete memory units into a coherent "user background introduction," which significantly reduces the cognitive load on the language model to understand historical information.
[0029] Subsequently, the background text, the short-term context of the current conversation (recent rounds of dialogue to maintain topic coherence), and the current query text are concatenated according to a preset template (such as [background knowledge], [recent dialogues], [current question]). This concatenation is not a simple superposition, but rather the construction of a hierarchical context system. This allows the language model to simultaneously perceive the user's long-term preferences, short-term dialogue status, and immediate intent when generating a response, thus providing a comprehensive information foundation for generating highly personalized responses.
[0030] Step S105: Input the enhanced prompt words into the language model to generate the initial response text; The underlying logic of this step lies in leveraging the emergent and instruction-following capabilities of large-scale language models within rich contexts. The enhanced prompts, containing comprehensive and relevant user information, are then input into the large-scale language model. Based on its general knowledge gained from training on massive amounts of data and its powerful logical reasoning abilities, the model performs a deep understanding of the enhanced prompts. It no longer answers isolated, context-lacking questions, but rather reasones within a rich context that includes user profiles and historical interactions.
[0031] This technical solution enables the initial response text generated by the model to naturally incorporate personalized elements, such as directly referencing the user's historical information and providing customized suggestions based on their preferences, thereby achieving an interactive effect of "understanding the user." The generation process is end-to-end; the model autonomously decides how to organize the language and which background knowledge to reference, ultimately outputting a fluent, natural, and highly targeted text.
[0032] In some embodiments, the language model instances employed include, but are not limited to, GPT-4, Claude3, or similar large-scale pre-trained language models. Their core function is to generate natural, coherent, and highly personalized initial response text based on enhanced prompts that incorporate long-term memory (structured background text) and short-term context (current conversation records) through understanding and reasoning. For example, in a healthcare assistant scenario, when a user's enhanced prompts integrate their "long-term history of hypertension," "recent low-sodium diet record," and current query about "annual physical examination items," the language model can generate an initial response such as: "Considering your long-term history of hypertension and your recent low-sodium diet control, in addition to the routine items, I specifically recommend that you include homocysteine testing and a more detailed echocardiogram in this year's physical examination for a more comprehensive assessment of cardiovascular risk." This directly and specifically references and applies the user's historical information.
[0033] Step S106: Detect the active service triggering conditions based on the user identifier, relevant memory set, and system time; The logical principle behind this step is an event-driven mechanism based on multi-dimensional context, simulating the predictive care of an intelligent assistant.
[0034] In some embodiments, the detection of proactive service triggering conditions includes: matching condition combinations in a predefined rule base; triggering rule-based proactive service when a specific type of memory unit exists in the relevant memory set and the system time meets a preset time range; and triggering inferential proactive service by analyzing user profile data in the relevant memory set through a lightweight inference model and outputting potential service intent.
[0035] Specifically, the detection process employs two strategies, either in parallel or sequentially: First, it uses predefined rule-based matching, where the rule engine scans relevant memory sets and system time to determine if specific combinations of conditions are met (e.g., IF "user has a monthly end-of-month review need" AND system time is the last day of the month THEN). Second, it uses a lightweight inference model, which analyzes the user profile (such as life status and business progress) contained in relevant memory sets and, combined with the time context, proactively infers the services or care the user might currently need (e.g., "the user's child is about to start school and may need to learn about education insurance"). User identification ensures that the detection is targeted at a specific user. This mechanism breaks through the passive question-and-answer mode of traditional chatbots, making the service proactive.
[0036] Step S107: If the active service triggering condition is met, an active service text is generated and merged with the initial response text to form the final response text.
[0037] The underlying logic of this step is the natural integration and smooth presentation of multi-intent responses. When the proactive service trigger condition is detected, the system generates corresponding proactive service text (such as "By the way, please note that this month's bill has been issued. Would you like to check it now?"). The generation of this text may also rely on LLM or predefined templates.
[0038] The key is that this text isn't sent abruptly as a standalone message, but rather intelligently integrated with the initial response text addressing the user's query. This integration process must ensure fluent language and logical coherence, typically handled by an LLM (Local Management Model). It embeds proactive service content naturally into the reply to the main question (using transition words like "additionally" or "by the way"), forming a complete and unified final response. This not only answers the user's question but also provides extra care, enhancing the completeness and surprise of the user experience.
[0039] In the above implementation, a vectorized unified memory bank, independent of individual sessions and continuously evolving, is constructed for each user. A "memory retrieval-context enhancement-active detection" mechanism is embedded in the dialogue generation process, successfully enabling the text robot to overcome the limitations of short-term memory and achieve deep personalized interaction based on long-term history. This technical solution transforms fragmented user information into computable structured knowledge, accurately activates relevant memories using semantic vector retrieval technology, and provides rich decision-making context for large-scale language models through carefully designed prompt word engineering, thereby generating responses highly tailored to individual user situations. Furthermore, through a dual triggering mechanism based on rules and AI inference, the robot is endowed with the ability to move from passive response to proactive care. Ultimately, this solution enables machine interaction to possess continuity, predictability, and deep care characteristics similar to human assistants, significantly enhancing service stickiness and value, and improving user experience.
[0040] Reference Figure 2 As one implementation of step S101, the steps of receiving a user-initiated dialogue request and parsing to obtain the user identifier and the current query text include: Step S201: Listen for user request data packets coming into the network port and extract the original request message; The system, acting as a network service, continuously listens on one or more specific network ports (e.g., port 80 for HTTP, port 443 for HTTPS, or a custom WebSocket port). When a user initiates interaction through a client (such as an app or webpage), their request is encapsulated into a user request data packet conforming to a specific application layer protocol (such as HTTP) and transmitted over the network to the corresponding port on the server. The listening process (such as server software like Nginx or Netty) captures these data packets but does not directly process the business logic. Instead, it first performs depackaging at the link layer and network layer, reassembling the scattered data packets in order to restore the complete, application-layer-parsable original request message. This step is the infrastructure guarantee for the entire technical solution to respond to external requests; its stability and high performance determine the overall access capability of the system. For example, this mechanism enables the system to handle concurrent requests from web chat plugins and mobile apps simultaneously.
[0041] Step S202: Parse the header fields of the original request message to obtain the session-independent user unique identifier; This system accurately and reliably identifies users from communication protocol metadata, breaking the lifecycle limitations of traditional sessions. The original request message typically consists of header fields and a payload. Header fields contain control information, such as the request method, content type, and crucial authentication information. The system parses specific fields in the header, such as the Authorization field, whose value is usually an access token conforming to standards like OAuth 2.0. By decrypting or verifying the token's validity, the system can extract the user's unique identifier.
[0042] It's important to note that the "session-independent" nature of this identifier is its key innovation. It doesn't rely on a session ID created by the server for a single connection, which typically has an expiration time. Instead, it's a logical identifier (like a database primary key or UUID) permanently bound to the user entity. This allows the system to accurately link to the user's long-term data regardless of when or from which device the conversation begins, laying a solid foundation for subsequent loading of the unified memory.
[0043] Step S203: Extract the original query content input by the user from the payload of the original request message; This process involves seamlessly extracting the user's intent (i.e., the query content) from the network protocol encapsulation. After obtaining the message header metadata, the message payload needs further processing. The payload contains the actual content sent by the user; it may be plain text, structured data in JSON or XML format, or even multi-part form data (when file uploads are included). Based on the format indicated by header fields (such as Content-Type), the system calls the corresponding parser to parse the payload, thereby separating the original query content input by the user. This process requires handling encoding conversion (such as URL decoding) and data format validation to ensure that the extracted content is the original byte stream or text initially input by the user. This step ensures the accurate transmission of the user's intent and provides expanded possibilities for handling multimodal inputs (such as text, images, and files).
[0044] Step S204: Perform security verification and encoding standardization on the original query content to generate the current query text; Raw query content obtained directly from the network may contain potential risks and irregularities. Security verification aims to defend against threats such as injection attacks. For example, regular expression pattern matching is used to detect and filter characteristic characters that may be used for SQL injection or script injection, thereby preventing malicious code from damaging downstream databases or logic modules. Encoding standardization is to unify data formats and eliminate uncertainty. For example, multiple character encodings that may exist are uniformly converted to UTF-8 encoding to avoid garbled characters; full-width punctuation marks are uniformly converted to half-width or standardized to ensure the accuracy of subsequent natural language processing steps such as text vectorization. After these processes, a clean, standardized, and predictable structured query text is generated.
[0045] Step S205: Output the user's unique identifier and the current query text.
[0046] After the aforementioned steps of meticulous processing, the system packages and outputs two of the most critical information entities: the user's unique identifier serves as the "key" to locate the user, and the current query text serves as the "carrier" of the user's intent after purification and standardization.
[0047] In the above implementation, not only is the basic transformation from network data stream to business data completed, but also the "session-independent user unique identifier" extraction mechanism fundamentally ensures the accurate association of long-term personalized memory. At the same time, its built-in security verification and coding standardization preprocessing links improve the system's ability to resist malicious input and the stability and accuracy of downstream natural language processing tasks.
[0048] Reference Figure 3As one implementation of step S103, the steps of converting the current query text into a query vector, calculating the similarity between the query vector and each memory unit in the unified memory bank, and retrieving the K memory units with the highest similarity as the relevant memory set include: Step S301: Invoke the pre-trained semantic encoding model to map the current query text into a high-dimensional semantic vector; Among them, a deep neural network model is used to transform discrete symbolic text into a continuous numerical representation containing rich semantic information.
[0049] Specifically, the pre-trained semantic encoding models called by the system (such as BERT and Sentence-BERT based on the Transformer architecture) are trained on large-scale corpora, and their core capability lies in understanding the deep semantics of language rather than simple literal matching. This model encodes the input structured query text (a sequence of words) and maps it to a fixed-length high-dimensional semantic vector (usually a vector composed of hundreds or thousands of floating-point numbers). This vector can be viewed as the "coordinate points" of the text in a high-dimensional semantic space; texts with similar semantics will have their coordinate points close to each other in this space.
[0050] Step S302: Read the vectorized representations of each memory unit stored in the unified memory bank; Specifically, it activates long-term knowledge reserves related to the current user across multiple sessions, providing data support for personalized interactions. The unified memory is a continuously growing vector database maintained independently for each user. Each memory unit stored in it contains key information extracted from historical interactions (such as user preferences, historical orders, etc.), and is also converted into a vectorized representation through a semantic encoding model.
[0051] This step essentially involves loading all of a user's memory unit vectors from persistent storage into memory based on the user's identifier, forming a vector set that can be retrieved in real time. This allows the system to overcome the limitations of a single session and search within a rich semantic knowledge base that covers the user's long-term history.
[0052] Step S303: Perform a cosine similarity comparison operation on the high-dimensional semantic vector and the vectorized representation of each memory unit; Specifically, an approximate nearest neighbor search is performed in the high-dimensional semantic space, and semantic relevance is quantified by calculating the geometric relationships between vectors. The system then performs a numerical similarity comparison between the obtained query vector and all read memory unit vectors.
[0053] Specifically, the most common method is to calculate cosine similarity, which measures the consistency of the directions of two vectors by calculating the cosine of the angle between them. The value ranges from -1 to 1; the closer the value is to 1, the more consistent the directions of the two vectors, meaning the more similar the semantics of the texts they represent. This similarity calculation based on a vector space model can effectively capture semantic associations such as "recommended restaurants" and "what's good to eat," which have different expressions but similar intentions, and is key to achieving accurate and intelligent memory retrieval.
[0054] Step S304: Based on the similarity ranking results, select the top K memory units with the highest similarity to form a related memory set.
[0055] The system dynamically filters and aggregates background knowledge subsets based on quantitative relevance scores to form the most relevant subset for the current query. All calculated similarity scores are sorted in descending order, and then, according to a preset parameter K, the top K most similar memory units are selected and combined into a relevant memory set. This Top-K filtering mechanism is dynamically adaptable, returning the most relevant memories based on the specific circumstances of each query, rather than rigidly using a fixed similarity threshold.
[0056] For example, for a broad question, multiple memories may be highly relevant; while for a specific question, only a few may be highly relevant. The resulting set of relevant memories is a condensed, personalized background knowledge package that has been intelligently sorted and filtered. This package will be directly used in subsequent context enhancement steps to guide the language model in generating personalized responses.
[0057] In the above implementation, deep learning models are used to quantify text semantics, enabling semantically meaningful intelligent matching to replace shallow keyword matching. By calculating similarity in a high-dimensional vector space, the intrinsic connection between user queries and historical memories can be deeply understood. Finally, a highly relevant memory set is output through a dynamic Top-K mechanism. This retrieval process successfully transforms statically stored long-term user memories into dynamic, live contextual knowledge that can be dynamically invoked in each conversation. This provides a fundamental technical guarantee for the robot to "recognize the user" and conduct deep personalized interactions, improving the accuracy of interaction and the consistency of the user experience.
[0058] Reference Figure 4 As one implementation of step S104, the steps of sorting the relevant memory set according to time order and relevance, generating structured background text, and concatenating it with the current query text and the short-term context of the current session to form enhanced prompt words include: Step S401: Obtain the relevant memory set, wherein each memory unit contains a timestamp, memory content, and source session identifier; Specifically, each memory unit is a structured data entity. In addition to the core memory content (such as "user prefers dark mode"), it must also contain three key metadata: a timestamp, which records the specific time when the memory was generated and is the basis for judging the age of information and constructing a timeline; a source session identifier, which indicates in which conversation the memory was first recorded, which is crucial for tracing the source of information and maintaining the interpretability of data; and the memory content itself is the carrier of knowledge.
[0059] Step S402: Arrange the memory units in ascending order of timestamps to generate a time series set; Arranging memory units in ascending order according to their timestamps generates a time-series set that clearly shows the chronological order of events or facts related to the current problem within the user's history. For example, in a health consultant scenario, memories of a user's "blood pressure indicators," when sorted by time, can intuitively display their changing trends. This temporal structure is of great value for in-depth analysis and reasoning in language models, as it avoids confusion of factual causality or logical relationships that may result from disordered memory.
[0060] Step S403: Assign a relevance weight value to each memory unit in the time series set. The weight value is dynamically calculated based on its similarity to the current query text. While maintaining the chronological order, the system further prioritizes memory units based on their immediate relevance to the current question. Although each unit in the relevant memory set is somewhat relevant to the current query, the degree of relevance varies. The system uses the raw similarity values (such as cosine similarity values) calculated in the preceding retrieval steps, and through normalization and other processing, dynamically calculates a relevance weight value for each memory unit. This weight value is a quantitative indicator that accurately reflects the importance level of a memory within the current dialogue context.
[0061] Step S404: Reorder the time series set in descending order according to the correlation weight values to generate an optimized memory sequence; After establishing the temporal structure and weights, the system performs a secondary sorting, rearranging the information in descending order of relevance weights. This places the most relevant information in the most prominent position to maximize the attention of the language model. The resulting optimized memory sequence begins with the memory unit that most directly answers or responds to the user's question. This arrangement aligns with cognitive principles and the processing characteristics of the language model. When these memories are converted into text, the most important information is presented to the model first, significantly increasing the probability that the model accurately cites key facts when generating responses. It achieves an effective balance and combination of temporal cues and relevance priority.
[0062] Step S405: Convert the content, timestamp, and source session identifier of each memory unit in the optimized memory sequence into structured text paragraphs; This process involves synthesizing discrete data points and their metadata into a coherent and readable background story, providing the language model with an easily digestible and reasoning-based context, with natural text as input. Therefore, each memory unit in the optimized memory sequence, including its memory content, timestamp, and source session identifier, needs to be converted into a structured text paragraph according to a predefined template (e.g., "Timestamp in session source session identifier: user mentions memory content"). This process is not merely simple splicing, but a reorganization and formatting of information, transforming the originally scattered data points into a contextual and readable background introduction.
[0063] Step S406: Read the most recent N rounds of dialogue records stored in the current session buffer as short-term context; The system reads the most recent N rounds of dialogue from the current session buffer (usually a temporary storage area that maintains the most recent rounds of conversation) as short-term context. This information is crucial for understanding what the user has just said, handling pronoun references (such as "it" and "this"), and maintaining natural transitions between topics. This step is fundamental to achieving fluent multi-turn dialogue and complements the deep context provided by long-term memory.
[0064] Step S407: Concatenate the structured text paragraph, short context, and current query text into enhanced prompt words according to a preset format.
[0065] In this way, three different information sources with different dimensions and granularities—long-term memory, short-term context, and current problem—are clearly and hierarchically integrated into a complete instruction context, maximizing the performance of the language model.
[0066] In this embodiment, the system does not simply concatenate the three elements, but rather concatenates them according to a preset format (e.g., explicitly divided into three blocks: [Background Memory], [Recent Conversations], and [Current Problem]) to generate the final enhanced prompt words. This structured prompt word engineering provides the language model with extremely clear information navigation: it clearly knows where to find the user's long-term profile, where to view recent chat history, and what the core problem that needs to be solved is. This clear hierarchical structure greatly reduces the cognitive load on the model, guiding it to generate high-quality responses that possess both long-term personalized depth and maintain short-term conversational coherence.
[0067] In the above implementation, not only are relevant memories intelligently retrieved, but a well-organized and focused narrative of background knowledge is constructed through dual optimization of chronological arrangement and weighted rearrangement. Furthermore, by converting structured data into natural language and splicing it using a pre-defined partitioned format, an optimal reasoning environment is created for large-scale language models. This prompt word construction process is the information fusion center of the entire cross-conversation personalized interaction system, effectively transforming cold, fragmented historical data into coherent contextual knowledge that can be directly utilized by the model. This ensures that the robot's final generated response deeply reflects an understanding of the user's long-term history, achieving deep personalization and conversational coherence.
[0068] Reference Figure 5 As one implementation of step S106, the step of detecting the active service trigger condition based on the user identifier, related memory set, and system time includes: Step S501: Obtain the user-related attribute dataset, which includes the preset preference tags and business status metadata corresponding to the user identifier; The system retrieves user-related attribute datasets from an independent user profile database or business system based on user identifiers.
[0069] In this embodiment, the user-related attribute dataset contains two types of core information: first, preset preference tags, which are relatively stable tags that are explicitly set by the user or assigned by the system through historical behavior analysis, such as "preferring e-invoices" and "risk-averse investor," representing the user's long-term and stable tendencies; second, business status metadata, which is dynamic data synchronized in real time from the business system, such as "current policy validity period," "shipment status of the most recent order," and "account points balance," reflecting the real-time progress of the user's interaction with the service provider.
[0070] Step S502: Analyze the type labels and content text of each memory unit in the relevant memory set, and extract the user profile feature vector; This involves aggregating discrete and fragmented historical conversation memories into a computable dynamic profile that comprehensively reflects a user's recent interests, needs, and status.
[0071] Specifically, the relevant memory set consists of historical memory fragments retrieved from previous steps that are relevant to the current conversation. The system needs to go beyond the content of individual memory units and extract features from a macroscopic level. By parsing the type tags (such as "dietary preferences", "health indicators", "product consultation") and content text of each memory unit, the system uses natural language processing techniques (such as keyword extraction, sentiment analysis, topic modeling) or designed feature engineering methods to fuse and compress all this information, ultimately generating a low-dimensional, dense user profile feature vector.
[0072] Understandably, the user profile feature vector is no longer a specific sentence, but a numerical summary of the user's recent focus, potential needs, and lifestyle, which provides standardized and semantically rich input for subsequent intelligent inference.
[0073] Step S503: Read the current timestamp recorded by the system clock; The system reads a precise, standardized current timestamp from the operating system or network time protocol service; this time information is an indispensable variable in the triggering logic. Many services are highly time-sensitive, such as triggering bill reminders at the end of the month, sending birthday wishes to users, or reaching out during users' usual active periods. By using the absolute timestamp as input, the predefined rule engine can determine whether the current moment falls within a preset time window (such as "Monday morning"), or combine user profiles to determine whether the timing is appropriate (such as "avoid sending non-urgent notifications late at night"), thereby ensuring that proactive services are timely and appropriate, rather than untimely disturbances.
[0074] Step S504: Input the user profile feature vector, current timestamp, and business status metadata into the predefined condition matching engine and execute logical rule traversal matching. Among them, the rule system based on clear business logic enables accurate and reliable triggering of proactive service scenarios with high certainty and high value.
[0075] In this embodiment, the predefined condition matching engine is a rule executor with a pre-built "IF-THEN" rule base defined by business experts or product managers. The conditions of these rules are typically combinations of the existence of specific features in the user profile feature vector (e.g., "IF user profile contains 'planning to have children'"), the current timestamp meeting a specific range (e.g., "AND current time is 2025"), and business status metadata reaching a specific threshold (e.g., "AND user's current life insurance coverage is less than 1 million"). The engine iterates through all rules, matching the input data with the conditions of each rule. This rule-based approach offers advantages such as clear logic, predictable results, ease of control and debugging, making it ideal for scenarios with clear triggering conditions and fixed business rules, such as renewal reminders, birthday greetings, and recommendations based on fixed preferences, thus ensuring the stability and reliability of core services.
[0076] Step S505: When the predefined condition matching engine outputs a trigger flag that is satisfied, a trigger condition expression containing a service type identifier is generated. When the rule engine finds a matching rule, it outputs a trigger flag. At this point, the system doesn't directly execute the action; instead, it generates a structured trigger condition expression. This expression contains at least one service type identifier to uniquely identify the type of proactive service to be triggered, such as "policy renewal reminder," "product feature education," or "satisfaction survey." This design decouples trigger detection from service execution, allowing the trigger module to determine "when, why, and what service to trigger," while the specific service content generation is handled by downstream dedicated modules, improving the system's modularity and scalability.
[0077] Step S506: Analyze the user profile feature vector using a lightweight inference model and output the probability distribution of potential service intent; The underlying logic of this step is to leverage the generalization ability of machine learning models to discover potential service needs that cannot be described by hard rules but are implicit in users' long-term behavioral patterns, thus achieving coverage of long-tail scenarios. In parallel with the hard-coded rule-based engine, the system also deploys a lightweight inference model (such as a small, distilled neural network).
[0078] Specifically, this lightweight inference model takes the generated user profile feature vector as input and its task is to perform multi-class inference, outputting a probability distribution of potential service intents. This distribution is a vector, where each dimension represents a possible service intent (such as "Do I need health advice?", "Do I have financial needs?", "Do I need customer service support?"), and its value represents the probability that the model infers that the user belongs to that category. This method does not rely on all predefined combinations of conditions; instead, it uses complex patterns learned by the model from the data to identify hidden, subtle signals in the user profile, thereby triggering more flexible and personalized care or suggestions, compensating for the shortcomings of rule engines in handling ambiguous and unstructured needs.
[0079] Step S507: When the highest probability value in the probability distribution of potential service intents exceeds a preset probability threshold, a trigger condition expression containing an intent category identifier is generated.
[0080] Specifically, a confidence threshold is set for the AI inference results to ensure that only potential intentions that the model is highly confident in are translated into actual proactive service actions, balancing service coverage and accuracy. The system checks the probability distribution output by the inference model; if the highest probability value exceeds a preset threshold, the potential intention is considered significant enough to warrant triggering.
[0081] Subsequently, similar to the rule engine's trigger path, the system generates a trigger condition expression containing an intent category identifier. This expression indicates that it was triggered by AI inference and includes the specific intent category. This approach combines the insights of machine learning with robust engineering controls, allowing the system to discover services that users might need while using threshold filtering to avoid excessive invalid or annoying interruptions caused by model misjudgments.
[0082] The above implementation not only utilizes the user's static attributes and real-time business status, but also aggregates dynamic memory sets into computable feature vectors, closely integrating them with the temporal context. This ensures that triggering decisions are rooted in solid business logic while possessing the flexibility to understand dynamic user profiles and seize opportunities. This design allows text chatbots to completely transcend the passive response paradigm, enabling them to proactively provide crucial and considerate services at precise times, based on a deep understanding of the user, much like a true human assistant. This significantly enhances the predictability, personalization, and user value of services, serving as a core technological pillar for building next-generation intelligent interactive experiences.
[0083] Reference Figure 6 As one implementation of step S107, the step of generating active service text if the active service triggering condition is met, and merging it with the initial response text to form the final response text, includes: Step S601: When the active service triggering condition is detected, read the service type identifier contained in the triggering condition expression; Once the preceding detection logic (whether based on rule matching or AI inference) determines that the triggering condition is met, a structured triggering condition expression is generated. This expression is a machine-readable data object that encapsulates the essential information of the triggering event. The core action of this step is to read the service type identifier in this expression. This identifier is a key code or enumeration value that uniquely identifies a type of proactive service, such as "policy renewal reminder," "birthday wishes," or "personalized product recommendations." This allows the system to invoke different resource templates and adopt different generation and fusion strategies based on different service types, thereby achieving service precision and differentiation.
[0084] Step S602: Load the preset service template corresponding to the service type identifier, which includes variable slots and natural language structures; The system maintains a service template library, with each template bound to a service type identifier. Once the identifier is determined, the system loads the corresponding preset service template. This template is not pure natural language text, but a semi-finished structure containing two core parts: first, a fixed natural language structure, i.e., the main framework of the sentence, ensuring that the service script conforms to business specifications and basic grammar; second, variable slots, which are reserved placeholders for filling in dynamic and personalized information. For example, a renewal reminder template might be "Your [Policy Name] will expire on [Expiration Date]. Please renew in time to maintain coverage." Here, "[Policy Name]" and "[Expiration Date]" are variable slots.
[0085] Step S603: Based on the content data in the relevant memory set and the current system time, fill the variable slots of the preset service template to generate the service text base; The relevant memory set contains historical information related to the user, such as policy number and product preferences; the current system time provides the real-time time context for triggering the service. The task of this step is to extract the specific values corresponding to each variable slot in the template from these data sources and populate them into the template.
[0086] For example, the "policy name" is extracted from the memory unit as "XX Lifetime Critical Illness Insurance," and the "expiration date" is calculated as "October 25, 2024" from the system time. After filling in the blanks, a complete, but perhaps slightly stiff or formulaic, service text base is obtained. It contains all the correct information, but may lack in naturalness, fluency, and emotional tone.
[0087] Step S604: Call the language model to perform natural language polishing on the service text base and generate active service text paragraphs; Specifically, a language model (usually a lightweight model focused on text rewriting or optimization) is invoked to perform natural language polishing.
[0088] In some embodiments, the processing may include: synonym substitution to enrich the expression, sentence structure adjustment to make the rhythm smoother, adding appropriate interjections or emojis to increase friendliness, and ensuring consistency with the overall style of the conversation. For example, a stiff "Your policy will expire on October 25, 2025" could be polished into "Just a reminder that your whole life critical illness insurance coverage will expire on October 25, 2025. Don't forget to renew it on time!" This generated proactive service text paragraph retains the accuracy of the core facts while possessing good readability and friendliness.
[0089] Step S605: Input the initial response text and the active service text paragraph into the text fusion device, and reorganize the text structure according to the preset priority strategy; The text merging mechanism reorganizes the two responses according to a preset priority strategy. In some embodiments, the strategy may include: determining the order based on the urgency of the services (e.g., prioritizing important reminders); determining whether to present them side-by-side or embed the proactive service as supplementary information in an appropriate position within the initial response based on semantic relevance; or using transition sentences or separators to smoothly connect the two topics. The goal is to create a structurally optimal response order and presentation method that provides the best user experience, avoiding any sense of disjointed thinking or information overload for the user.
[0090] Step S606: Verify the logical coherence of the reconstructed text and output the final response text to the user session interface.
[0091] This step involves final quality control and consistency checks on the merged text to ensure that the content output to users is high-quality and free of logical errors, thereby maintaining the system's professionalism and credibility.
[0092] Understandably, even after the aforementioned meticulous processing, the merged text may still contain minor logical issues, such as ambiguous pronoun references, abrupt topic transitions, or inconsistencies in information. This step employs a validation process (potentially rule-based or a lightweight model) to detect these potential problems, focusing on evaluating logical coherence, such as checking the clarity of pronoun references and the smoothness of the topic flow. If a problem is detected, fine-tuning or refactoring can be triggered. After passing the validation, the final response text is output to the user's session interface, completing the interaction.
[0093] In the above implementation, the accuracy and standardization of proactive service content are first ensured through template-based and data-filling. Then, language models are used to refine the naturalness and approachability of the expression. Subsequently, a text fusion processor and preset strategies are used to intelligently coordinate the structure and priority between proactive services and direct responses, achieving an orderly organization of the response content. Finally, a logical coherence checkpoint ensures the high standard and professionalism of the final output text. This response fusion process enables the robot not only to accurately answer user questions but also to naturally and timely provide value-added services beyond the current question and answer, thereby enhancing the depth, warmth, and user experience of the interaction.
[0094] Reference Figure 7 As a further implementation of the cross-conversation text robot interaction method, it also includes: Step S701: Periodically scan the last access timestamp of each memory unit in the unified memory bank; The system uses a background task (such as a time-triggered daemon) to scan all memory units in the unified memory bank at fixed time intervals (e.g., every morning). The core objective of the scan is to read the last access timestamp recorded in the metadata of each memory unit. This timestamp is a crucial status indicator that precisely records the point in time when the memory unit was last retrieved, referenced, or modified.
[0095] Specifically, a database sharding and indexing technique combined with an incremental scanning strategy can be employed. This involves scanning only memory shards that may have changed since the last inspection, rather than performing a full database traversal each time, thereby minimizing performance interference with the online dialogue service. This step systematically transforms the dynamic usage of each memory unit into time-series data that can be quantified and processed by the program.
[0096] Step S702: Calculate the memory activity decay coefficient based on the difference between the current system time and the last access timestamp; Based on the principle of information entropy increase, a mathematical model simulating the natural forgetting pattern of human memory is established, quantifying the time difference as a continuous variable characterizing the degree of memory value decay. The system obtains the current precise system time and calculates the difference (Δt) with the last access timestamp of each memory unit collected in the first step. This Δt represents the silent duration during which the memory unit has not been triggered.
[0097] The system then applies a calculation model based on an exponential decay function to this Δt value to calculate the memory activity decay coefficient. This coefficient is typically a floating-point number between 0 and 1, and its value gradually approaches 0 as Δt increases. The decay constant (λ) in the model is a configurable parameter; different λ values can be set for different types of memory units (such as "long-term preferences" and "temporary session contexts") to achieve differentiated decay rates, reflecting the fine-grained management capabilities of the strategy. This coefficient is essentially a probabilistic assessment of the current relative value of the memory unit; a higher value indicates that the memory is "fresher" and more important.
[0098] Step S703: When the memory activity decay coefficient is lower than the preset survival threshold, the corresponding memory unit is migrated to the archive storage area. Among them, hot and cold data separation is implemented based on quantitative indicators, and "cold" data with low access probability is migrated from the high-performance main storage pool to low-cost storage media, thereby achieving the optimal balance between storage cost and access efficiency.
[0099] In this embodiment, the system compares the calculated decay coefficient of each memory cell with a predefined survival threshold (e.g., 0.05). This threshold is the critical point that distinguishes between "hot data" (active memory) and "cold data" (inactive memory). When the decay coefficient of a memory cell falls below this threshold, it is determined that it has entered a low-value state, and a migration process is triggered.
[0100] Specifically, the migration process includes: securely transferring the entire contents of the memory unit and its metadata from a high-speed active memory (such as an in-memory database) to an archive storage area (such as object storage or a cold storage database), updating its status to "archived" in the active memory, and retaining a lightweight index pointer for possible future relocation. This operation effectively controls the size of the active memory, avoiding the degradation of retrieval performance caused by unlimited data expansion, and is crucial to ensuring the long-term stable operation of the system.
[0101] Step S704: When a user's retrieval request for archived memory is received, the relevant memory units in the archived storage area are temporarily loaded into the active memory bank.
[0102] When a user's current query, after semantic analysis, is identified as potentially requiring access to archived historical memory (e.g., the query contains explicit time indicators such as "last year"), the system initiates an archive retrieval process. It searches the archive storage index based on the query criteria, locates the relevant memory unit, and temporarily loads its complete content back into the active memory. After loading, the memory unit is marked as "temporarily active" and a time-to-live (TTL) is set. Within this short period, it can be retrieved and referenced normally, just like active memory. If accessed again within the TTL, its status may be promoted to permanently active; otherwise, it will be automatically written back to the archive storage upon expiration.
[0103] In the above implementation, the natural decay of human memory is simulated, and the usage frequency of memories is transformed into actionable decision-making criteria through refined mathematical modeling. Based on this, dynamic optimization of storage resources is achieved. Simultaneously, its ingenious archiving and temporary loading mechanisms ensure that while pursuing high performance and low cost, the system will never lose any valuable historical information due to management operations, guaranteeing the continuity and traceability of memories. Ultimately, this solution makes the unified memory bank a system capable of intelligently optimizing resources, providing upper-layer applications with an efficient, economical, and complete long-term memory support platform, forming the foundation for building a sustainably evolving personalized interactive system.
[0104] This application also discloses a cross-conversation text robot interaction system based on a unified memory.
[0105] A cross-session text-based robot interaction system based on a unified memory bank, specifically including: The request parsing and user identification module is used to receive dialogue requests initiated by users, parse them to obtain user identifiers and current query text; The unified memory loading module is used to load the corresponding unified memory according to the user identifier; wherein, the unified memory contains at least one structured memory unit, and each memory unit contains memory content represented by vectorization; The memory retrieval module is used to convert the current query text into a query vector, calculate the similarity between the query vector and each memory unit in the unified memory bank, and retrieve the K memory units with the highest similarity as the relevant memory set. The enhanced prompt word building module is used to sort the relevant memory set by time order and relevance, generate structured background text, and concatenate it with the current query text and the short-term context of the current session to form enhanced prompt words; The initial response generation module is used to input the enhanced prompt words into the language model to generate the initial response text; The proactive service trigger detection module is used to detect proactive service trigger conditions based on user identifier, relevant memory set, and system time. The final response generation module is used to generate active service text when the active service triggering conditions are met, and merge it with the initial response text to form the final response text.
[0106] An embodiment of this application provides a cross-conversation text robot interaction system based on a unified memory that can implement any of the above methods, and the specific working process of each module in the system can be referred to the corresponding process in the above method embodiments.
[0107] In the several embodiments provided in this application, it should be understood that the provided methods and systems can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for example, the division of a certain module is merely a logical functional division, and in actual implementation there may be other division methods, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.
[0108] This application also discloses a computer device.
[0109] A computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a cross-conversation text robot interaction method based on a unified memory as described above.
[0110] This application also discloses a computer-readable storage medium.
[0111] A computer-readable storage medium storing a computer program that can be loaded by a processor and executed as described above in any of the methods of a cross-conversation text-based robot interaction method based on a unified memory.
[0112] The computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device; the program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0113] The above are all preferred embodiments of this application and are not intended to limit the scope of protection of this application. Any feature disclosed in this specification (including the abstract and drawings) may be replaced by other equivalent or similar features unless specifically stated otherwise. That is, unless specifically stated otherwise, each feature is only one example of a series of equivalent or similar features.
Claims
1. A cross-conversation text-based robot interaction method based on a unified memory, characterized in that, The method includes: Receive a dialogue request initiated by a user, parse it to obtain the user identifier and the current query text; The corresponding unified memory is loaded according to the user identifier; wherein, the unified memory contains at least one structured memory unit, each memory unit contains vectorized memory content, the last access timestamp of each memory unit in the unified memory is scanned periodically, and the memory activity decay coefficient is calculated based on the difference between the current system time and the last access timestamp using an exponential decay function; when the memory activity decay coefficient is lower than a preset survival threshold, the corresponding memory unit is migrated to the archive storage area; when a user's retrieval request for archived memory is received, the relevant memory unit in the archive storage area is temporarily loaded into the active memory and a survival time is set, and if it is accessed again within the survival time, it is promoted to a permanently active state, and automatically written back to the archive storage area after the expiration; The current query text is converted into a query vector, the similarity between the query vector and each memory unit in the unified memory bank is calculated, and the K memory units with the highest similarity are retrieved as the related memory set. The relevant memory set is sorted according to time order and relevance to generate structured background text, which is then concatenated with the current query text and the short-term context of the current session to form enhanced prompt words; The enhanced prompt words are input into the language model to generate the initial response text; Based on the user identifier, the relevant memory set, and the system time, proactive service triggering conditions are detected. This involves: acquiring a user-related attribute dataset containing preset preference tags and business status metadata corresponding to the user identifier; parsing the type tags and content text of each memory unit in the relevant memory set to extract user profile feature vectors; reading the current timestamp recorded by the system clock; inputting the user profile feature vectors, the current timestamp, and the business status metadata into a predefined condition matching engine to perform logical rule traversal matching; when the predefined condition matching engine outputs a trigger flag that is met, generating a triggering condition expression containing a service type identifier; analyzing the user profile feature vectors using a lightweight inference model to output a potential service intent probability distribution; when the highest probability value in the potential service intent probability distribution exceeds a preset probability threshold, generating a triggering condition expression containing an intent category identifier; the detection process employs two strategies in parallel or sequentially. If the proactive service triggering conditions are met, proactive service text is generated and merged with the initial response text to form the final response text.
2. The method for cross-conversation text robot interaction based on a unified memory according to claim 1, characterized in that, The steps for receiving a user-initiated dialogue request and parsing it to obtain the user identifier and the current query text include: Listen for user request data packets coming into the network port and extract the original request message; Parse the header fields of the original request message to obtain a session-independent user unique identifier; Extract the original query content input by the user from the payload of the original request message; The original query content is subjected to security verification and encoding standardization processing to generate the current query text; Output the user's unique identifier and the current query text.
3. The method for cross-session text robot interaction based on a unified memory according to claim 1, characterized in that, The steps of converting the current query text into a query vector, calculating the similarity between the query vector and each memory unit in the unified memory bank, and retrieving the K memory units with the highest similarity as the relevant memory set include: Invoke a pre-trained semantic encoding model to map the current query text into a high-dimensional semantic vector; Read the vectorized representation of each memory unit stored in the unified memory bank; Perform a cosine similarity comparison operation on the high-dimensional semantic vector and the vectorized representation of each memory unit; Based on the similarity ranking results, the top K memory units with the highest similarity are selected to form a related memory set.
4. The method for cross-session text robot interaction based on a unified memory according to claim 3, characterized in that, The steps of sorting the relevant memory set by time order and relevance, generating structured background text, and concatenating it with the current query text and the short-term context of the current session to form enhanced prompt words include: Retrieve the relevant memory set, where each memory unit contains a timestamp, memory content, and source session identifier; The memory units are arranged in ascending order of timestamps to generate a time series set; Each memory unit in the time series set is assigned a relevance weight value, which is dynamically calculated based on its similarity to the current query text; The time series set is rearranged in descending order according to the correlation weight values to generate an optimized memory sequence; The content, timestamp, and source session identifier of each memory unit in the optimized memory sequence are converted into structured text paragraphs; Read the most recent N rounds of dialogue records stored in the current session buffer as short-term context; The structured text paragraph, the short context, and the current query text are concatenated into enhanced prompt words according to a preset format.
5. The method for cross-conversation text robot interaction based on a unified memory according to claim 1, characterized in that, If the active service triggering condition is met, the step of generating active service text and merging it with the initial response text to form the final response text includes: When the active service triggering condition is detected to be met, the service type identifier contained in the triggering condition expression is read; Load the preset service template corresponding to the service type identifier, which includes variable slots and natural language structures; Based on the content data in the relevant memory set and the current system time, the service text base is generated by filling the variable slots of the preset service template; The language model is invoked to perform natural language processing on the service text base to generate active service text paragraphs; The initial response text and the active service text paragraph are input into a text fusion processor, and the text structure is reorganized according to a preset priority strategy. Verify the logical coherence of the reconstructed text and output the final response text to the user session interface.
6. A cross-conversation text-based robot interaction system based on a unified memory, characterized in that, The system is used to execute the cross-session text robot interaction method based on a unified memory as described in any one of claims 1 to 5, the system comprising: The request parsing and user identification module is used to receive dialogue requests initiated by users, parse them to obtain user identifiers and current query text; A unified memory loading module is used to load the corresponding unified memory according to the user identifier; wherein, the unified memory contains at least one structured memory unit, and each memory unit contains memory content represented by a vectorization; The memory retrieval module is used to convert the current query text into a query vector, calculate the similarity between the query vector and each memory unit in the unified memory bank, and retrieve the K memory units with the highest similarity as the related memory set; The enhanced prompt word construction module is used to sort the relevant memory set according to time order and relevance, generate structured background text, and concatenate it with the current query text and the short-term context of the current session to form enhanced prompt words; An initial response generation module is used to input the enhanced prompt words into a language model to generate initial response text. The proactive service trigger detection module is used to detect proactive service trigger conditions based on the user identifier, the relevant memory set, and the system time. The final response generation module is used to generate active service text when the active service triggering conditions are met, and merge it with the initial response text to form the final response text.
7. A computer device, characterized in that: The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer program is stored that can be loaded by a processor and executed as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Active dialogue triggering method, device and equipment, vehicle and storage medium
CN116701581A
Intelligent agent long-term memory modeling method based on memory network
CN120688545A