Question and answer processing method and device, medium and product
By constructing a hierarchical storage structure and a multi-dimensional signal detection algorithm, the efficiency and accuracy issues of large language models in user interaction data storage and retrieval are solved, achieving efficient and personalized question-and-answer processing and improving the rationality and personalization of the response content.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- IFLYTEK CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-05-15
AI Technical Summary
Existing large language models suffer from low retrieval efficiency, insufficient information content, and inadequate response accuracy and personalization in storing and retrieving user interaction data, especially in long-cycle interactions and unstructured data processing.
A hierarchical storage structure is constructed, the target query intent is determined by intent classification, and retrieval is performed in each memory layer according to the access priority of each layer. Information retrieval is combined with a multi-dimensional signal detection algorithm to ensure that the level of abstraction of information matches the semantic granularity, thereby improving retrieval efficiency and the rationality and personalization of the response content.
Through optimized storage and retrieval mechanisms, the retrieval efficiency of the question-answering system and the contextual rationality and personalization of the responses have been significantly improved, while computational overhead and latency have been reduced, providing more accurate and personalized responses.
Smart Images

Figure CN122047463A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence and natural language processing, and in particular to a question-answering processing method, device, medium, and product. Background Technology
[0002] In recent years, with the rapid development of Large Language Models (LLM) technology, AI assistants have provided great convenience to users as personal assistants.
[0003] Currently, users' historical interaction data is usually compressed and stored in a flat, stacked manner. When it is necessary to retrieve this historical interaction data to generate a response to a user's question, the relevant content must be retrieved from this flat storage structure.
[0004] However, this not only leads to low retrieval efficiency, but also results in insufficient information in the retrieval results due to the loss of a large amount of detailed information during the compression process, which in turn affects the rationality and personalization of the response. Summary of the Invention
[0005] Based on the aforementioned technological status, this application provides a question-and-answer processing method, device, medium, and product that can improve the retrieval efficiency of users' historical interaction data and enhance the rationality and personalization of response content.
[0006] To achieve the above-mentioned technical objectives, this application proposes the following technical solution: According to a first aspect of the embodiments of this application, a question-and-answer processing method is provided, comprising: classifying intents based on acquired user questions to obtain target query intents corresponding to the user questions; determining access priorities of memory layers corresponding to the target query intents based on the target query intents and a mapping relationship between the query intents and access priorities of preset memory layers at various levels; wherein each memory layer is a hierarchical storage structure that stores the user's historical conversation messages in ascending order of information abstraction; retrieving memory data related to the target query intents in each memory layer according to the access priorities of the memory layers at various levels; and generating response content to the user questions based on the memory data.
[0007] According to a second aspect of the embodiments of this application, an electronic device is provided, including a memory and a processor; the memory is connected to the processor and is used to store a program; the processor is used to implement the question-and-answer processing method as described in the first aspect by running the program in the memory.
[0008] According to a third aspect of the embodiments of this application, a storage medium is provided, on which a computer program is stored, and when the computer program is run by a processor, it implements the question-and-answer processing method as described in the first aspect.
[0009] According to a fourth aspect of the embodiments of this application, a computer program product is provided, including computer program instructions that, when executed by a processor, cause the processor to perform: the question-and-answer processing method as described in the first aspect.
[0010] This application provides a question-and-answer processing method, device, medium, and product. The method classifies user questions based on their intents to obtain the target query intent. Based on the target query intent and the mapping relationship between the query intent and preset access priorities of various memory layers, the access priorities of each memory layer corresponding to the target query intent are determined. Each memory layer is a hierarchical storage structure that stores the user's historical conversation messages in ascending order of information abstraction. Based on the access priorities of each memory layer, a retrieval is performed within each memory layer to obtain memory data related to the target query intent. Based on the memory data, a response to the user question is generated. This technical solution determines the access priority of each memory layer based on the user's target query intent and retrieves relevant memory data from each layer accordingly. This guides the model to extract information that highly matches the target query intent from the correct memory layer, avoiding ineffective traversal of low-priority layers, reducing computational overhead and latency, and improving retrieval efficiency. Furthermore, since different memory layers store multi-granularity information ranging from specific events to abstract preferences, the priority-driven retrieval mechanism can further acquire semantic granularity adapted to the target query intent on demand. This provides more comprehensive and accurate contextual support for subsequent reasoning and generation, thereby significantly improving the contextual rationality and personalization of the response content. Attached Figure Description
[0011] 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 embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0012] Figure 1 This is a flowchart of a question-and-answer processing method provided in an embodiment of this application.
[0013] Figure 2 This is a schematic diagram of the architecture of each level of memory layer provided in the embodiments of this application.
[0014] Figure 3 A flowchart of another question-and-answer processing method provided in an embodiment of this application.
[0015] Figure 4 A flowchart illustrating the method for constructing memory layers at various levels as provided in the embodiments of this application.
[0016] Figure 5 This is a schematic diagram of the structure of a question-and-answer processing device provided in an embodiment of this application.
[0017] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] The technical solutions provided in this application can be applied, by way of example, to hardware devices such as processors, electronic devices, and servers (including cloud servers), or packaged as software programs and run. When the hardware device executes the processing procedure of the technical solutions in this application, or when the aforementioned software program is run, the target task can be automatically split and the application programming interfaces required by the task can be automatically invoked to achieve the purpose of the target task. This application only provides illustrative descriptions of the specific processing procedure of the technical solutions in this application and does not limit the specific implementation form of the technical solutions in this application. Any technical implementation form that can execute the processing procedure of the technical solutions in this application can be adopted by this application.
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] Before introducing the solution proposed in this application, the relevant technologies will first be introduced: Artificial intelligence assistants, or AI assistants for short, are intelligent programs developed using artificial intelligence technologies (such as natural language processing and machine learning). They are designed to understand human language, analyze user needs, and provide information, perform tasks, or complete services through dialogue and interaction, thereby helping users solve problems.
[0021] The core function of AI assistants lies in simulating human intelligent interaction: receiving voice or text commands, interpreting user intent, and generating corresponding responses. Common functions include information retrieval, task execution (such as setting reminders and controlling smart home devices), content creation, and data analysis. Due to their high level of convenience, AI assistants have been widely applied in various human-computer interaction scenarios, including intelligent customer service, personal assistants, educational tutoring, and medical consultation.
[0022] However, existing large language models are inherently stateless, and their reasoning process relies solely on the context of the current input, unable to autonomously retain or retrieve the user's personalized information across sessions. To compensate for this "memory deficiency," external memory mechanisms are commonly used. This involves building a memory storage and retrieval mechanism outside the model and inputting the retrieval results as part of the prompts to achieve a certain degree of personalized response.
[0023] Specifically, the mechanism first segments the user's original dialogue data using fixed rules; second, it compresses the segmented conversations using a digest method and converts them into structured data formats such as JSON; and then, it stores these processed memory data in a vector database in a flattened manner.
[0024] When a user asks a question, the system retrieves relevant historical dialogue data fragments from the vector database based on semantic similarity; these fragments are then concatenated with the user's prompts and input into a large model to generate a response to the user's question.
[0025] However, this approach has the following main drawbacks: (1) Limited by the upper limit of the model's tokens (such as 8K or 128K), it is difficult to support long-term interactions; and as the context grows, the reasoning cost increases approximately quadratically. At the same time, the model is prone to the "Lost in the Middle" phenomenon, which weakens the focus on key information and affects the accuracy and personalization of the response.
[0026] (2) Although the semantic similarity retrieval method can recall semantically similar segments, it often retrieves content that is not related to the context because it only relies on surface similarity.
[0027] (3) When storing user information as structured data such as JSON, a schema needs to be predefined, which results in poor flexibility and difficulty in handling unstructured natural language dialogues and complex user behavior patterns.
[0028] (4) The process of generating abstracts with high compression ratios often loses a lot of details (such as specific time, place, and subtle emotional changes), resulting in insufficient information in the search results and thus reducing the quality of the response.
[0029] (5) The use of a flat data stacking method results in low retrieval efficiency under large-scale memory.
[0030] (6) Segmenting dialogues based on fixed rules can easily break up the complete topic and damage its integrity.
[0031] In summary, while the current external memory solution alleviates the "stateless" problem of large models to some extent, it still struggles to generate highly accurate and personalized responses due to the aforementioned shortcomings.
[0032] In view of this, the embodiments of this application aim to provide a question-answering processing method, device, medium, and product. This method constructs a hierarchical storage structure and proposes a topic boundary detection algorithm combining multi-dimensional signals of time, semantics, and sentiment to perform boundary detection on conversation messages. When a new topic is identified, ended conversations are stored in memory layers at each level according to the order of information abstraction from low to high. When information retrieval is needed subsequently, the access priority of each memory layer is determined by the user's target query intent, and information retrieval is performed accordingly. This guides the model to extract information highly matching the target query intent from the correct memory layer, avoiding invalid traversal of low-priority layers, reducing computational overhead and latency, and improving retrieval efficiency. Furthermore, since different memory layers store multi-granularity information ranging from specific events to abstract preferences, based on the priority-driven retrieval mechanism, it can further obtain semantic granularity adapted to the target query intent on demand, providing more comprehensive and accurate contextual support for subsequent reasoning and generation, thereby significantly improving the contextual rationality and personalization of the response content. These will be described in detail in the following embodiments.
[0033] Exemplary methods Figure 1 This is a flowchart illustrating a question-and-answer processing method provided in an embodiment of this application. Figure 1 As shown, the question-and-answer processing method provided in this embodiment includes steps S101-S104: S101. Classify the intents of the obtained user questions to obtain the target query intents corresponding to the user questions.
[0034] The execution subject in this embodiment can be a user's terminal device, such as a smartphone, smart speaker, tablet, or in-vehicle system. When a user asks a question on the terminal device via voice or text input, semantic understanding and intent recognition are required to classify the intent.
[0035] In some examples, user queries can be classified using a pre-trained intent classification model to obtain the corresponding target query intent. This intent classification model can be pre-trained under supervision using deep learning architectures (such as BERT, Transformer, or LSTM) with training samples containing user queries and their corresponding true query intents.
[0036] In practical applications, intent classification models can map user queries to a set of preset query intent categories, and output a confidence probability for each category. Then, the intent category with the highest probability is selected as the target query intent for the user's query.
[0037] In some examples, the predefined query intent categories in this group may include: factual queries, inference queries, sentiment queries, and predictive queries. Each category corresponds to a typical pattern of how users express information needs or psychological desires in different scenarios, which helps to provide targeted information queries.
[0038] The fact query category focuses on retrieving specific, objective historical or current information. Users typically seek answers to known facts by directly asking questions such as, "What is my birthday?" or "Where was the last meeting held?" This type of query emphasizes the accuracy and timeliness of the information.
[0039] Inference-based queries require logical integration and inference based on multiple pieces of existing information to generate personalized or contextualized answers. Users often don't directly state their goals but provide clues or conditions, expecting the question-answering system to perform implicit inference. Examples include: "Recommend a restaurant based on my eating habits," or "Based on my schedule, can I still schedule a gym session today?" This query category demands a high level of understanding of context, fusion of multi-source information, and reasoning ability.
[0040] The sentiment query category focuses on expressing emotional states, feelings, or seeking emotional support, rather than obtaining specific facts. Users may convey their inner emotions through venting, sighing, or vague expressions, such as "I've been feeling a lot of stress lately" or "I haven't had a very happy year."
[0041] Predictive queries focus on future events, trends, or potential risks, expecting the question-and-answer system to make forward-looking judgments or alerts based on historical data and current status. Examples include "What precautions should I take next week?", "Based on my health data, are there any abnormal risks in the next month?", and "Will it rain in the next few days?". This query category relies on time series analysis, behavioral modeling, or external data access to help users plan ahead, mitigate risks, or optimize decision-making.
[0042] S102. Based on the target query intent and the mapping relationship between the query intent and the access priorities of the preset memory layers at each level, determine the access priorities of the memory layers at each level corresponding to the target query intent.
[0043] The memory layers are hierarchical storage structures that store users' historical conversation messages in ascending order of information abstraction. In other words, users' historical conversation information is stored hierarchically, following the order from specific events to the abstract information extracted from those events.
[0044] In this embodiment, each level of memory layer is designed to simulate the memory characteristics of the biological brain in the process of perceiving, processing, storing and retrieving information, and is constructed as a biological memory mechanism that conforms to the cognitive science of the biological brain.
[0045] Figure 2 This is a schematic diagram of the architecture of each level of memory layer provided in the embodiments of this application. For example... Figure 2 As shown, each memory layer comprises five layers progressively higher according to the level of information abstraction, hereinafter referred to as Memory Layer L1, Memory Layer L2, Memory Layer L3, Memory Layer L4, and Memory Layer L5. The functions and characteristics of each memory layer are as follows: The first memory layer, L1, can be understood as the perception buffer. As the lowest-level buffer for raw input messages, it temporarily stores approximately 100-150 of the user's most recent raw input messages using a first-in, first-out (FIFO) queue mechanism. This layer does not perform semantic parsing or information extraction; it only retains unprocessed raw interaction data, providing immediate contextual support for upper layers.
[0046] The second memory layer, L2, can be understood as the working memory layer. It is responsible for maintaining the short-term context state of the current session, typically retaining the content of the most recent 15-30 rounds of dialogue. Its core function is to ensure the coherence and contextual consistency of multi-turn dialogues. When a complete session ends, the current session content stored in L2 is processed and migrated to L3.
[0047] The third memory layer, L3, can be understood as the Episodic Memory layer. It organizes and retains fragments of the user's past interaction events in chronological order. Each record contains complete 5W1H metadata (i.e., time, place, person, event, reason, and method) to restore the detailed information in a specific scenario.
[0048] The fourth memory layer, L4, can be understood as the semantic memory layer. It extracts common patterns from the contextual memory of L3, removing specific constraints such as time and place to form decontextualized abstract knowledge. Its content includes: user preferences (such as dietary restrictions, common modes of transportation), behavioral habits (such as exercising every Wednesday evening), common-sense rules, and stable facts (such as "the user is allergic to peanuts"). This layer supports cross-scenario knowledge reuse and generalized reasoning.
[0049] The fifth memory layer, L5, can be understood as the autobiographical memory layer. It stores highly stable information such as a user's core identity attributes, long-term goals, values, personality traits, and deep beliefs. For example, "The user hopes to start a business within three years," "They value work-life balance," and "They prefer an environmentally friendly lifestyle." This type of information is updated less frequently and is more stable, but it has the highest access priority when it involves important decisions, personalized recommendations, or emotional resonance.
[0050] In some embodiments, the access priority of each memory layer corresponding to the target query intent can be determined based on the mapping relationship between the query intent and the access priorities of preset memory layers at each level. This mapping relationship can be specifically as follows: The access priorities for memory layers at each level for fact queries are as follows: L3 and L4 have higher access priority than other memory layers. For inference queries, the access priorities are: retrieval is performed in layers L2-L5, with a focus on layers L4 and L3. For sentiment queries, the access priorities are as follows: L3 and L5 have higher access priority than other memory layers. For prediction queries, the access priorities are as follows: L4 and L2 have higher access priority than other memory layers.
[0051] In some embodiments, the target retrieval strategy corresponding to the target query intent can be determined based on the target query intent and the preset mapping relationship between query intent and retrieval strategy. Then, based on the target retrieval strategy, the retrieval strategy can be matched in the mapping relationship between the retrieval strategy and the access priority of each level of memory layer to obtain the access priority of each level of memory layer corresponding to the target retrieval strategy.
[0052] The retrieval strategies may include: exact matching strategy, broad retrieval and association matching strategy, sentiment signal matching strategy, semantic association and timeline deduction strategy.
[0053] The precise matching strategy is suitable for scenarios where the accuracy of information is extremely important, emphasizing direct and unambiguous matching of existing facts.
[0054] Extensive retrieval and association matching strategies are suitable for scenarios that require comprehensive reasoning or recommendation based on information from multiple sources, emphasizing the breadth of information coverage and semantic relevance.
[0055] Emotional signal matching strategies focus on identifying and responding to users' emotional states, psychological needs, or empathy requests.
[0056] Semantic association and timeline extrapolation strategies are used for predictive analysis of future trends, potential risks, or event evolution, relying on an understanding of historical patterns and the ability to extrapolate over time.
[0057] Accordingly, the mapping relationship between the preset query intent and retrieval strategy includes: fact query category corresponding to exact matching strategy, reasoning query category corresponding to broad retrieval and association matching strategy, sentiment query category corresponding to sentiment signal matching strategy, and prediction query category corresponding to semantic association and timeline deduction strategy.
[0058] Based on this, each retrieval strategy is further configured with access priority for each level of memory layer, as follows: When the target retrieval strategy is an exact match strategy, this strategy aims to quickly locate clear and specific factual information. L3 (contextual memory layer) stores specific events with complete context (e.g., "On October 5, 2024, the user booked a flight from city A to city B"), while L4 (semantic memory layer) summarizes decontextualized stable knowledge (e.g., "The user's usual city is city A" and "lactose intolerant"). Both can meet the high-precision retrieval requirements. Therefore, L3 and L4 have higher access priority than other memory layers, while L1, L2, and L5 serve only as auxiliary supplements.
[0059] When the target retrieval strategy is a broad retrieval and association matching strategy, this type of strategy emphasizes mining potential associations from multiple dimensions, requiring consideration of both short-term context and long-term patterns. Therefore, a comprehensive retrieval is needed at layers L2 to L5. L2 retrieves current conversation clues, L3 retrieves historical event details and past user feedback, and L4 extracts refined preferences, habits, and rules—the core of constructing association inference. L5 retrieves the user's deeper motivations. Among these, L4 and L3 are given higher weights to ensure semantic relevance while achieving broad coverage.
[0060] When the target retrieval strategy is an emotion signal matching strategy, because it has a high demand for emotion, and L3 stores events with emotion tags, and L5 stores user personality tendencies and value data, the access priority of the corresponding memory layers is as follows: L3 and L5 have higher access priority than other memory layers, L4 can help identify emotion-related habits (such as "like to listen to classical music when stressed"), and L1 / L2 are used to capture current emotional cues.
[0061] When the target retrieval strategy employs semantic association and timeline extrapolation, this type of retrieval strategy requires trend extrapolation or future planning based on historical behavioral patterns. The abstract behavioral patterns provided by layer L4 (such as "a habit of reviewing finances at the beginning of each month") form the basis for this extrapolation, while the recent dialogue context retained by layer L2 (such as "the user just mentioned they're going on a business trip next week") provides anchor points for the timeline. Therefore, the access priorities of the corresponding memory layers are as follows: L4 and L2 are set as high-priority access layers, L3 can be used to verify historically similar situations, and L5 provides guidance when it comes to aligning long-term goals.
[0062] Through the two-level mapping mechanism of "query intent → retrieval strategy → priority of each level of memory layer" mentioned above, the access priority of each level of memory layer corresponding to the target query intent can also be determined.
[0063] S103. Based on the access priority of each level of memory layer, perform retrieval in each level of memory layer to obtain memory data related to the target query intent.
[0064] In this step, based on the access priority sequence of each memory layer determined in step S102 (e.g., L3>L4>L2>L5>L1), the memory data related to the target query intent will be retrieved in the corresponding memory layers in descending order.
[0065] During the retrieval process, the focus is first on the memory layer with the highest access priority, from which memory fragments related to the current target query intent are extracted. For example, if the target query intent is "fact query", specific records with clear metadata such as time, location, and event are searched first in L3, while stable factual knowledge (such as user preferences, frequently used locations, and fixed schedules) that have been summarized are retrieved in L4 to obtain relevant memory data.
[0066] S104. Generate response content to user questions based on the memorized data.
[0067] Specifically, step S104 includes: determining whether the retrieved memory data meets the information requirements for replying to the user's question; if not, identifying the missing information type; performing supplementary queries based on the missing information type to obtain supplementary query results; further, determining whether the memory data and supplementary query results meet the information requirements for replying to the user's question; if not, continuing supplementary queries until the supplementary query results and memory data meet the information requirements for replying to the user's question, and then generating a reply to the user based on the memory data and supplementary query results.
[0068] By supplementing the query mechanism, the model is given the ability to "self-examine," thereby automatically supplementing missing information, significantly reducing the occurrence of incorrect answers due to incomplete retrieval, and thus improving the accuracy of responses.
[0069] In some embodiments, to address the large model illusion and black box problem, this application may further include the following steps a1-a4 when implementing step S104: Step a1: Determine the correlation between multiple memory fragments and user questions.
[0070] After retrieving relevant memory data from various memory layers, it is necessary to further evaluate the semantic relevance of multiple memory fragments contained in this data to the current user's question. Specifically, each memory fragment can be scored using a pre-trained relevance scoring model to obtain the relevance between each memory fragment and the user's question. This model is based on a deep semantic matching architecture (such as Sentence-BERT, DPR, or Cross-Encoder) and can capture the degree of fit between the user's question and memory fragments in multiple dimensions such as semantics, entities, time, and intent.
[0071] For example, when a user asks, "Did I go to the hospital last week?", the model calculates a high correlation score between this question and the memory fragment in L3, "On December 20, 2025, the user went to the First Municipal Hospital for a follow-up visit," while assigning a low score to the record "Booked a flight in August 2024." The final output is a set of memory fragments with correlation scores, which serves as the basis for subsequent processing.
[0072] Step a2: Based on relevance, sort multiple memory segments in descending order and determine the logical relationships between the sorted memory segments.
[0073] After obtaining the relevance scores, all memory fragments can be sorted from highest to lowest relevance score to form a ranking result. Subsequently, to further enhance the depth of understanding, the logical relationships such as temporal, causal, conditional, or comparative relationships between the sorted memory fragments can be analyzed.
[0074] In some examples, the analysis of logical relationships can be achieved through an event graph building module or a causal reasoning engine. For example, if highly relevant segments include: "worked overtime until late at night on December 15", "took sick leave on the morning of December 16 due to headache", and "bought painkillers on December 17", then the causal chain of "continuous overtime → lack of sleep → headache → medication" can be inferred.
[0075] Step a3: Generate a structured chain of evidence based on the logical relationships between multiple memory fragments; the structured chain of evidence includes at least two of the following: the content of the multiple memory fragments, the information source identifier, the reasoning basis, and the confidence level.
[0076] After obtaining the logical connections between the various memory fragments through step a2, they can be integrated into one or more structured evidence chains. Each evidence chain not only contains the original memory content, but also explicitly labels its information source, reasoning path, and credibility, thereby enhancing the transparency and interpretability of the system's decision-making.
[0077] The structured chain of evidence can be represented as follows: [Content of multiple memory fragments] -> [Information source identifier] -> [Basis of reasoning] -> [Confidence level].
[0078] Memory content: such as "The user went to the First Municipal Hospital on December 20, 2025"; Source identifier: Indicates that the memory comes from L3 (episodic memory layer) or L4 (semantic memory layer), and includes the original session ID or event ID; Reasoning basis: Explain how the fragment supports the answer, such as "this event directly responds to the user's question about 'whether to go to the hospital'" or "combined with the record of 'the user has chronic gastritis' in L4, the reason for seeking medical treatment can be explained"; Confidence level: Calculated by both the relevance model and logical consistency, the value is usually in the range of 0–1, and is used to quantify the reliability of the evidence.
[0079] Through structured expression, question-answering systems can not only answer "what" but also clearly explain "why they think so," significantly improving user trust.
[0080] Step a4: Based on the structured chain of evidence, generate the response content and explanatory evidence for the user's question.
[0081] In this step, a Natural Language Generation (NLG) module is driven by a structured chain of evidence to synthesize an accurate and interpretable response. The response typically includes both the answer to the user's question and explanatory evidence.
[0082] The response to user questions serves as the main answer, providing a concise and clear reply. For example: "Yes, you went to the First Municipal Hospital on December 20th." Explanatory justification briefly explains the source of the conclusion in natural language, such as: "Based on your medical record on December 20 and the stomach discomfort you mentioned earlier, the system determines that you were returning for a follow-up visit due to chronic gastritis." In scenarios involving complex reasoning or emotional support, explanatory evidence can also demonstrate a logical chain (such as "You have been working overtime recently and have not been getting enough sleep, which may have caused your headache").
[0083] This embodiment enhances the credibility of responses to user questions in human-computer interaction by translating the chain of evidence into language that users can understand, thus solving the illusion and black box problems of large models.
[0084] Figure 3 A flowchart illustrating another question-and-answer processing method provided in an embodiment of this application. For example... Figure 3 As shown, the question-and-answer processing method includes the following steps S301-S305: S301. Classify the intent based on the obtained user question to obtain the target query intent corresponding to the user question.
[0085] The specific implementation process of step S301 is similar to that of step S101; please refer to the specific implementation process of step S101 for details.
[0086] S302. Based on the target query intent and the mapping relationship between the query intent and the access priorities of the preset memory layers at each level, determine the access priorities of the memory layers at each level corresponding to the target query intent.
[0087] The specific implementation process of step S302 is similar to that of step S102. For details, please refer to the specific implementation process of step S102.
[0088] S303. Based on the target query intent and the mapping relationship between the query intent and the weights of the multi-way retrieval methods, determine the weights of the multi-way retrieval methods corresponding to the target query intent.
[0089] To retrieve highly relevant memory data and improve the accuracy of search results, this embodiment employs a multi-path hybrid retrieval architecture, integrating multiple complementary retrieval mechanisms to address information needs across different dimensions, including semantic understanding, keyword matching, structured reasoning, and time sensitivity. This multi-path retrieval method includes at least two of the following: dense retrieval, sparse retrieval, graph retrieval, and time-series retrieval.
[0090] Dense retrieval, primarily based on deep semantic encoding models (such as Sentence-BERT and ColBERT), maps user queries and memory fragments to high-dimensional vector spaces, capturing implicit semantic relationships through vector similarity calculation. This approach excels at handling synonym substitution, semantic generalization, and ambiguous contextual expressions, making it suitable for understanding implied meanings.
[0091] Sparse retrieval employs traditional information retrieval methods (such as the BM25 algorithm) to precisely match keywords (such as names, locations, dates, and specific terms) based on term frequency and inverse document frequency. Its advantages lie in its high recall and interpretability for entities, proper nouns, and key facts.
[0092] Graph retrieval refers to using a pre-constructed personal or domain knowledge graph to perform multi-hop reasoning through nodes (entities) and edges (relationships). For example, starting from "restaurants frequently visited by users," it can explore "the business district" → "nearby subway stations" → "commuting routes" to achieve cross-entity association mining, which is suitable for complex logical deduction.
[0093] Time-series retrieval, by introducing a time window constraint mechanism, filters memory fragments based on the timestamps of events. For example, it can retrieve only records from the past 7 days to respond to "What did you do recently?", or focus on the next 30 days to support schedule prediction. This retrieval method can effectively eliminate time-irrelevant noise and improve the accuracy of time-sensitive tasks.
[0094] Differentiated weighting strategies can be preset for different types of query intents to guide the fusion of multi-path search results. Specifically: When the target query intent is a factual query intent, since users are interested in clear and specific historical facts (such as "What time did my last meeting end?"), dense search has the highest weight. When the target query intent is a reasoning query intent, since this type of query requires logical inference by integrating information from multiple sources (such as "recommend weekend activities based on my diet and exercise habits"), dense retrieval can help understand the deep semantics of user preferences and behavioral descriptions, while graph retrieval can mine cross-domain associations such as "diet-health-activity" through knowledge graphs to support multi-step reasoning. Therefore, dense retrieval and graph retrieval have the highest weight.
[0095] When the target query intent is sentiment-based, this type of query intent focuses on the user's expressed emotions or psychological state (such as "I've been feeling very tired lately"), emphasizing empathy and contextual understanding. Since emotional expression is often subtle and unstructured, dense retrieval is given the highest weight to capture implicit emotional signals from tone, emotional vocabulary, and context.
[0096] When the target query intent is a predictive query intent, since such queries are future-oriented, trend judgments or risk warnings need to be made based on historical patterns (e.g., "Will I exceed my budget next month?"). Graph retrieval is used to model causal or dependency relationships between variables (e.g., the "income-expenditure-savings" structure), while time series retrieval focuses on recent behavioral sequences to identify periodic or abnormal patterns. Therefore, graph retrieval and time series retrieval have the highest weight.
[0097] S304. Based on the access priority of each memory layer and the weight of the multi-way retrieval method, a retrieval is performed in each memory layer to obtain memory data related to the target query intent.
[0098] In some embodiments, the specific implementation process of step S304 further includes the following steps b1-b4: Step b1: According to the access priority of each memory layer from high to low, search each memory layer in turn using a multi-way search method to obtain the sorting results of each memory segment in that memory layer under each search method.
[0099] As mentioned earlier, when the query intent is a fact query, the access priority of each memory layer is as follows: L3 and L4 have higher access priority than other memory layers. Therefore, this step first uses a multi-way retrieval method in the L3 layer to obtain the sorted results of each memory segment in L3 under the multi-way retrieval method, and then uses a multi-way retrieval method in the L4 layer to obtain the sorted results of each memory segment in L4 under the multi-way retrieval method; or, first uses a multi-way retrieval method in the L4 layer to obtain the sorted results of each memory segment in L4 under the multi-way retrieval method; then uses a multi-way retrieval method in the L3 layer to obtain the sorted results of each memory segment in L3 under the multi-way retrieval method.
[0100] When the query intent is a reasoning query, the access priority of each memory layer is as follows: retrieval is performed in layers L2-L5, with a focus on layers L4 and L3. Therefore, this step first uses a multi-way retrieval method in layer L4 to obtain the ranking results of each memory segment in L4 under the multi-way retrieval method; then, a multi-way retrieval method is used in layer L3 to obtain the ranking results of each memory segment in L3 under the multi-way retrieval method; then, a multi-way retrieval method is used in layers L2 and L5 in sequence to obtain the ranking results of the memory segments in each layer under the multi-way retrieval method.
[0101] When the query intent is a sentiment query, the access priority of each memory layer is as follows: L3 and L5 have higher access priority than other memory layers. Therefore, this step first uses a multi-way retrieval method in the L3 layer to obtain the ranking results of each memory segment in L3 under the multi-way retrieval method; then, it uses a multi-way retrieval method in the L5 layer to obtain the ranking results of each memory segment in L5 under the multi-way retrieval method; or, it first uses a multi-way retrieval method in the L5 layer to obtain the ranking results of each memory segment in L5 under the multi-way retrieval method; then, it uses a multi-way retrieval method in the L3 layer to obtain the ranking results of each memory segment in L3 under the multi-way retrieval method.
[0102] When the query intent is a predictive query type, the access priority of each memory layer is as follows: L4 and L2 have higher access priority than other memory layers. Therefore, this step first uses a multi-way search method in the L4 layer to obtain the sorted results of each memory segment in L4 under the multi-way search method; then, it uses a multi-way search method in the L2 layer to obtain the sorted results of each memory segment in L2 under the multi-way search method; or, it first uses a multi-way search method in the L2 layer to obtain the sorted results of each memory segment in L2 under the multi-way search method; then, it uses a multi-way search method in the L4 layer to obtain the sorted results of each memory segment in L4 under the multi-way search method.
[0103] Step b2: For each memory segment in each memory segment of this memory layer, determine the comprehensive ranking result of the memory segment based on the ranking result of the memory segment under the multi-way retrieval method and the weight of the multi-way retrieval method corresponding to the target query intent.
[0104] In this step, for the current memory layer, the ranking results of each memory segment in the memory layer under the multi-way retrieval method can be fused by the weight of the multi-way retrieval method corresponding to the target query intent, thereby obtaining the comprehensive ranking result of each memory segment in the memory layer. Taking four-way retrieval as an example, this process can be expressed as the following formula (1): (1) In the formula, d is the number of the memory segment; This is the comprehensive sorting result of memory fragment d; The sorting result of memory fragment d under the i-th retrieval method; For smoothing parameters; The weight corresponding to the i-th retrieval method; These correspond to dense search, sparse search, graph search, and time-series search, respectively.
[0105] For example, suppose a user asks, "Have I been staying up late a lot lately?", the intent classification model determines that the target query intent is a fact query. Based on the aforementioned rules, the corresponding multi-path retrieval weights are: Dense: 0.5; Sparse: 0.3; Graph: 0.1; Temporal: 0.1. The access priority of each memory layer is: L3 and L4 are higher than other layers, meaning retrieval is preferentially performed in L3 and L4.
[0106] Suppose that three relevant memory fragments are retrieved in layer L3, numbered d=1, 2, and 3. Assuming a smoothing coefficient of 0.01, the comprehensive scores for these three relevant memory fragments can be calculated using formula (1) as 0.755, 0.606, and 0.205 respectively. Therefore, the overall ranking of these three relevant memory fragments is d=1>d=2>d=3.
[0107] Step b3: Based on the comprehensive sorting results of each memory fragment in this memory layer, determine the memory fragment retrieved in this memory layer.
[0108] Specifically, the top K memory segments from the comprehensive ranking results can be selected as the memory segments retrieved in the current memory layer. The value of K can be selected according to the actual situation, such as 2 or 3.
[0109] Referring again to the example in step b2, assuming K=2, then d=1 and d=2 are selected as the final search results in layer L3.
[0110] Assuming the same approach is used, the final search results obtained in layer L4 are e=1 and e=2.
[0111] Step b4: Merge the memory fragments retrieved from each level of memory layer to obtain memory data related to the target query intent.
[0112] Referring again to the example in step b2, this step obtains memory data related to the fact query category intent by merging the memory fragments d=1, d=2, e=1, and e=2 from the retrieval results in layers L3 and L4.
[0113] S305. Generate response content to user questions based on the stored data.
[0114] The specific implementation process of step S305 is similar to that of step S104; for details, please refer to the specific implementation process of step S104.
[0115] This embodiment improves the accuracy of search results and the accuracy of response content by combining the weights of multiple retrieval methods and comprehensively ranking the results.
[0116] Figure 4 A flowchart illustrating the method for constructing memory layers at various levels as provided in the embodiments of this application. Figure 4 As shown, the construction method of each memory layer includes the following steps S401-S403: S401. Upon receiving the current message, store the current message in the first memory layer and the second memory layer.
[0117] When a new current message initiated by a user is received, it is first received through a first-in-first-out queue and stored in the first memory layer (L1) and the second memory layer (L2). The L1 layer serves as a temporary storage area for the raw data and does not perform deep semantic processing on the current message. The L2 layer, on the other hand, uses this current message to support the smooth operation of the current session.
[0118] S402. Determine the boundary indicator value corresponding to the current message; this boundary indicator value is used to characterize the degree of association between the current message and the current session.
[0119] This step aims to determine the boundary indicator values for the current message in order to determine whether it belongs to a new session or the current session.
[0120] In some embodiments, when determining the boundary indicator value corresponding to the current message in step S402, the following steps c1-c2 are specifically included: Step c1: Determine the time interval influence coefficient, topic shift degree, and absolute value of sentiment polarity change between the target message and historical messages.
[0121] Among them, the influence coefficient of the time interval between the target message and the historical message can be calculated using the exponential decay function to determine the degree of influence of the time interval on the continuity of the topic, as shown in formula (2): (2) In equation (2), The influence coefficient of the time interval between the target message and historical messages; The time interval between the target message and historical messages; This is the attenuation coefficient, which can be 0.1.
[0122] The degree of topic shift between the target message and the historical message can be obtained by extracting their semantic vector representations using a pre-trained language model, and then calculating the degree of topic shift in the semantic space using cosine similarity, as shown in formula (3): (3) In the formula, The degree of topic shift between the target message and historical messages in the semantic space; This is a historical message; This is a new message.
[0123] Among them, the absolute value of the change in emotional polarity between the target message and the historical message can capture significant changes in the emotional state in the dialogue and serve as an auxiliary basis for judging topic transitions. Specifically, it can be calculated using the following formula (4): (4) In the formula, This represents the absolute value of the change in sentiment polarity between the target message and historical messages. The sentiment polarity score of historical messages, typically in the range of [-1, 1]; The emotional polarity score of the new message.
[0124] Step c2: Determine the boundary index value of the target message based on the weighted sum of the influence coefficient of the time interval between the target message and historical messages, the degree of topic shift, and the absolute value of the change in sentiment polarity.
[0125] The weights corresponding to the time interval influence coefficient between the target message and historical messages, the degree of topic shift, and the absolute value of the change in sentiment polarity are w1, w2, and w3, respectively. By weighting and summing the time interval influence coefficient between the target message and historical messages, the degree of topic shift, and the absolute value of the change in sentiment polarity using w1, w2, and w3, the boundary index value of the target message can be obtained.
[0126] In some examples, w1, w2, and w3 can take values of 0.3, 0.5, and 0.2, respectively.
[0127] S403. If the boundary index value is greater than the preset index value, then according to the information abstraction level corresponding to the third memory layer, the fourth memory layer and the fifth memory layer, information is extracted from the current session to obtain the information extraction results corresponding to the third memory layer, the fourth memory layer and the fifth memory layer respectively, and stored in the third memory layer, the fourth memory layer and the fifth memory layer respectively.
[0128] When the boundary indicator value is less than or equal to the preset indicator value, it means that the current message belongs to the current session, and it can be merged into the current session. When the boundary indicator value is greater than the preset indicator value, it means that the current message belongs to a new topic. At this time, it is necessary to further extract information from the current session (i.e., messages that have not been stored in memory before the current message) according to the information abstraction levels corresponding to the third, fourth, and fifth memory layers, and obtain the information extraction results corresponding to the third, fourth, and fifth memory layers, including the following steps d1-d4: Step d1: Identify the entity and fact triples of the current session.
[0129] This step aims to identify entities with specific semantic categories from the current session, such as names, locations, times, organizations, and products. Specifically, this can be achieved by using a pre-trained language model for entity recognition or by extracting entities from the current session using regular expressions.
[0130] Among them, the fact triple refers to the structured triple extracted from a single sentence, namely the subject, predicate, and object.
[0131] Step d2: Generate at least one scenario summary based on the current conversation and its corresponding entity and fact triples using the large language model, and store it in the third memory layer.
[0132] Specifically, the original content of the current conversation and the entity and fact triples extracted in step d1 can be input into the large language model, and combined with designed prompts, so that the large language model can generate at least one scenario summary based on the above input data. This scenario summary refers to the 5W1H mentioned above, namely, time, place, person, event, reason, and manner.
[0133] The generated scenario summary will be written to the third memory layer L3 and persistently stored as an event episode with complete context and metadata.
[0134] Step d3: Based on the current conversation and its corresponding entity and fact triples, identify the conversation topic of the current conversation using the large language model, and store it in the fourth memory layer.
[0135] Specifically, the original content of the current conversation, the entities extracted in step d1, and the fact triples can be used as contextual input. Combined with designed prompts, this guides the large language model to perform semantic induction and topic clustering, thereby identifying the core topic or intent category of the current conversation. This conversation topic should be abstract and generalizable, able to transcend specific dialogue details, and reflect the user's long-term interests or types of affairs.
[0136] For example, given the conversation "I'm going on a business trip to city A next week and need to book a hotel for the night of the 22nd," the large language model can generate a conversation topic such as "travel arrangements" or "travel booking" by combining the extracted triples (me, business trip location, city A), (business trip time, yes, next week), and (need to book, hotel, night of December 22nd). This topic is then stored in the fourth memory layer (L4, semantic memory layer) to build a user preference tagging system, support cross-conversation topic associations (e.g., multiple occurrences of "travel arrangements" can infer that the user is a frequent business traveler), and provide semantic anchors for subsequent inference queries or proactive services.
[0137] Step d4: Based on the current conversation and its corresponding entity and fact triples, determine the user profile data using the large language model and store it in the fifth memory layer.
[0138] Specifically, the current conversation content, the entity and fact triples extracted in step d1, can be input into the large language model. Coupled with prompt word templates (such as "Based on the following interaction content, infer the user's long-term characteristics, values, or behavioral tendencies"), the model is driven to extract stable, representative, and identity-identifying user profile elements from the current dialogue. This profile data transcends single events, reflecting the user's intrinsic attributes, including: personality traits (such as "efficiency-conscious," "preference for advance planning"), life roles (such as "project leader," "new parent"), long-term goals (such as "planning to study abroad next year," "hoping to improve sleep"), and values (such as "emphasis on environmental protection," "pursuit of work-life balance").
[0139] For example, if a user repeatedly mentions "minimizing carbon footprint" and "choosing public transportation," combined with relevant triples (user, preference, environmentally friendly travel), the large language model can infer that their profile label is "an environmentally conscious consumer." This type of profile data is persistently stored in the fifth memory layer, L5.
[0140] In some embodiments, when storing corresponding data at each memory layer, a pre-trained large language model (such as BERT, GPT, etc.) can be used to encode the corresponding message data into a high-dimensional dense vector before storage. This vector can capture the deep semantic features of memory, supporting efficient semantic similarity calculation and retrieval.
[0141] Furthermore, to optimize storage at each memory layer level, this embodiment can also set a forgetting mechanism for each session, determine the forgetting strategy for each session at each memory layer based on the forgetting mechanism, and dynamically adjust the retention time and access weight of the session content at each memory layer according to the strategy. This mechanism not only helps control storage overhead but also simulates the natural law of "use it or lose it" in biological memory, thereby focusing on truly important or frequently used knowledge.
[0142] In some embodiments, the method of this embodiment may further include: determining the importance score of the current session; constructing an information decay model of the current session based on the importance score of the current session; the information decay model is used to characterize the degree of information retention of the current session by each level of memory layer over time.
[0143] Among them, the information decay model of the current session simulates the biological forgetting curve and is adaptively adjusted in combination with the importance score of the current session, which can be expressed as the following formula (5): (5) In the formula, The degree of memory retention at time t; The initial memory strength is 1; t is the time interval since the memory was formed. I is the time decay constant used to control the basic decay rate; I is the information importance score. .
[0144] It can be seen that the higher the importance score of the memory data, the slower the decay. When I is close to 1, the exponent (1-I) is close to 0, which slows down the decay rate; when I is close to 0, the exponent (1-I) is close to 1, and the decay rate speeds up.
[0145] The determination of the importance score of the current session includes: identifying at least two of the following factors: emotional intensity factor, user engagement factor, novelty factor, and goal relevance factor; and determining the importance score of the current session based on the weighted sum of at least two of these factors. The emotional intensity factor represents the intensity of emotional expression in the current session; the user engagement factor represents the degree of active attention the user pays to the current session; the novelty factor represents the frequency of occurrence of information contained in the current session in historical interactions; the novelty factor is negatively correlated with the frequency of occurrence; and the goal relevance factor represents the semantic relevance between the content of the current session and the continuous interaction goal reflected by the user's preset intent identifier or historical behavior pattern.
[0146] In this embodiment, the Emotional Intensity factor is used to measure the intensity of emotions (such as anger, joy, anxiety, etc.) expressed by the user in a conversation. It can be quantified using a sentiment analysis model (such as a fine-grained sentiment classifier based on RoBERTa). The stronger the emotion, the deeper the memory, and the higher the weight of this factor.
[0147] User engagement reflects a user's level of active participation in a conversation, such as whether they initiate topics, ask follow-up questions, or use emphasis words (e.g., "very important" or "remember this"). Actively interacting content has a higher memory priority than passively received push notifications.
[0148] The novelty factor characterizes the frequency with which information in the current session appears in the user's historical interactions. This factor is negatively correlated with frequency: locations, people, events, or opinions mentioned for the first time have higher information gain and therefore higher novelty scores; repeated content is gradually weighted lower.
[0149] Goal Relevance measures the semantic relevance of conversation content to a user's long-term intent and pre-set goals. For example, if a user has set "improving English proficiency" as a goal, conversations containing "exam preparation" and "foreign teacher courses" will receive a high relevance score. This factor is calculated by semantically matching the user profile stored in layer L5 (autobiographical memory).
[0150] After constructing the aforementioned information decay model for each session content, the memory fragments related to that session content stored in each level of memory layer will dynamically adjust their memory strength or retrieval weight according to the decay law defined by the information decay model, thereby achieving gradual information decay over time.
[0151] This dynamic management mechanism based on the information decay model enables the memory storage structure to retain high-value, highly relevant core information for a long time, while automatically forgetting redundant or outdated details, thereby maintaining efficient, accurate, and biologically cognitive memory operation with limited resources.
[0152] The memory construction process, memory retrieval, and reasoning process of this embodiment will be described below with specific examples: In this example, suppose a user says to the AI assistant on Friday night: "I'm so tired from work today, and I had a fight with my boss, but I'm going to Paris for vacation next week, so I'm feeling a little better." The message is first received through L1, and the current session context is maintained through L2. Simultaneously, topic boundary detection is performed on the message using TABD.
[0153] Assuming that, in terms of semantic signals, a significant difference is detected between the current message and the previous conversation about "weather"; and in terms of emotional signals, a strong mixed emotion is detected, namely, both negative emotions (tired, arguing) and positive emotions (vacation), then it is determined to be a new topic boundary, triggering the conversation end and memory storage process.
[0154] Subsequently, information was extracted from the ended sessions, yielding the following content: Context level (L3): Store the following events: "Arguing with the boss" (Time: Friday, Reason: Tired of work) and "Planning to go to Paris" (Time: Next week).
[0155] Semantic level (L4): Extracting preferences such as "users' stress relief methods may include travel".
[0156] Autobiographical Level (L5): (If it occurs multiple times) Update the user profile "Occupational Characteristics: May be in a high-pressure work environment".
[0157] Next, the extracted information will be vectorized and stored in the corresponding memory layer, while an information decay model will be constructed for it. Because this conversation contains strong emotional expressions (tiredness, arguing) and clear future plans (Paris), the importance score of this memory is high, and the decay rate is dynamically adjusted to ensure long-term preservation.
[0158] Suppose a week later, a user asks, "What luggage should I pack?" The first step is intent analysis to identify whether the user's question falls under the "inferential" or "predictive" category, requiring a comprehensive inference based on the user's travel plans, personal habits, and external environmental information.
[0159] Then, multi-way retrieval is performed in each memory layer, specifically including: Keyword matching (sparse retrieval) was used to find keywords such as "luggage" and "preparation".
[0160] By locating the time window of "next week" (i.e., the current time) through time-series retrieval, the "go to Paris" event stored in L3 is matched.
[0161] The "user's fear of cold" preference in the L4 layer was hit through semantic retrieval (dense retrieval) (assuming it was stored before).
[0162] At this point, the preliminary results included: "Going to Paris" (L3) and "Afraid of the cold" (L4). However, the Memory Coverage and Relevance Evaluation (MCRE) module determined that the current information was still insufficient—local weather information for Paris was missing.
[0163] Therefore, the system automatically generates a supplementary query: "Paris weather next week". It also calls external tools or searches a knowledge base to obtain the query: "Paris will be rainy next week, with a temperature of 10 degrees Celsius".
[0164] Based on this, ECR inference is performed: Evidence 1: The user is going to Paris (Source: L3 Contextual Memory).
[0165] Evidence 2: Paris will experience rain and low temperatures next week (Source: Supplementary search).
[0166] Evidence 3: Users are afraid of the cold (Source: L4 semantic memory).
[0167] Reasoning chain: Going to Paris + cold weather + user is afraid of the cold -> need to bring warm clothes; raining -> need to bring an umbrella.
[0168] Finally, a personalized reply was generated: "I remember you mentioned last week that you were going to Paris for vacation. Since you're sensitive to the cold, and the temperature in Paris next week will only be around 10 degrees Celsius and it will be rainy, I suggest you bring a thick coat, scarf, and rain gear. Have a pleasant trip and forget about your work worries!" In summary, the embodiments of this application have the following beneficial effects: (1) By using a hierarchical memory architecture, specific “events” and abstract “semantics” are separated, so that the model can remember the specific event “I ate hot pot last Wednesday” and also understand the preference information “user likes spicy food” which is abstracted from the aforementioned specific event, thereby significantly improving the depth of personalized services.
[0169] (2) By combining multi-dimensional signals such as time, semantics and sentiment for topic boundary detection, compared with traditional segmentation based on fixed rules, it can avoid confusion of cross-topic memory, improve the accuracy of boundary detection, and optimize the quality of stored data.
[0170] (3) During the retrieval process, missing information can be automatically supplemented, which significantly reduces the error in the response caused by incomplete retrieval and improves the accuracy of the response.
[0171] (4) By outputting the chain of evidence, users can clearly understand which specific past memory data the AI's response is based on, thereby enhancing the credibility of the response and making it easier to check for errors.
[0172] (5) By introducing a time decay model based on importance scores, low-value trivial information can be automatically filtered out, key high-value memories can be retained, and the utilization rate of storage space can be optimized.
[0173] Exemplary device Corresponding to the question-and-answer processing method described above, this application also provides a question-and-answer processing device. Figure 5 This is a schematic diagram of the structure of a question-and-answer processing device provided in an embodiment of this application. Figure 5As shown in the embodiment of this application, the question-and-answer processing device includes: an intent classification module 501, a determination module 502, a retrieval module 503, and a generation module 504; wherein, the intent classification module 501 is used to classify the intent according to the acquired user question to obtain the target query intent corresponding to the user question; the determination module 502 is used to determine the access priority of the memory layer corresponding to the target query intent according to the target query intent and the mapping relationship between the query intent and the access priority of the preset memory layer at each level; the memory layer at each level is a hierarchical storage structure that stores the user's historical conversation messages in order of increasing information abstraction level; the retrieval module 503 is used to retrieve memory data related to the target query intent by searching in the memory layer at each level according to the access priority of the memory layer at each level; the generation module 504 is used to generate the response content to the user question according to the memory data.
[0174] In some embodiments, the determining module 502 is further configured to: determine the weight of the multi-way retrieval method corresponding to the target query intent based on the target query intent and the mapping relationship between the query intent and the weight of the multi-way retrieval method; the multi-way retrieval method includes at least two of dense retrieval, sparse retrieval, graph retrieval, and time-series retrieval; wherein, the retrieval module 503 performs retrieval in each level of memory layer according to the access priority of each level of memory layer to obtain memory data related to the target query intent, including: sequentially targeting each level of memory layer in descending order of access priority. A multi-path retrieval method is used to search within this level of memory layer, obtaining the ranking results of each memory segment in this level of memory layer under each retrieval method. For each memory segment in each memory segment of this level of memory layer, based on the ranking result of the memory segment under the multi-path retrieval method and the weight of the multi-path retrieval method corresponding to the target query intent, the comprehensive ranking result of the memory segment is determined. Based on the comprehensive ranking result of each memory segment in this level of memory layer, the memory segments retrieved in this level of memory layer are determined. The memory segments retrieved in each level of memory layer are merged to obtain memory data related to the target query intent.
[0175] In some embodiments, the memory layers at each level include a first memory layer, a second memory layer, a third memory layer, a fourth memory layer, and a fifth memory layer; the memory layers at each level are constructed using the following steps: upon receiving a current message, the current message is stored in the first memory layer and the second memory layer; a boundary index value corresponding to the current message is determined; the boundary index value is used to characterize the degree of association between the current message and the current session; if the boundary index value is greater than a preset index value, information is extracted from the current session according to the information abstraction levels corresponding to the third memory layer, the fourth memory layer, and the fifth memory layer, to obtain the information extraction results corresponding to the third memory layer, the fourth memory layer, and the fifth memory layer respectively, and stored in the third memory layer, the fourth memory layer, and the fifth memory layer respectively.
[0176] In some embodiments, determining the boundary index value of the target message includes: determining the time interval influence coefficient, topic shift degree, and absolute value of sentiment polarity change between the target message and historical messages; and determining the boundary index value of the target message based on the weighted summation result of the time interval influence coefficient, topic shift degree, and absolute value of sentiment polarity change between the target message and historical messages.
[0177] In some embodiments, the step of extracting information from the current session based on the information abstraction levels corresponding to the third, fourth, and fifth memory layers to obtain the information extraction results corresponding to each of the third, fourth, and fifth memory layers includes: identifying entity and fact triples of the current session; generating at least one scenario summary based on the current session and its corresponding entity and fact triples using a large language model, and storing it in the third memory layer; identifying the session topic of the current session based on the current session and its corresponding entity and fact triples using a large language model, and storing it in the fourth memory layer; and determining user profile data based on the current session and its corresponding entity and fact triples using a large language model, and storing it in the fifth memory layer.
[0178] In some embodiments, the determining module 502 is further configured to: determine the importance score of the current session; construct an information decay model of the current session based on the importance score of the current session; the information decay model is used to characterize the degree of information retention of the current session by each level of memory layer over time.
[0179] In some embodiments, the determining module 502 determines the importance score of the current session, including: determining at least two of the following: an emotional intensity factor, a user engagement factor, a novelty factor, and a goal relevance factor; and determining the importance score of the current session based on a weighted sum of at least two of the following: emotional intensity factor, user engagement factor, novelty factor, and goal relevance factor. The emotional intensity factor represents the intensity of the emotional expression in the current session; the user engagement factor represents the degree of active attention the user pays to the current session; the novelty factor represents the frequency of occurrence of information contained in the current session in historical interactions; the novelty factor is negatively correlated with the frequency of occurrence; and the goal relevance factor represents the semantic relevance between the content of the current session and the continuous interaction goal reflected by the user's preset intent identifier or historical behavior pattern.
[0180] In some embodiments, the generation module 504 generates a response to the user's question based on the memory data, including: if the memory data does not meet the required information conditions for responding to the user's question, identifying the missing information type; performing a supplementary query based on the missing information type to obtain a supplementary query result; if the supplementary query result and the memory data meet the required information conditions for responding to the user's question, generating a response to the user based on the memory data and the supplementary query result.
[0181] In some embodiments, the memory data includes multiple memory segments; wherein, the generation module 504 generates a response to the user's question based on the memory data, including: determining the relevance between the multiple memory segments and the user's question; sorting the multiple memory segments in descending order based on the relevance, and determining the logical association between the sorted multiple memory segments; generating a structured chain of evidence based on the logical association between the multiple memory segments; the structured chain of evidence includes at least two of the following: the content of the multiple memory segments, information source identifier, reasoning basis, and confidence level; and generating a response to the user's question and explanatory evidence based on the structured chain of evidence.
[0182] The question-and-answer processing device provided in this embodiment belongs to the same concept as the question-and-answer processing method provided in the above embodiments of this application. It can execute the question-and-answer processing method provided in any of the above embodiments of this application and has the corresponding functional modules and beneficial effects for executing the question-and-answer processing method. Technical details not described in detail in this embodiment can be found in the specific processing content of the question-and-answer processing method provided in the above embodiments of this application, and will not be repeated here.
[0183] The functions implemented by the intent classification module 501, determination module 502, retrieval module 503 and generation module 504 can be implemented by the same or different processors, and this application embodiment does not limit them.
[0184] It should be understood that the units in the above device can be implemented by a processor calling software. For example, the device includes a processor connected to a memory containing instructions. The processor calls the instructions stored in the memory to implement any of the above methods or to implement the functions of each unit in the device. The processor can be a general-purpose processor, such as a CPU or microprocessor, and the memory can be internal or external to the device. Alternatively, the units in the device can be implemented as hardware circuits. By designing the hardware circuits, some or all of the unit functions can be implemented. The hardware circuits can be understood as one or more processors. For example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are implemented by designing the logical relationships between the components within the circuit. In another implementation, the hardware circuit can be implemented using a PLD, such as an FPGA, which can include a large number of logic gates. The connection relationships between the logic gates are configured through configuration files to implement the functions of some or all of the above units. All units in the above device can be implemented entirely by a processor calling software, entirely by hardware circuits, or partially by a processor calling software with the remaining parts implemented by hardware circuits.
[0185] In this application embodiment, a processor is a circuit with signal processing capabilities. In one implementation, the processor can be a circuit with instruction reading and execution capabilities, such as a CPU, microprocessor, GPU, or DSP. In another implementation, the processor can implement certain functions through the logical relationships of hardware circuits. These logical relationships are fixed or reconfigurable. For example, the processor may be a hardware circuit implemented as an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document and configuring the hardware circuit can be understood as the processor loading instructions to implement the functions of some or all of the above units. Furthermore, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, or DPU.
[0186] As can be seen, each unit in the above device can be one or more processors (or processing circuits) configured to implement the above methods, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0187] Furthermore, the units in the above devices can be integrated in whole or in part, or they can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a System-on-Chip (SoC). The SoC may include at least one processor for implementing any of the above methods or implementing the functions of the units in the device. The at least one processor may be of different types, such as CPU and FPGA, CPU and artificial intelligence processor, CPU and GPU, etc.
[0188] Exemplary electronic devices This application provides an electronic device, see [link to relevant documentation] Figure 6 As shown, the electronic device includes: Memory 200 and processor 210; The memory 200 is connected to the processor 210 and is used to store programs; The processor 210 is configured to implement the question-and-answer processing method disclosed in any of the above embodiments by running the program stored in the memory 200.
[0189] Specifically, the aforementioned electronic device may also include: a bus, a communication interface 220, an input device 230, and an output device 240.
[0190] The processor 210, memory 200, communication interface 220, input device 230, and output device 240 are interconnected via a bus. Among them: A bus can include a pathway for transmitting information between various components of a computer system.
[0191] Processor 210 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0192] Processor 210 may include a main processor, as well as a baseband chip, modem, etc.
[0193] The memory 200 stores a program that executes the technical solution of this invention, and may also store an operating system and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory 200 may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, flash memory, etc.
[0194] Input device 230 may include a device for receiving user input data and information, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.
[0195] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0196] The communication interface 220 may include a device that uses any transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0197] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement each step of any of the question-and-answer processing methods provided in the above embodiments of this application.
[0198] This application also proposes a chip including a processor and a data interface. The processor reads and runs a program stored in a memory through the data interface to execute the question-and-answer processing method described in any of the above embodiments. For details of the processing and its beneficial effects, please refer to the above-described embodiments of the question-and-answer processing method.
[0199] Exemplary computer program products and storage media In addition to the methods and devices described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the question-and-answer processing methods according to various embodiments of this application as described in any of the above embodiments of this specification.
[0200] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this application. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0201] Furthermore, embodiments of this application may also be storage media storing a computer program, which is executed by a processor of the steps in the question-and-answer processing method according to various embodiments of this application as described in any of the foregoing embodiments of this specification.
[0202] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0203] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0204] The steps in the methods of the various embodiments of this application can be adjusted, merged, or deleted in order according to actual needs, and the technical features described in each embodiment can be replaced or combined.
[0205] The modules and sub-modules in the various embodiments of the present application's devices and terminals can be merged, divided, and deleted according to actual needs.
[0206] It should be understood that the disclosed terminals, devices, and methods can be implemented in other ways, given the several embodiments provided in this application. For example, the terminal embodiments described above are merely illustrative. For instance, the division of modules or sub-modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0207] The modules or submodules described as separate components may or may not be physically separate. The components that constitute a module or submodule may or may not be physical modules or submodules; that is, they may be located in one place or distributed across multiple network modules or submodules. Some or all of the modules or submodules can be selected to achieve the purpose of this embodiment's solution, depending on actual needs.
[0208] Furthermore, the functional modules or sub-modules in the various embodiments of this application can be integrated into one processing module, or each module or sub-module can exist physically separately, or two or more modules or sub-modules can be integrated into one module. The integrated modules or sub-modules described above can be implemented in hardware or in the form of software functional modules or sub-modules.
[0209] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0210] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software unit executed by a processor, or a combination of both. The software unit can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0211] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0212] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A question-and-answer processing method, characterized in that, include: The intent is categorized based on the obtained user questions to obtain the target query intent corresponding to the user questions; Based on the target query intent and the mapping relationship between the query intent and the access priorities of the preset memory layers at each level, the access priorities of the memory layers at each level corresponding to the target query intent are determined. The memory layers at each level are a hierarchical storage structure that stores users' historical session messages in order of increasing information abstraction. Based on the access priority of each memory layer, a search is performed in each memory layer to obtain memory data related to the target query intent; Based on the memory data, a response to the user's question is generated.
2. The method according to claim 1, characterized in that, The method further includes: Based on the target query intent and the mapping relationship between the query intent and the weights of the multi-way retrieval methods, the weights of the multi-way retrieval methods corresponding to the target query intent are determined; the multi-way retrieval methods include at least two of dense retrieval, sparse retrieval, graph retrieval, and time-series retrieval. Specifically, based on the access priority of each memory layer, retrieval is performed in each memory layer to obtain memory data related to the target query intent, including: According to the access priority of each memory layer from high to low, the multi-way retrieval method is used to search each memory layer in turn to obtain the sorting result of each memory segment in the memory layer under each retrieval method. For each memory segment in each memory segment of this memory layer, the comprehensive ranking result of the memory segment is determined based on the ranking result of the memory segment under the multi-way retrieval method and the weight of the multi-way retrieval method corresponding to the target query intent. Based on the comprehensive sorting results of the memory segments described in this memory layer, the memory segments retrieved in this memory layer are determined; The memory fragments retrieved from each level of memory layer are merged to obtain memory data related to the target query intent.
3. The method according to claim 1, characterized in that, The memory layers at each level include a first memory layer, a second memory layer, a third memory layer, a fourth memory layer, and a fifth memory layer; each memory layer is constructed using the following steps: Upon receiving the current message, the current message is stored in the first memory layer and the second memory layer; Determine the boundary indicator value corresponding to the current message; the boundary indicator value is used to characterize the degree of association between the current message and the current session; If the boundary index value is greater than the preset index value, then information is extracted from the current session according to the information abstraction level corresponding to the third memory layer, the fourth memory layer and the fifth memory layer, to obtain the information extraction results corresponding to the third memory layer, the fourth memory layer and the fifth memory layer respectively, and stored in the third memory layer, the fourth memory layer and the fifth memory layer respectively.
4. The method according to claim 3, characterized in that, Determining the boundary indicator value of the target message includes: Determine the time interval influence coefficient, topic shift degree, and absolute value of sentiment polarity change between the target message and historical messages; The boundary index value of the target message is determined by weighting and summing the influence coefficient of the time interval between the target message and historical messages, the degree of topic shift, and the absolute value of the change in sentiment polarity.
5. The method according to claim 3, characterized in that, The step of extracting information from the current session based on the information abstraction levels corresponding to the third, fourth, and fifth memory layers to obtain the information extraction results corresponding to each of the third, fourth, and fifth memory layers includes: Identify the entity and fact triples of the current session; Based on the current conversation and its corresponding entities and fact triples, at least one scenario summary is generated using a large language model and stored in the third memory layer. The large language model identifies the conversation topic of the current session based on the current session and its corresponding entity and fact triple, and stores it in the fourth memory layer; The user profile data is determined by the large language model based on the current session and its corresponding entity and fact triple, and stored in the fifth memory layer.
6. The method according to claim 3, characterized in that, The method further includes: Determine the importance score of the current session; Based on the importance score of the current session, an information decay model for the current session is constructed; the information decay model is used to characterize the degree to which the memory layers at each level retain information about the current session over time.
7. The method according to claim 6, characterized in that, Determining the importance score of the current session includes: Determine at least two of the following factors for the current session: emotional intensity factor, user engagement factor, novelty factor, and target relevance factor; The importance score of the current session is determined by weighted summation of at least two of the following factors: emotional intensity factor, user engagement factor, novelty factor, and target relevance factor. The emotional intensity factor represents the intensity of the emotional expression in the current session; the user engagement factor represents the degree of active attention the user pays to the current session; the novelty factor represents the frequency of occurrence of information contained in the current session in historical interactions; the novelty factor is negatively correlated with the frequency of occurrence; and the goal relevance factor represents the semantic relevance between the content of the current session and the continuous interaction goal reflected by the user's preset intent identifier or historical behavior pattern.
8. The method according to any one of claims 1-7, characterized in that, The step of generating a response to the user's question based on the memory data includes: If the memory data does not meet the information requirements for responding to the user's question, then identify the type of missing information; Based on the type of missing information, perform a supplementary query to obtain the supplementary query results; If the supplementary query results and the memory data meet the information requirements for replying to the user's question, then a reply to the user is generated based on the memory data and the supplementary query results.
9. The method according to any one of claims 1-7, characterized in that, The memory data includes multiple memory segments; The step of generating a response to the user's question based on the memory data includes: Determine the correlation between the plurality of memory fragments and the user's question; Based on the correlation, the multiple memory segments are sorted in descending order, and the logical relationships between the multiple memory segments after sorting are determined. Based on the logical relationships between the multiple memory fragments, a structured chain of evidence is generated; the structured chain of evidence includes at least two of the following: the content of the multiple memory fragments, information source identifiers, reasoning basis, and confidence level; Based on the structured chain of evidence, generate response content and explanatory evidence for the user's question.
10. An electronic device, characterized in that, Including memory and processor; The memory is connected to the processor and is used to store programs; The processor is configured to implement the method as described in any one of claims 1 to 9 by running a program in the memory.
11. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method as described in any one of claims 1 to 9.
12. A computer program product, characterized in that, It includes computer program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1 to 9.