Intelligent question answering methods, devices, and storage media
By using tag-based memory management and a pre-set large language model, the problems of user preference tracking and context loss in complex dialogue scenarios of intelligent question-answering systems are solved, achieving personalized question-answering experience and interactive continuity.
Patent Information
- Application Number
- CN202510875489.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-06-27
AI Technical Summary
Existing intelligent question-answering systems struggle to dynamically track and update users' long-term preferences in complex dialogue scenarios, leading to deviations between generated content and actual user needs. Furthermore, interactions are often interrupted in multi-turn dialogues due to loss of context or logical breaks.
By using tag-based memory management and storing users' historical conversation information in a tag vector database, combined with a pre-set large language model, the question-and-answer roles, task objectives, and constraints are determined to generate personalized answers.
It enables long-term memory management of conversations, improves the relevance of answers to user preferences, enhances the user's question-and-answer experience, and ensures the continuity and accuracy of interaction.
Smart Images

Figure CN120371983B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and more particularly to an intelligent question-answering method, device, and storage medium. Background Technology
[0002] With the rapid development of artificial intelligence technology, intelligent agent question answering systems have become a core research direction in the field of human-computer interaction. Question answering systems based on large language models perform well in general scenarios, but still have significant shortcomings in complex dialogue scenarios.
[0003] Current intelligent question-answering systems generally rely on conversation history or short-term context management, making it difficult to dynamically track and update users' long-term preferences. Therefore, when user interests or needs change dynamically, they cannot efficiently identify key events and update user information, resulting in generated content that deviates from the user's actual needs or fails to meet their preferences. Furthermore, existing intelligent question-answering systems often experience interaction interruptions in multi-turn dialogues due to context loss or logical gaps. For example, traditional methods rely on fixed-window-length context caching (e.g., retaining only the most recent 5 rounds of dialogue), leading to long-term memory loss. Moreover, some retained conversation history often lacks depth in representing the user's personalized characteristics due to information redundancy or low relevance, making it difficult to generate highly appropriate responses based on context.
[0004] In view of this, the present invention is hereby proposed. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention provides an intelligent question-and-answer method, device, and storage medium that enables tagged memory of conversations, facilitating long-term maintenance and retrieval of historical memories, improving the relevance of answers to user preferences, and enhancing the user's question-and-answer experience.
[0006] This invention provides an intelligent question-answering method, which includes:
[0007] Based on the target question and the tag vector database of the target users corresponding to the target question, the target memory fragment is determined; wherein, the tag vector database is a database constructed based on historical sessions, containing each user's tag group, the historical tag information corresponding to each user's tag group, and factual semantic vectors;
[0008] Based on the target question, determine the question-and-answer roles and task objectives; based on the question-and-answer roles and task objectives, determine the basic instructions.
[0009] Based on the target memory fragment, determine the constraints and the corresponding reasoning guidance instructions;
[0010] Based on the basic instructions, constraints, and reasoning guidance instructions, determine the target answer corresponding to the target question.
[0011] This invention provides an electronic device, which includes:
[0012] Processor and memory;
[0013] The processor executes the steps of the intelligent question-answering method of any embodiment by calling a program or instruction stored in memory.
[0014] This invention provides a computer-readable storage medium that stores a program or instructions that cause a computer to perform the steps of any embodiment of the intelligent question-answering method.
[0015] The embodiments of the present invention have the following technical effects:
[0016] By using a target question and a tag vector database of the target user, target memory fragments are determined. These fragments store the target user's tag information and factual semantic vectors, achieving long-term memory management. Then, based on the target question, question-answering roles and task objectives are determined. Basic instructions are then established, along with constraints and corresponding reasoning guidance instructions, based on the target memory fragments. This allows for the retrieval of relevant content from long-term memory, increasing the constraints on the target question and improving the relevance of subsequent answers to the target user. Finally, based on the basic instructions, constraints, and reasoning guidance instructions, the target answer is determined. This process achieves tagged memory of the conversation, facilitating long-term maintenance and retrieval of historical memory, improving the alignment of answers with user preferences, and enhancing the user's question-answering experience. Attached Figure Description
[0017] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart of an intelligent question-answering method provided in an embodiment of the present invention;
[0019] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0021] The intelligent question-answering method provided in this invention is mainly applicable to situations where users' historical conversations are tagged and remembered, and personalized answers are given to user questions based on these tags. The intelligent question-answering method provided in this invention can be executed by an electronic device.
[0022] Example 1
[0023] Figure 1 This is a flowchart of an intelligent question-answering method provided in an embodiment of the present invention. See also... Figure 1 The intelligent question-answering method specifically includes:
[0024] S110. Based on the target question and the tag vector database of the target users corresponding to the target question, determine the target memory fragment.
[0025] The target question is a question posed by the target user and requires an answer. The target user is the user currently in the session. The tag vector database is a database bound to different users. It is built based on historical sessions and contains user tag groups, corresponding historical tag information, and factual semantic vectors. Historical sessions refer to all previous sessions of the target user. User tag groups are combinations of tags associated with the target user at various levels, such as: basic identity information - demographics - age, social and occupational - educational background - major, etc. Historical tag information stores information content corresponding to user tag groups. Factual semantic vectors are vector representations of statements from historical sessions used when extracting historical tag information. Target memory fragments are relevant historical memories extracted for the target question, namely, user tag groups related to the target question, corresponding historical tag information, and factual semantic vectors.
[0026] Specifically, the target problem can be analyzed based on a pre-set large language model to determine the relevant user tag groups. The determined user tag groups are then matched against the target user's tag vector database. Each user tag group, along with the corresponding historical tag information and factual semantic vectors obtained from the matching, are used as target memory fragments.
[0027] Based on the above example, the target memory fragment can be determined using the target question and the tag vector database of the target users corresponding to the target question, in the following way:
[0028] Based on the target question, determine at least one candidate label group corresponding to the target question;
[0029] Based on each candidate tag group, in the tag vector database of the target user corresponding to the target question, determine the candidate tag information and candidate fact vector corresponding to each candidate tag group respectively;
[0030] For each candidate label group, the candidate relevance is determined based on the candidate fact vector corresponding to the candidate label group and the question vector corresponding to the target question;
[0031] The relevance of each target is determined based on the relevance of each candidate, the relevance threshold, and the preset number of memories.
[0032] For each target relevance, the candidate label group corresponding to the target relevance is determined as the target label group, and the candidate label information and candidate fact vector corresponding to the target label group are used as target memory fragments.
[0033] Here, candidate label groups are the label groups related to the target question. Candidate label information and candidate fact vectors are historical label information and fact semantic vectors that correspond to the candidate label groups. The question vector is the vectorized representation of the target question. Candidate relevance is the relevance between the candidate fact vector and the question vector, such as cosine similarity. The relevance threshold is a pre-set minimum requirement for relevance when answering the target question. The preset memory count is a pre-set maximum number of target memory segments to be selected. Target relevance is the candidate relevance that simultaneously meets the relevance threshold and the preset memory count requirement. The target label group is the candidate label group corresponding to each target relevance, that is, the user label groups that are relatively relevant to the target question.
[0034] Specifically, the target question can be analyzed based on a pre-defined large language model to identify at least one user tag group related to the target question as a candidate tag group. Then, each candidate tag group is matched against the tag vector database of the target users corresponding to the target question to obtain the candidate tag information and candidate fact vectors for each candidate tag group. It is understood that not every candidate tag group will have corresponding candidate tag information and candidate fact vectors; if the database does not record them, the corresponding candidate tag information and candidate fact vectors can be considered empty. For each candidate tag group, relevance can be calculated. Specifically, the relevance between the candidate fact vector corresponding to the candidate tag group and the question vector corresponding to the target question is calculated as the candidate relevance for that candidate tag group. Candidate relevance values below a relevance threshold are deleted, and the number of remaining candidate relevance values is determined. If this number is greater than a pre-defined memory count, the remaining candidate relevance values are arranged in descending order, and the candidate relevance values at the top of the pre-defined memory count are retained as the target relevance. If this number is less than or equal to the pre-defined memory count, all remaining candidate relevance values are used as the target relevance. The candidate label groups corresponding to each target relevance are determined as target label groups. The candidate label information and candidate fact vectors corresponding to each target label group are integrated and used as target memory fragments.
[0035] For example, using a vector database-based storage architecture, the structured memory tags representing the user's personalization, extracted from the target user's historical conversations, are stored in the tag vector database as semantic vectors of unstructured data. Therefore, when a target user raises a new question, the database retrieves Top-K (preset number of) relevant memory fragments based on the current conversation. For instance, if a target user asks "Recommend a suitable breakfast for me," the database can be retrieved for memories related to "dietary preferences," "allergy history," and "recent health goals."
[0036] S120. Based on the target question, determine the question-and-answer roles and task objectives, and based on the question-and-answer roles and task objectives, determine the basic instructions.
[0037] The question-and-answer role is the persona used when answering the target question, making the answering process more professional. The task objective is a concise summary of the target question, which is the problem that the question-and-answer role needs to solve. The basic instructions are instructions obtained by substituting the question-and-answer role and the task objective into a preset format. In other words, they are instructions for the target role to execute the task objective, which is the content that the preset large language model needs to execute.
[0038] Specifically, the target question is analyzed based on a pre-defined large language model to determine the question-answering role and the task objective within the target question. Then, the question-answering role and task objective are combined according to a pre-defined format to obtain basic instructions.
[0039] S130. Based on the target memory fragment, determine the constraints and the corresponding reasoning guidance instructions.
[0040] The constraints are brief contents of the target memory fragment. The reasoning guidance instruction is to add a chain-of-thought instruction, which requires the pre-defined large language model to explicitly associate the content of the constraints.
[0041] Specifically, the content of the target memory fragment is converted into natural language according to a preset template, and then the constraints can be extracted. Based on the constraints, the need for chain thinking is added to obtain reasoning guidance instructions.
[0042] For example, the retrieved memory information (target memory fragment) is first converted into a natural language description according to a preset template. Then, prompt words are constructed through layered prompt word injection to guide the generation of a preset large language model. Layered prompt word injection includes: a. Basic instructions (defining the target role and task objective, such as "as a nutrition consultant, provide breakfast advice"); b. Memory context: inserting formatted memory information and clarifying generation constraints; c. Reasoning guidance: adding chain-thinking instructions, requiring the model to explicitly associate memory with generated content. Structured memory retrieval and reasoning guidance can reduce noise interference, and dynamically generated prompt words can adapt to different scenarios and user profiles.
[0043] For example: Natural language description of memory:
[0044] [User Memory]
[0045] - Dietary preference: Strict vegetarian
[0046] - Health goal: Lose 5 kg within three months (80% confidence level)
[0047] - Allergy history: Peanut allergy
[0048] Example of prompt words:
[0049] You are a nutrition consultant, recommending breakfast options based on a user's memory:
[0050] <User Memory>
[0051] {Memory formatted content}
[0052] < / User Memory>
[0053] Please think about it step by step:
[0054] 1. What are the user's core needs and limitations?
[0055] 2. Based on your memory of dietary preferences and health goals, choose appropriate ingredients;
[0056] 3. Ensure you avoid allergens and meet your weight loss requirements.
[0057] The final response must include a detailed recipe and nutritional analysis.
[0058] S140. Based on the basic instructions, constraints, and reasoning guidance instructions, determine the target answer corresponding to the target question.
[0059] The target answer is the response to the target question based on the target user's historical conversations.
[0060] Specifically, the basic instructions, constraints, and reasoning guidance instructions are integrated to obtain prompt words for the input pre-set large language model. The pre-set large language model analyzes based on the prompt words and outputs the target answer corresponding to the target question.
[0061] Based on the above example, the target answer to the target question can be determined using the basic instructions, constraints, and reasoning guidance instructions in the following way:
[0062] Based on the basic instructions, constraints, and reasoning guidance instructions, determine the target prompt words;
[0063] Input the target prompt words into a pre-set large language model to obtain candidate answers to the target question;
[0064] Based on a pre-defined large language model, determine whether candidate answers meet the constraints.
[0065] If so, the candidate answer will be taken as the target answer for the target question;
[0066] If not, then based on the preset large language model, generate modification suggestions corresponding to the candidate answers, update the target prompt words according to the candidate answers and modification suggestions, and return to execute the step of inputting the target prompt words into the preset large language model to obtain the candidate answers corresponding to the target question.
[0067] The target prompt is the content that the pre-defined large language model needs to analyze. The candidate answer is the output of the pre-defined large language model in response to the target prompt. The modification suggestion is a suggestion to modify the parts of the candidate answer that conflict with the constraints.
[0068] Specifically, the basic instructions, constraints, and reasoning guidance instructions are integrated to obtain target prompts. These target prompts are then input into a pre-defined large language model to obtain candidate answers to the target question. The candidate answers and constraints are then input into the pre-defined large language model to determine if the candidate answers meet the constraints, i.e., whether they match the target user's personalized tags. If so, it means there is no conflict with the target user's personalized tags, and the candidate answer can be directly used as the target answer for the target question. If not, based on the pre-defined large language model, the conflict between the candidate answer and the constraints is analyzed to obtain modification suggestions for the candidate answer. The candidate answer and modification suggestions are then added to the target prompts to obtain new target prompts. The process then returns to the step of inputting the target prompts into the pre-defined large language model to obtain candidate answers to the target question, facilitating a new reasoning process.
[0069] For example, during the model inference phase, attention correction techniques are employed, which adjust the attention mechanism using external memory information (constraints) to strengthen semantic regions related to user preferences. For instance, when generating "breakfast recommendations," the model automatically focuses on the activation patterns of neurons related to "vegetarian" and "weight loss." After inference is completed, generation verification techniques are used to automatically verify the consistency between the candidate answers generated by the model and the constraints. If a conflict is detected (such as recommending foods containing peanuts), regeneration is triggered until the consistency verification passes.
[0070] Building upon the above example, after determining the target answer to the target question, the tag vector database for the target user can be updated based on the current session. Specifically, this can be done by:
[0071] The current session is obtained, and based on the preset large language model, each factual information in the current session is determined. For each factual information, the current tag group corresponding to the factual information and the current tag information corresponding to each current tag group are determined.
[0072] Update the target user's tag vector database based on each current tag group, the current tag information corresponding to each current tag group, and the current fact vector corresponding to the fact information.
[0073] Here, "current session" refers to the session to which the target question and answer belong. "current tag group" is the tag group extracted from factual information within the current session. "current tag information" is a summary of the factual information within the current tag group. "current fact vector" is a vectorized representation of the factual information within the current session.
[0074] Specifically, the current session is acquired, and based on a pre-defined large language model, the factual information within the current session is analyzed. For each factual information, a tag group analysis and brief summary are performed to obtain the corresponding current tag groups and their corresponding current tag information. Then, using the current tag groups, their corresponding current tag information, and the current fact vectors corresponding to the factual information, the target user's existing tag vector database is adjusted and updated.
[0075] Based on the above example, the target user's tag vector database can be updated using the following method: (The database is updated based on each current tag group, the current tag information corresponding to each current tag group, and the current fact vector corresponding to the fact information.)
[0076] Based on the current tag groups, the current tag information, and the tag vector database of the target user, determine the tag processing strategy corresponding to the current tag group;
[0077] For each current label group, determine the corresponding current fact vector based on the fact information corresponding to the current label group;
[0078] Based on the tag processing strategy corresponding to the current tag group, the tag vector database of the target user is processed according to the current tag information and the current fact vector corresponding to the current tag group.
[0079] The tag processing strategy is the method used to merge the current tag group and its corresponding tag information with the target user's tag vector database. Tag processing strategies include adding, updating, deleting, and leaving unchanged.
[0080] Specifically, for each current tag group, the current tag group and its corresponding current tag information are matched against the target user's tag vector database to obtain the matching results. Based on different matching results, the tag processing strategy corresponding to the current tag group is determined. Further, for each current tag group, the fact information corresponding to the current tag group is vectorized to obtain the corresponding current fact vector. According to the tag processing strategy corresponding to the current tag group, the current tag information and current fact vector are organized into the target user's tag vector database for processing.
[0081] Based on the above example, the tag processing strategy corresponding to the current tag group can be determined using the following method, based on each current tag group, each current tag information, and the target user's tag vector database:
[0082] For each current tag group, determine whether there is historical tag information corresponding to the current tag group in the target user's tag vector database;
[0083] If there is historical tag information corresponding to the current tag group, then determine whether there is a semantic conflict between the historical tag information and the current tag information corresponding to the current tag group;
[0084] If a semantic conflict exists, determine whether the historical tag information and the current tag information are semantically opposite;
[0085] If the semantics are opposite, then the tag processing strategy corresponding to the current tag group is determined to be deletion;
[0086] If the semantics are not opposite, then the tag processing strategy corresponding to the current tag group is determined to be update;
[0087] If there is no semantic conflict, the tag processing strategy corresponding to the current tag group is determined to remain unchanged;
[0088] If no historical tag information exists for the current tag group, the tag processing strategy for the current tag group is determined to be adding new tags.
[0089] Specifically, for each current tag group, firstly, it is determined whether historical tag information corresponding to the current tag group exists in the target user's tag vector database. If no historical tag information exists, it means that the tag vector database does not yet contain relevant information, so it can be added directly, thus determining the tag processing strategy for the current tag group as "add". If historical tag information exists, it means that the target user's tag vector database already contains relevant information, so it is necessary to further determine whether there is a semantic conflict between the historical tag information and the current tag information corresponding to the current tag group. If there is no semantic conflict, it means that the current tag information and the historical tag information are consistent, and the tag processing strategy for the current tag group can be determined as "unchanged". If there is a semantic conflict, it means that the historical tag information needs to be adjusted, and further, it is necessary to determine whether the historical tag information and the current tag information are semantically opposite. If the semantics are opposite, it means that the current tag information and the historical tag information cannot coexist, so the tag processing strategy for the current tag group is "delete"; if the semantics are not opposite, it means that the current tag information and the historical tag information can coexist, and the current tag information can be added to the historical tag information, so the tag processing strategy for the current tag group is "update".
[0090] Based on the above example, the tag vector database of the target user can be processed according to the tag processing strategy corresponding to the current tag group, based on the current tag information and the current fact vector of the current tag group:
[0091] Based on the tag processing strategy corresponding to the current tag group, the tag adjustment information corresponding to the current session is generated and displayed according to the target user's tag vector database, the current tag information corresponding to the current tag group, and the current fact vector.
[0092] In response to receiving secondary adjustment information corresponding to the tag adjustment information, the tag vector database of the target user is processed according to the secondary adjustment information;
[0093] If a confirmation message corresponding to the tag adjustment information is received, or if no feedback message is received within a preset time, the tag vector database of the target user is processed according to the tag adjustment information.
[0094] The tag adjustment information comprises adjustments made to the target user's tag vector database based on the current session analysis, including both the original and updated versions. The secondary adjustment information reflects the target user's proactive modifications to the tag adjustment information. The preset timeframe is the period for the target user to confirm the tag adjustment information. Feedback information includes both the secondary adjustment information and the confirmation message.
[0095] Specifically, in the target user's tag vector database, by combining the current tag information and current fact vectors corresponding to each current tag group, the tag processing strategy corresponding to each current tag group is simulated and executed. This determines the information before and after execution. If the information differs, the information before and after execution can be used as the tag adjustment information for the current session and displayed for the user to view. If secondary adjustment information corresponding to the tag adjustment information is received, it indicates that the target user is dissatisfied with the current adjustment and has provided secondary adjustment information. Therefore, the secondary adjustment information provided by the target user is directly used to process the target user's tag vector database. If a confirmation message corresponding to the tag adjustment information is received, or no feedback message is received within a preset time, it indicates that the target user affirms the tag adjustment information, or the timeout has expired and no processing has occurred. Therefore, the tag adjustment information is still used to process the target user's tag vector database.
[0096] For example, the above example could be an event-driven memory update, specifically referring to the automatic activation of the memory recoding process when the target user interacts with the intelligent agent system and meets any of the following conditions: a. New information is added, such as the target user mentioning a certain type of fact for the first time (e.g., "I am allergic to peanuts"), b. Information conflict: the target user's current statement contradicts the historical record (e.g., the user in the historical record is "teacher," but the current conversation mentions "programmer"). Optionally, contextual association can be considered, such as implying long-term preference changes in the conversation (e.g., the target user repeatedly rejects sweet food recommendations, triggering an update of the "dietary preference" label).
[0097] The current conversation records of the target user and the intelligent agent system can be deeply analyzed through a pre-set large language model. Personalized structured memory tag information (current tag information corresponding to each current tag group) representing the target user can be extracted from the current conversation and stored in a vector database as semantic vectors (current facts) of unstructured data. Examples include basic identity information, social and occupational characteristics, personality and psychological traits, interests and lifestyles, interpersonal relationships and family, values and beliefs, abilities and skills, health and medical care, environment and geography, digital characteristics, and other dynamic tags. Table 1 lists some tag types.
[0098] Table 1. Tag Groups and Tag Information
[0099]
[0100] Conflict detection and logical reasoning refer to retrieving the target user's tag information from the current session, obtaining the target user's current tag vector database through memory lookup, and then analyzing it using a pre-defined large language model. This involves comparing the current factual tag information with historical memory (the historical tag information corresponding to the current tag group and the current tag information corresponding to the current tag group), and providing a memory handling strategy (tag processing strategy). The main basis for the pre-defined large language model's decision-making is: a. Semantic conflict detection: determining whether new and old tags contradict each other (e.g., "Occupation: Student" vs. "Occupation: Engineer"); b. Logical association analysis: identifying dependencies between tags (e.g., "Dietary Habits: Vegetarian" needs to be associated with "Health Goal: Weight Loss"), which can be pre-bound dependencies. Based on the logical reasoning of the pre-set large language model, if the current tag group does not exist in the tag vector database (e.g., adding "pet: cat"), the addition (ADD) strategy is given; if the tag information is conflicting or needs to be supplemented (e.g., "interest: photography" becomes "photography + mountaineering"), the update (UPDATE) strategy is given; if the semantics of the historical tag information are opposite to the current tag information (e.g., deleting the expired "place of residence: Beijing"), the deletion (DELETE) strategy is given; if the historical tag information is consistent with the current tag information (e.g., "blood type: type A" remains unchanged), the no change (NONE) strategy is given.
[0101] Dynamic updates and feedback verification are performed after the previous round of memory processing strategy generation. Based on this strategy, corresponding operations are executed. For example, adding a new label involves writing it into the label vector database (e.g., "Digital Feature: Frequent iOS System Use"); updating involves merging or replacing old labels (e.g., expanding "Interest: Basketball" to "Basketball, Esports"); and deleting a label involves marking expired labels as invalid (e.g., removing "Marital Status: Single"). After the strategy is executed, feedback can be provided to verify the update effect.
[0102] This system solves the problems of static nature, coarse-grained nature, and high maintenance costs in traditional memory management through a three-layer architecture of event triggering, semantic reasoning, and policy closed loop. Real-time binding of memory updates with the dialogue flow avoids information lag. Deep reasoning based on a pre-set large language model enables fine-grained management at the tag level. Conflict detection and feedback verification allow for autonomous evolution of memory quality. The tag system and handling strategies support custom expansion to adapt to multi-domain needs. This mechanism endows the intelligent agent system with "human-like" memory evolution capabilities, enabling it to continuously adapt to user changes in long-term interactions and become a truly personalized digital assistant.
[0103] By combining event triggering with semantic reasoning, intelligent and dynamic management of user memory is achieved. Based on the deep analysis capabilities of a pre-set large language model, multi-dimensional tag groups such as user identity, health, and interests are extracted from multiple rounds of conversation. These tags are then compared with historical conversation memories for conflict detection and logical correlation judgment, automatically generating tag handling strategies such as adding (ADD), updating (UPDATE), deleting (DELETE), or remaining unchanged (NONE). Compared to traditional static memory management, its innovation lies in: capturing explicit and implicit user characteristics through a fine-grained tag system, resolving information conflict issues using the semantic understanding capabilities of the pre-set large language model, and constructing an event-driven closed-loop update chain to achieve real-time and accurate adjustment of memory. This mechanism not only supports dynamic tracking of user preferences (such as switching from "fitness" to "meditation"), but also adaptively handles complex scenarios (such as updating medical contraindications). Furthermore, hot update technology ensures uninterrupted system operation, significantly improving the agent's memory accuracy and scenario adaptability in long-term interactions.
[0104] Based on the above example, before determining the target memory fragment according to the target question and the tag vector database of the target users corresponding to the target question, it is also necessary to perform a content security check on the target question. Specifically, this can be:
[0105] Receive the initial question from the target user and determine whether the initial question touches on a sensitive area based on the preset static rule base and the preset large language model;
[0106] If so, generate and display a risk warning message;
[0107] If not, then the initial problem will be used as the target problem.
[0108] The initial question is the question input by the target user; correspondingly, the target question is the initial question that has passed security verification. The preset static rule base is a rule base used for fixed risk checks, such as a preset sensitive word list or regular expressions. The preset static rule base and the preset large language model are updated according to a regularly established security case library, which includes case questions, case answers, case risk types, and case handling methods. The security case library contains manually annotated questions and answers indicating whether the handling was correct or not, along with the corresponding correct handling methods. The sensitive scope refers to content that does not meet security risks. Risk warning information is used to inform the target user that the initial question does not meet security standards.
[0109] Specifically, upon receiving an initial question from the target user, the system uses a pre-set static rule base and a pre-set large language model to identify the initial question and determine if it falls within a sensitive area. If at least one identification result falls within a sensitive area, it is determined to be sensitive. In this case, a risk warning message needs to be generated and displayed to inform the target user that the initial question poses a security risk and cannot be answered. If none of the identification results fall within a sensitive area, it means that subsequent answering can proceed, and therefore the initial question can be used as the target question.
[0110] Correspondingly, after determining the target answer to the target question, a content security check is also required, which may include:
[0111] Based on the preset static rule base and the preset large language model, determine whether there are hidden risks in the target answer;
[0112] If so, a feedback instruction is generated, the target answer is updated according to the feedback instruction, and the process is returned to execute the step of judging whether there are hidden risks in the target answer based on the preset static rule base and the preset large language model;
[0113] If not, then determine the target answer corresponding to the target question.
[0114] Implicit risk refers to the risk that the target answer touches on a sensitive area. Feedback instructions are instructions to correct the target answer.
[0115] Specifically, similar to the initial question detection, a pre-set static rule base and a pre-set large language model are used to determine if the target answer contains any hidden risks. If so, the target answer needs to be modified. Feedback instructions are generated for the parts with hidden risks to guide the pre-set large language model to make modifications. Therefore, the pre-set large language model can update the target answer based on the feedback instructions and return to execute the step of determining whether the target answer contains hidden risks based on the pre-set static rule base and the pre-set large language model, so as to re-determine the risk. If not, it means that the target answer passes the risk determination and can be used to answer the target question.
[0116] Understandably, through semantic understanding and risk prediction—that is, based on a static rule base and dynamic semantic fences (utilizing the self-reflective capabilities of a pre-defined large language model to achieve multi-round semantic cleansing)—after the target user inputs the initial question, the pre-defined large language model first performs intent analysis to determine if it touches on sensitive areas. If it does, interception is triggered (e.g., if a user asks "How to make explosives," the model parses it as "intent to prepare dangerous goods," triggering interception). After the model outputs the target answer, the generated target answer is recursively checked. If the responded target answer contains hidden risks, the model is required to review the feedback. Regenerate (generate feedback instructions) until safety is achieved (the target answer has no hidden risks). (For example, if the target answer is: "The explosive components include ammonium nitrate...", then a hidden risk is identified, and the review fails; feedback instruction: "Delete the specific component description, only explain the legal risks"; the updated target answer: "Preparing explosives is an illegal act, it is recommended to comply with laws and regulations.") Through two-way dynamic review, simultaneously monitoring both the target user input (initial answer) and the model output (target answer), a leap from "hard rule interception" to "cognitive alignment" is achieved, providing a safe foundation that balances accuracy and adaptability.
[0117] Furthermore, a closed-loop feedback and adaptive evolution are introduced. Specifically, intercepted violations and their revised responses are stored in a security case library, with risk types and handling methods labeled. A pre-set large language model is regularly trained using security case data to improve risk identification and compliance generation capabilities. New sensitive patterns (such as homophonic variants of "explosives") are automatically extracted and added to the static rule library.
[0118] This invention has the following technical effects: By determining the target memory fragment based on the target question and the tag vector database of the target user corresponding to the target question, the target user's tag information and factual semantic vector are stored in the tag vector database to achieve long-term memory management. Furthermore, based on the target question, the question-answering role and task objective are determined. Based on the question-answering role and task objective, basic instructions are determined. Based on the target memory fragment, constraints and corresponding reasoning guidance instructions are determined to combine with long-term memory to retrieve relevant content. The constraints of the target question are increased to improve the adaptability of subsequent answers to the target user. Finally, based on the basic instructions, constraints, and reasoning guidance instructions, the target answer corresponding to the target question is determined. This realizes the tag-based memory of the conversation, which facilitates long-term maintenance and retrieval of historical memory, improves the fit between the answer and user preferences, and enhances the user's question-answering experience.
[0119] Example 2
[0120] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. For example... Figure 2 As shown, the electronic device 200 includes one or more processors 201 and memory 202.
[0121] The processor 201 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 200 to perform desired functions.
[0122] The memory 202 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 201 may execute the program instructions to implement the intelligent question-answering method of any embodiment of the present invention described above and / or other desired functions. Various contents such as initial extrinsic parameters and thresholds may also be stored in the computer-readable storage medium.
[0123] In one example, the electronic device 200 may further include an input device 203 and an output device 204, these components being interconnected via a bus system and / or other forms of connection mechanisms (not shown). The input device 203 may include, for example, a keyboard, a mouse, etc. The output device 204 may output various information to the outside, including warning messages, braking force, etc. The output device 204 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0124] Of course, for the sake of simplicity, Figure 2 Only some of the components of the electronic device 200 relevant to the present invention are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 200 may include any other suitable components depending on the specific application.
[0125] Example 3
[0126] In addition to the methods and devices described above, embodiments of the present invention may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps of the intelligent question-answering method provided in any embodiment of the present invention.
[0127] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of the present invention. 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.
[0128] Furthermore, embodiments of the present invention may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps of the intelligent question-answering method provided in any embodiment of the present invention.
[0129] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0130] It should be noted that the terminology used in this invention is for describing specific embodiments only and is not intended to limit the scope of this application. As shown in this specification, unless the context clearly indicates otherwise, words such as "a," "an," "an," and / or "the" do not specifically refer to the singular and may include the plural. The terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, 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, or apparatus. Without further limitations, an element defined by the phrase "comprising an..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes said element.
[0131] It should also be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Unless otherwise expressly specified and limited, the terms "installed," "connected," "linked," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components. For those skilled in the art, the specific meaning of the above terms in the present invention can be understood according to the specific circumstances.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the technical solutions of the embodiments of the present invention.
Claims
1. An intelligent question-answering method, characterized in that, include: Based on the target question and the tag vector database of the target user corresponding to the target question, the target memory fragment is determined; wherein, the tag vector database is a database constructed based on historical sessions, containing each user's tag group, the historical tag information corresponding to each user's tag group, and factual semantic vectors; Based on the target question, determine the question-and-answer roles and task objectives, and based on the question-and-answer roles and task objectives, determine the basic instructions; Based on the target memory fragment, determine the constraints and the corresponding reasoning guidance instructions; Based on the basic instructions, the constraints, and the reasoning guidance instructions, determine the target answer corresponding to the target question; The tag vector database is updated according to the tag processing strategy corresponding to each current tag group in the current session, the current tag information corresponding to each current tag group, and the current fact vector corresponding to the fact information; the tag processing strategy is determined in the following manner: For each current tag group, determine whether there is historical tag information corresponding to the current tag group in the target user's tag vector database; if there is historical tag information corresponding to the current tag group, determine whether there is a semantic conflict between the historical tag information and the current tag information corresponding to the current tag group; if there is a semantic conflict, determine whether the historical tag information and the current tag information are semantically opposite; if the semantics are opposite, determine that the tag processing strategy corresponding to the current tag group is deletion; if the semantics are not opposite, determine that the tag processing strategy corresponding to the current tag group is update; if there is no semantic conflict, determine that the tag processing strategy corresponding to the current tag group is unchanged; if there is no historical tag information corresponding to the current tag group, determine that the tag processing strategy corresponding to the current tag group is addition.
2. The method according to claim 1, characterized in that, After determining the target answer corresponding to the target question, the method further includes: The current session is obtained, and based on a preset large language model, each factual information in the current session is determined. For each factual information, the current tag group corresponding to the factual information and the current tag information corresponding to each current tag group are determined. The target user's tag vector database is updated based on each current tag group, the current tag information corresponding to each current tag group, and the current fact vector corresponding to the fact information.
3. The method according to claim 2, characterized in that, The step of updating the target user's tag vector database based on each current tag group, the current tag information corresponding to each current tag group, and the current fact vector corresponding to the fact information includes: Based on each current tag group, each current tag information, and the tag vector database of the target user, determine the tag processing strategy corresponding to the current tag group; For each current tag group, determine the corresponding current fact vector based on the fact information corresponding to the current tag group; Based on the tag processing strategy corresponding to the current tag group, the tag vector database of the target user is processed according to the current tag information and the current fact vector corresponding to the current tag group.
4. The method according to claim 3, characterized in that, The tag processing strategy based on the current tag group, which processes the target user's tag vector database according to the current tag information and current fact vector corresponding to the current tag group, includes: Based on the tag processing strategy corresponding to the current tag group, and according to the tag vector database of the target user, the current tag information corresponding to the current tag group, and the current fact vector, the tag adjustment information corresponding to the current session is generated and displayed. In response to receiving secondary adjustment information corresponding to the tag adjustment information, the tag vector database of the target user is processed according to the secondary adjustment information; In response to receiving confirmation information corresponding to the tag adjustment information or not receiving feedback information within a preset time, the tag vector database of the target user is processed according to the tag adjustment information; The feedback information includes secondary adjustment information and confirmation information.
5. The method according to claim 1, characterized in that, The step of determining the target answer corresponding to the target question based on the basic instructions, the constraints, and the reasoning guidance instructions includes: Based on the basic instructions, the constraints, and the reasoning guidance instructions, the target prompt words are determined; The target prompt words are input into a preset large language model to obtain candidate answers corresponding to the target question; Based on the preset large language model, determine whether the candidate answer satisfies the constraints; If so, then the candidate answer will be taken as the target answer corresponding to the target question; If not, then based on the preset large language model, generate modification suggestions corresponding to the candidate answer, update the target prompt word according to the candidate answer and the modification suggestions, and return to execute the step of inputting the target prompt word into the preset large language model to obtain the candidate answer corresponding to the target question.
6. The method according to claim 1, characterized in that, Before determining the target memory fragment based on the target question and the tag vector database of the target user corresponding to the target question, the method further includes: Receive the initial question from the target user, and determine whether the initial question touches on a sensitive area based on a preset static rule base and a preset large language model; If so, generate and display the risk warning information; If not, then the initial problem will be taken as the target problem; After determining the target answer corresponding to the target question, the method further includes: Based on the preset static rule base and the preset large language model, determine whether the target answer has any hidden risks; If so, a feedback instruction is generated, the target answer is updated according to the feedback instruction, and the process returns to the step of determining whether the target answer has hidden risks based on the preset static rule base and the preset large language model. If not, then determine the target answer corresponding to the target question; The preset static rule base and the preset large language model are updated according to the security case base established regularly. The security case base includes case questions, case answers, case risk types and case handling methods.
7. The method according to claim 1, characterized in that, The step of determining the target memory fragment based on the target question and the tag vector database of the target user corresponding to the target question includes: Based on the target question, at least one candidate label group corresponding to the target question is determined; Based on each candidate tag group, in the tag vector database of the target user corresponding to the target question, determine the candidate tag information and candidate fact vector corresponding to each candidate tag group respectively; For each candidate label group, the candidate relevance is determined based on the candidate fact vector corresponding to the candidate label group and the question vector corresponding to the target question; The relevance of each target is determined based on the relevance of each candidate, the relevance threshold, and the preset number of memories. For each target relevance, the candidate label group corresponding to the target relevance is determined as the target label group, and the candidate label information and candidate fact vector corresponding to the target label group are used as the target memory fragment.
8. An electronic device, characterized in that, The electronic device includes: Processor and memory; The processor executes the steps of the intelligent question-answering method as described in any one of claims 1 to 7 by calling the program or instructions stored in the memory.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instructions that cause a computer to perform the steps of the intelligent question-answering method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Intention recognition method and device, electronic equipment and storage medium
CN116861926A
Human-computer interaction method and device and computer readable storage medium
CN118838998A