Self-adaptive retrieval reasoning method and system based on memory stack and knowledge perception optimization

By employing an adaptive retrieval and reasoning method optimized with memory stacks and knowledge perception, the memory management and retrieval decision-making problems in multi-turn dialogues in existing technologies are solved, achieving efficient and accurate intelligent retrieval and reasoning, and improving the system's credibility and user satisfaction.

CN121835883APending Publication Date: 2026-04-10BEIJING PANJI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING PANJI INFORMATION TECH CO LTD
Filing Date
2025-12-16
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing intelligent retrieval and reasoning systems based on large language models suffer from problems in multi-turn dialogues, such as chaotic memory management, rigid retrieval decisions, weak fuzzy query processing capabilities, insufficient noise resistance in the reasoning process, and lack of answer tracing mechanisms. These issues lead to loss of dialogue semantics, inaccurate retrieval results, and low system credibility.

Method used

An adaptive retrieval and reasoning method based on memory stack and knowledge perception optimization is adopted. Through proxy memory stack, retrieval decision-maker and noise-resistant reasoning engine, the structured management of dialogue state and intelligent determination of retrieval timing are realized. The large language model is used to generate enhanced answers and perform source analysis to provide high-quality queries and answers.

Benefits of technology

It improves the reasoning accuracy and system credibility of multi-turn dialogues, reduces interference from irrelevant information, increases retrieval recall and accuracy, enhances system robustness and user satisfaction, and ensures the accuracy and interpretability of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121835883A_ABST
    Figure CN121835883A_ABST
Patent Text Reader

Abstract

The invention relates to a memory stack and knowledge perception optimization-based self-adaptive retrieval and reasoning method and system and a medium, and the method comprises the following steps: receiving user interaction information, and importing the user interaction information into a created proxy memory stack to obtain structured dialogue state information; the query result information is imported into a retrieval decision maker, the retrieval decision maker judges whether retrieval is needed or not based on a neural network, and if retrieval is needed, the query result information is imported into a query generation model to obtain query result information; the query result information and the structured dialogue state information are imported into an anti-noise inference engine, and the anti-noise inference engine generates enhanced answers and attention distribution based on a large language model and a knowledge perception preference optimization model; and performing traceability analysis on the enhanced answers, matching the enhanced answers with corresponding traceability based on attention distribution, and constructing a traceability mapping table. A high-precision, high-reliability and high-efficiency solution is provided for complex multi-round intelligent questions and answers in the professional vertical field, and the method has wide application prospects and practical value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer information processing, and in particular to an adaptive retrieval and reasoning method and system based on memory stack and knowledge perception optimization. Background Technology

[0002] With the rapid development of Large Language Model (LLM) technology, dialogue-based intelligent retrieval and reasoning systems are widely used in customer service, intelligent assistants, academic research, and other fields. The core requirement of such systems is the ability to accurately understand the user's multi-turn dialogue intent, retrieve external knowledge on demand, and generate accurate answers based on reliable evidence.

[0003] However, existing technologies suffer from the following significant drawbacks: First, multi-turn dialogue memory management is chaotic. Most systems employ simple historical text splicing, failing to effectively distinguish dialogue topic boundaries, leading to the loss or confusion of contextual semantics, which in turn affects the accuracy of subsequent reasoning. Second, the retrieval decision-making mechanism is rigid, often employing "fixed triggering" or "pure rule judgment" methods, unable to dynamically determine whether a retrieval is needed based on the dialogue content, easily resulting in "over-retrieval" (initiating a retrieval when no external knowledge is needed, wasting resources) or "missing retrieval" (failing to initiate a retrieval when external knowledge is needed, leading to incorrect answers). Third, the fuzzy query processing capability is weak. When user questions have issues such as missing entities or unclear conditions, the system cannot proactively clarify, resulting in low accuracy and poor relevance of directly generated retrieval queries. Fourth, the reasoning process lacks noise resistance. Retrieved documents often contain noise information irrelevant to the question or conflicting with facts. Existing LLMs are susceptible to such interference, generating "illusory answers" that do not conform to the facts. Fifth, the answer tracing mechanism is lacking. Users cannot verify the source of the answer information, reducing the system's credibility in professional scenarios (such as medical and legal fields).

[0004] Therefore, there is an urgent need for a technical solution that can achieve efficient dialogue memory management, intelligent retrieval decision-making, accurate noise-resistant reasoning, and reliable answer tracing to address the aforementioned shortcomings of existing systems. Summary of the Invention

[0005] Therefore, it is necessary to provide an adaptive retrieval and reasoning method, system, and medium to address the problems of the existing technologies mentioned above.

[0006] An adaptive retrieval and reasoning method based on memory stack and knowledge perception optimization, the method comprising:

[0007] Receive user interaction information and import the user interaction information into the created proxy memory stack to obtain structured dialogue state information;

[0008] The user interaction information and the structured dialogue status information are imported into the retrieval decision-maker. The retrieval decision-maker uses a neural network to determine whether the user interaction information and the structured dialogue status information need to be retrieved. If retrieval is required, the user interaction information and the structured dialogue status information are imported into the query generation model to obtain query results.

[0009] The query results and structured dialogue state information are imported into a noise-resistant inference engine. The noise-resistant inference engine generates enhanced answers and attention distributions corresponding to the structured dialogue state information based on a large language model and a knowledge-aware preference optimization model.

[0010] The enhanced answer is subjected to source analysis. Based on the attention distribution, the enhanced answer is matched with the corresponding source, a source mapping table is constructed, and the enhanced answer and the source mapping table are output.

[0011] In one preferred embodiment, the proxy memory stack includes a dialogue behavior classification model, a joint embedding computation model, and a confidence classification model. The behavior classification model classifies user interaction information using a fine-tuned BERT classifier. The joint embedding computation model normalizes the user interaction information by fusing semantic embedding and entity embedding. The confidence classification model classifies the user interaction information based on the log probability of the tokens generated by the large model and the confidence of the dialogue behavior classification.

[0012] In one preferred embodiment, the method for updating the proxy memory stack includes:

[0013] Check the proxy memory stack. If the proxy memory stack is empty, use the new memory unit as the initial memory stack; if the proxy memory stack is not empty,

[0014] Based on the cosine similarity model, the joint embedding vector similarity information between the new memory unit and the top stack unit is obtained. The cosine similarity model satisfies:

[0015]

[0016] above formula S sim For cosine similarity information, Information for the top cell of the stack. For information in the new memory unit;

[0017] When the cosine similarity information is higher than the similarity threshold, the new memory unit is concatenated to the top unit of the stack and the embedding vector and type of the top unit of the stack are recalculated; when the cosine similarity information is lower than the similarity threshold, the current memory stack is stored in long-term memory and a new stack containing the new memory unit is created; when the cosine similarity information is within the similarity threshold, the new memory unit is pushed onto the new stack.

[0018] In one preferred embodiment, the step of importing the user interaction information and the structured dialogue state information into a retrieval decision-maker, wherein the retrieval decision-maker determines whether a retrieval is needed based on a neural network, and the method further includes:

[0019] If no retrieval is required, the user interaction information and the structured dialogue state information are imported into the noise-resistant inference engine.

[0020] In one preferred embodiment, the step of importing the user interaction information and the structured dialogue state information into the query generation model to obtain query result information if retrieval is required includes:

[0021] The user interaction information and the structured dialogue state information are imported into a fuzzy query determination model to determine whether the user interaction information and the structured dialogue state information need to be fuzzy searched.

[0022] If no fuzzy search is required, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain the query results.

[0023] If a fuzzy search is required, proactive clarification and completion information is initiated based on the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain the query result information.

[0024] In one preferred embodiment, if a fuzzy query is required, proactive clarification and completion information is initiated based on the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain query result information, including:

[0025] The initiative to clarify and complete information is achieved through decision tree interaction. Clarification script templates are preset for different types of fuzzy queries, and a clear query is generated after key information is completed through multiple rounds of interaction.

[0026] In one preferred embodiment, the retrieval system determines whether retrieval is needed based on a neural network analysis of the user interaction information and the structured dialogue state information. The neural network structure of the retrieval decision-maker includes an input layer, a feature fusion layer, upper and lower feature extraction layers, and a decision layer.

[0027] The input layer receives the memory stack aggregation vector. With the current problem vector

[0028] The feature fusion layer performs a nonlinear transformation on the concatenated feature vectors using the GELU activation function to obtain fused feature information. The GELU activation function satisfies the following:

[0029]

[0030] in, To fuse feature information, Q f b f These are trainable parameters;

[0031] The context feature extraction layer arranges the memory stack embedding vectors into a matrix in order, performs convolution using three types of convolution kernels, and each convolution kernel outputs 64 channels. After passing through the GELU activation function and Max-over-time pooling, the concatenation results in the context feature information.

[0032] The decision-making level integrates feature information. With contextual feature information The retrieval probability is output through a decision model trained on labeled dialogue data using a binary cross-entropy loss function. The decision model satisfies the following:

[0033]

[0034] W h b h b0 are trainable parameters, P retrieve This represents the retrieval probability.

[0035] In one preferred embodiment, the query generation model is based on reinforcement learning training and includes:

[0036] Construct a multi-dimensional fused state vector to characterize the training scenario;

[0037] The action is defined as the sequence of search query terms output by the query generation model, and the action space is constrained by syntax validation and semantic relevance filtering.

[0038] A multi-objective weighted reward function is used to guide the model to generate high-quality retrieval queries. This multi-objective weighted reward function guides the model r(s,a) to satisfy the following:

[0039]

[0040] Where: α, β, and γ are the weight coefficients after empirical optimization, BERTScore(R) t Agold ) for retrieving document collection R t With the golden answer A gold The maximum semantic similarity is calculated based on the word embedding similarity of the pre-trained language model; This is a standardized query length penalty. Include indicator functions for key entities;

[0041] The policy network is trained and updated using a near-end policy optimization algorithm, and the policy network adopts a Transformer-based sequence generation network structure.

[0042] The method disclosed in this invention intelligently determines the retrieval timing based on the dynamic dialogue context state, enabling on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through a memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key conditions missing in user questions, completes information through multi-turn interactions, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing system credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value.

[0043] An adaptive retrieval and reasoning system based on memory stack and knowledge perception optimization, the system comprising:

[0044] The memory management module is used to receive user interaction information and import the user interaction information into the created proxy memory stack to obtain structured dialogue state information.

[0045] The retrieval control module is used to import the user interaction information and the structured dialogue status information into the retrieval decision-maker. The retrieval decision-maker uses a neural network to determine whether the user interaction information and the structured dialogue status information need to be retrieved. If retrieval is required, the user interaction information and the structured dialogue status information are imported into the query generation model to obtain query result information.

[0046] The noise-resistant reasoning module is used to import the query result information and structured dialogue state information into the noise-resistant reasoning engine. The noise-resistant reasoning engine generates the enhanced answer and attention distribution corresponding to the structured dialogue state information based on the large language model and the knowledge perception preference optimization model.

[0047] The source tracing module is used to perform source tracing analysis on the enhanced answer, match the enhanced answer with the corresponding source based on the attention distribution, construct a source tracing mapping table, and output the enhanced answer and the source tracing mapping table.

[0048] The system disclosed in this invention intelligently determines the retrieval timing based on the dynamic dialogue context state, enabling on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through a memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key missing conditions in user questions, completes information through multi-turn interactions, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing the system's credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value.

[0049] A storage medium containing computer-executable instructions, which are executed by a computer processor using the adaptive retrieval and reasoning method described above.

[0050] The storage medium disclosed in this invention, by executing the aforementioned method, intelligently determines the retrieval timing based on the dynamic dialogue context state, achieving on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through the memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key conditions missing in user questions, completes information through multi-turn interactions, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing system credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value. Attached Figure Description

[0051] Figure 1 This is a first flowchart illustrating the adaptive retrieval and reasoning method in the first preferred embodiment of the present invention;

[0052] Figure 2 This is a schematic diagram showing the detailed steps of step S10 in the adaptive retrieval and reasoning method of the first preferred embodiment of the present invention;

[0053] Figure 3 This is a flowchart of the memory stack update process in step S10 of the adaptive retrieval and reasoning method in the first preferred embodiment of the present invention.

[0054] Figure 4 This is a schematic diagram showing the detailed steps of step S20 in the adaptive retrieval and reasoning method of the first preferred embodiment of the present invention;

[0055] Figure 5 This is a schematic diagram of the adaptive retrieval and reasoning system in the second preferred embodiment of the present invention;

[0056] Figure 6 This is a schematic diagram of the information flow of the adaptive retrieval and reasoning system in the second preferred embodiment of the present invention. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0058] It should be noted that when an element is referred to as being "set on" another element, it can be directly on the other element or there may be an intervening element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "left," "right," and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementation.

[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0060] like Figure 1 As shown, the first preferred embodiment of the present invention discloses an adaptive retrieval and reasoning method based on memory stack and knowledge perception optimization, the method comprising the following steps:

[0061] S10: Receive user interaction information and import the user interaction information into the created proxy memory stack to obtain structured dialogue state information.

[0062] In this step, the aforementioned proxy memory stack includes a dialogue behavior classification model, a joint embedding computation model, and a confidence classification model. In this embodiment, the dialogue behavior classification model classifies user interaction information using a fine-tuned BERT classifier. The joint embedding computation model integrates semantic embedding and entity embedding to normalize the user interaction information. The confidence classification model classifies the user interaction information based on the log probability of the tokens generated by the large model and the confidence of the dialogue behavior classification.

[0063] More specifically, the aforementioned dialogue behavior classification model uses a BERT classifier (Bidirectional Encoder Representations from Transformers) fine-tuned on the dialogue corpus to classify the received user interaction information. Specifically, the dialogue behavior classification model converts user interaction information into… <user> u i <system>a i "For dialogue sequences, the dialogue behavior classification model outputs a probability distribution for each corresponding category. These categories can include questioning, explaining, and asserting. The category with the highest probability is then chosen as the corresponding category for the dialogue behavior, and the probability value corresponding to that category is the classification confidence C." type .

[0064] The aforementioned joint embedding computation model uses Sentence-BERT to convert the dialogue sequence into corresponding sentence vectors. Entities from the above dialogue sequence are extracted using a domain dictionary and a NER model, and entity set vectors are generated. The aforementioned Sentence-BERT is a sentence embedding model in the field of Natural Language Processing (NLP), utilizing trainable parameters W. e and b e The semantic embedding and entity embedding are fused and processed using LayerNorm to obtain the joint embedding vector e. i The joint embedding vector e i satisfy:

[0065]

[0066] In the above formula, e i For the joint embedding vector, W e b e For trainable parameters, For sentence vectors, It is a vector of entity sets.

[0067] The confidence classification model described above, combined with a large language model (LLM), generates the dialogue sequence described above, specifically the one described above. i The average log probability P of the token at that time llm Confidence C for classifying dialogue behavior type And the confidence level of the memory cell is calculated using the Sigmoid function. i Specifically, the confidence level of the aforementioned memory unit (conf) i satisfy:

[0068] conf i =σ(w1p llm +w2c tpye +b)

[0069] Where w1 and w2 are trainable parameters, b is a linear combination of biases, and P llm Let C be the logarithmic probability. type Confidence level for classifying dialogue behaviors.

[0070] The confidence level of the above memory cells (conf) i Essentially, it transforms the "raw score" calculated by the model into a probabilistic index that conforms to the semantics of "confidence" through nonlinear transformation. After transformation by the Sigmoid function, the confidence score (conf) of the aforementioned memory unit is... i The obtained value between 0 and 1 directly represents the reliability of the proxy memory stack in this step. The closer the value is to 1, the more reliable the proxy memory stack is in carrying dialogue information, providing a quantitative basis for subsequent memory stack updates and retrieval decisions.

[0071] Using the dialogue behavior classification model, joint embedding computation model, and confidence classification model included in the aforementioned proxy memory stack, this step converts the received user interaction information into structured dialogue state information.

[0072] Combination Figure 2 and Figure 3 As shown, the method for updating the proxy memory stack includes:

[0073] S11: Check the proxy memory stack. If the proxy memory stack is empty, initialize the proxy memory stack and push the received user interaction information into the proxy memory stack in the form of memory unit information. If the proxy memory stack is not empty, execute the following step S12.

[0074] This step is mainly to check if the above-mentioned proxy memory stack is empty. If it is empty, the proxy memory stack is initialized directly.

[0075] S12: Obtain the joint embedding vector similarity information between the new memory unit and the top stack unit based on the cosine similarity model, wherein the cosine similarity model satisfies:

[0076]

[0077] above formula S sim For cosine similarity information, Information for the top cell of the stack. For information in the new memory unit;

[0078] In this detailed step, if the aforementioned proxy memory stack is not empty, the joint embedding vector similarity information of the new memory unit and the top unit of the stack corresponding to the received user interaction information is obtained based on the cosine similarity model. This step is the core basis for the memory stack's "dynamic decision-making," providing data support for subsequent update strategy selection by quantifying the semantic correlation between new and historical dialogues. Specifically, the cosine similarity algorithm is used to calculate the joint embedding vector similarity between the new memory unit and the top unit of the memory stack. In this embodiment, the output cosine similarity information S... sim The value ranges from [-1, 1]. The closer the value is to 1, the stronger the correlation between the new dialogue and the historical dialogue at the top of the stack; the closer the value is to -1, the greater the difference in their topics. Compared with traditional text matching, this calculation method can more accurately capture the deep semantic connections in dialogues and avoid misjudgments of association caused by superficial differences in wording.

[0079] S13: When the cosine similarity information is higher than the similarity threshold, the new memory unit is concatenated to the top unit of the stack and the embedding vector and type of the top unit of the stack are recalculated; when the cosine similarity information is lower than the similarity threshold, the current memory stack is stored in long-term memory and a new stack containing the new memory unit is created; when the cosine similarity information is within the similarity threshold, the new memory unit is pushed into the new stack.

[0080] In this subdivided step, the specific strategy is as follows: when the dialogue behavior type of the new memory unit is questioning or explaining, and the semantic similarity output result S sim High similarity threshold θ high When triggered, the operation involves concatenating the corresponding new memory unit to the top unit of the stack and recalculating the embedding vector and type of the top unit. Specifically, the above is merged, which includes concatenating text, recalculating embedding, and reclassifying dialogue behavior. This strategy can avoid fragmented storage of dialogues on the same topic and improve the aggregation of context.

[0081] When the semantic similarity output result S sim Below the low similarity threshold θ low When the new dialogue is significantly different from the current memory stack topic, the current memory stack is stored in long-term memory and a new stack containing the new memory units is created. At the same time, a new memory stack containing only the new memory units is created to ensure that the memory boundaries of dialogues on different topics are clear and to avoid cross-topic information interference.

[0082] When the low similarity threshold θ low The semantic similarity output S is greater than or equal to sim Less than or equal to the high similarity threshold θ high If a new dialogue is found to be related to a previous dialogue but does not meet the aggregation criteria, the new memory unit is directly pushed onto the current memory stack. Alternatively, if the stack depth after pushing a new memory unit onto the current stack exceeds a preset capacity K, the memory unit with the lowest confidence at the bottom of the stack is removed before pushing it onto the stack again. This strategy can control the size of the memory stack while preserving valid context, reducing the computational burden on subsequent modules. The aforementioned "exceeding the preset capacity K" is a stack capacity parameter that balances memory integrity and computational efficiency.

[0083] In the above steps, the output result S is based on semantic similarity. sim Based on the dual conditions of dialogue behavior type, three differentiated strategies are dynamically executed to achieve the goals of "associative dialogue aggregation, topic switching separation, and redundant memory simplification".

[0084] S20: The user interaction information and the structured dialogue status information are imported into the retrieval decision-maker. The retrieval decision-maker determines whether the user interaction information and the structured dialogue status information need to be retrieved based on a neural network. If retrieval is required, the user interaction information and the structured dialogue status information are imported into the query generation model to obtain query result information.

[0085] Specifically, in the aforementioned retrieval decision-maker's determination of whether a retrieval is needed based on the user interaction information and the structured dialogue state information using a neural network, the neural network structure of the retrieval decision-maker includes an input layer, a feature fusion layer, upper and lower feature extraction layers, and a decision layer; specifically,

[0086] The input layer receives the memory stack aggregation vector. With the current problem vector The current problem vector The input layer receives the memory stack aggregation vector obtained from the user interaction information received in step S10 above. The state information is obtained by structuring the dialogue through the number of lines.

[0087] The feature fusion layer performs a nonlinear transformation on the concatenated feature vectors using the GELU activation function to obtain fused feature information. The GELU activation function satisfies the following:

[0088]

[0089] in, To fuse feature information, W f b f For trainable parameters, For the aggregation vector of the memory stack, This is the current problem vector;

[0090] The context feature extraction layer arranges the memory stack embedding vectors into a matrix in order, performs convolution using three types of convolution kernels, and each convolution kernel outputs 64 channels. After passing through the GELU activation function and Max-over-time pooling, the concatenation results in the context feature information.

[0091] The decision-making level integrates feature information. With contextual feature information The retrieval probability is output through a decision model trained on labeled dialogue data using a binary cross-entropy loss function. The decision model satisfies the following:

[0092]

[0093] W h b h W0 and b0 are trainable parameters. For contextual feature information, To fuse feature information, P retrieve This represents the retrieval probability.

[0094] When the retrieval probability P retrieve If the value exceeds the retrieval threshold, a retrieval is required. If the retrieval probability P... retrieve If the threshold is less than the required threshold, no retrieval is needed. If no retrieval is needed, the user interaction information and the structured dialogue state information are imported into the noise-resistant inference engine. The specific working process of the noise-resistant inference engine will be discussed in detail in step S30 below. It will not be elaborated here. When the retrieval decision-maker determines that a retrieval is needed, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain query result information, combined with... Figure 1 and Figure 3 As shown, it specifically includes:

[0095] S21: Import the user interaction information and the structured dialogue state information into the fuzzy query determination model to determine whether the user interaction information and the structured dialogue state information need to be fuzzy searched.

[0096] In this sub-step, only when the retrieval decision-maker determines "retrieval is required" is the user interaction information and the structured dialogue state information imported into the fuzzy query determination model. The fuzzy query determination model takes the user interaction information and the structured dialogue state information as input, focuses on the completeness of core information, and determines whether it is a fuzzy query.

[0097] Specifically, in this detailed step, based on the domain dictionary and the NER (Named Entity Recognition) model, key entities (such as technical terms, product names, people / scenes, etc.) can be extracted from the user interaction information and the structured dialogue state information. If a key entity is missing (e.g., "the device" is not explicitly pointed to in "What are the parameters of this device?"), it is marked as requiring a fuzzy query. On the other hand, it is determined whether the questions in the extracted user interaction information and the structured dialogue state information contain necessary constraints (such as time, scope, scene, etc.). If it is missing, it is determined whether the questions contain necessary constraints (e.g., "How to apply for subsidies" does not specify the region or identity), and it is determined as requiring a fuzzy query.

[0098] S22: If no fuzzy search is required, import the user interaction information and the structured dialogue state information into the query generation model to obtain query result information.

[0099] Specifically, the training process of the above query generation model reinforcement learning training includes:

[0100] A multi-dimensional fused state vector is constructed to characterize the training scenario. Specifically, a Transformer-based sequence generation network serves as the policy network. The encoder processes the input state features, and the decoder outputs the word sequence of the retrieval query. The network parameters are initialized using pre-trained BART-based weights. The training scenario consists of an external knowledge base and a golden answer annotation library. The external knowledge base provides retrieval feedback, and the golden answer annotation library provides the basis for semantic similarity determination.

[0101] An action is defined as a sequence of search query terms output by the query generation model. The action space is constrained by syntax validation and semantic relevance filtering. The semantic similarity between the generated query and the user's question is ≥0.5, and actions that are irrelevant to the needs are excluded. The action space must contain at least one key entity identified by the NER model (such as a disease or product name). The size of the constrained action space is greatly reduced, which significantly improves training efficiency and query effectiveness.

[0102] A multi-objective weighted reward function is used to guide the model to generate high-quality retrieval queries. This multi-objective weighted reward function guides the model r(s,a) to satisfy the following:

[0103]

[0104] Where: α, β, and γ are the weight coefficients after empirical optimization, BERTScore(R) t A gold ) for retrieving document collection R t With the golden answer A gold The maximum semantic similarity is calculated based on the word embedding similarity of the pre-trained language model; This is a standardized query length penalty. Including indicator functions for key entities; the above-mentioned standardized query length penalty can prevent the model from generating overly simplistic or redundant queries.

[0105] The policy network is trained and updated using a near-end policy optimization algorithm, and the policy network adopts a Transformer-based sequence generation network structure.

[0106] S23: If a fuzzy search is required, proactive clarification and completion information is initiated for the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain the query result information.

[0107] Specifically, the above-mentioned initiative to clarify and complete information is achieved through the execution of decision tree interaction. Clarification script templates are preset for different types of fuzzy queries, and a clear query is generated after key information is completed through multiple rounds of interaction.

[0108] More specifically, the aforementioned retrieval decision-maker has built-in fuzzy query classification rules, matching scenarios according to the priority from "entity missing to condition missing to multi-dimensional missing". For example, if only the entity is missing (such as "what is the usage of this medicine"), it matches the "entity clarification" branch; for example, "Which item do you specifically refer to with the '[fuzzy reference]' you mentioned? Please supplement the name / identifier (such as model number)".

[0109] If the entity is complete but the conditions are missing (e.g., "How to treat hypertension"), a "condition completion" branch will be matched. At the same time, standardized wording will be preset for different branches to avoid ambiguity. For example: "For an accurate answer, please provide [missing conditions] (e.g., application region / blood pressure value / allergy history)."

[0110] This step involves pushing clarification messages through the user interaction layer, receiving supplementary information from the user, and then using a fuzzy query judgment model to perform a second verification of the information's completeness. If there are still missing information, a second round of clarification is initiated (e.g., if the user only says "antihypertensive medication," ask "is it amlodipine or valsartan?"). After the information is completed, "clarity query marker V=0" is output.

[0111] After the key information is completed, the system integrates the original user interaction information, subsequent supplementary information, and structured dialogue status information into a complete requirement. The query generator generates a precise retrieval query containing core entities and constraints, ensuring that subsequent knowledge base retrieval can locate highly relevant documents and provide high-quality knowledge input for the noise-resistant reasoning engine.

[0112] S30: Import the query result information and structured dialogue state information into the noise-resistant inference engine. The noise-resistant inference engine generates the enhanced answer and attention distribution corresponding to the structured dialogue state information based on the large language model and the knowledge perception preference optimization model.

[0113] The core function of this step is to utilize a noise-resistant inference engine based on a large language model and a knowledge-aware preference optimization model, integrate dialogue context and reliable retrieval knowledge, and generate enhanced answers and attention distributions corresponding to the structured dialogue state information from the query result information and structured dialogue state information.

[0114] The structured dialogue state information mentioned above includes the current state of the memory stack, the dialogue behavior type / confidence / key entities of each memory unit, etc. Its core function is to provide dialogue context anchors (such as user history questions, core demand entities) for the Large Language Model (LLM) and avoid reasoning from deviating from the multi-turn dialogue scenario, such as key information such as "elderly woman" and "no history of drug allergies" in a medical scenario.

[0115] The query results obtained in step S20 are external knowledge sources for the Large Language Model (LLM), but may contain noise, such as documents irrelevant to the core requirements or content with factual conflicts. This is the core target of the noise-resistant inference engine. Specifically, the noise-resistant inference engine includes a large language model and a knowledge-aware preference optimization model. The training process of the knowledge-aware preference optimization model includes:

[0116] Constructing a knowledge conflict dataset, the process of which includes constructing a standard answer dataset A. + Negative example answer dataset A - and noise context dataset C.

[0117] The above standard answer dataset A + Based on the aforementioned user interaction information q, the most relevant document blocks are retrieved from the knowledge base. In this embodiment, the number of document blocks is 3, which are represented as: C rel =[c1,c2,c3], generally, these document blocks are written by domain experts or generated by a strong teacher model to produce the standard answer A. + .

[0118] The above noise context dataset C searches for the relationship between C and the knowledge base. rel Document blocks that contradict the facts. For example, C rel It is said that "the minimum area of ​​arable land plot is 200m²". 2 Then, search for "the minimum cultivated land area is 400m²". 2 "C" conflict Document. Incorporate a conflicting block into the above document block C. rel , forming C rel ⊕C conflict Next, randomly select 1-2 blocks from documents whose topics are unrelated to the aforementioned user interaction information q, and mix them into the aforementioned document block C. rel Noise dataset C is formed in the middle noise Finally, a noise context dataset is formed.

[0119] The above noisy context dataset C and question q are input into the basic large language model LLM to generate enhanced answers and attention distributions.

[0120] S40: Perform source analysis on the enhanced answer, match the enhanced answer with the corresponding source based on the attention distribution, construct a source mapping table, and output the enhanced answer and the source mapping table.

[0121] In this step, the source tracing analysis matches the enhanced answer with the corresponding source based on the attention distribution obtained in step S30 above, calculates the block-level source tracing score, completes the matching of answer fragments with source blocks, and generates a source tracing mapping table; the user interaction layer receives the final answer and the source tracing mapping table, and can highlight the answer and corresponding source document information and provide feedback to the user.

[0122] The method disclosed in this embodiment intelligently determines the retrieval timing based on the dynamic dialogue context state, achieving on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through a memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key conditions missing in user questions, completes information through multi-turn interactions, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing system credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value.

[0123] Combination Figure 4 and Figure 5 As shown, the second preferred embodiment of the present invention discloses an adaptive retrieval and reasoning system 100 based on memory stack and knowledge perception optimization. The system 100 includes a memory management module 110, a retrieval control module 120, a noise-resistant reasoning module 130, and a source tracing processing module 140.

[0124] Specifically, the user submits user interaction information (such as asking a question) through the user interaction layer. The memory management module 110 receives the user interaction information and imports it into the created proxy memory stack to obtain structured dialogue state information S. t In this embodiment, the aforementioned user interaction information is imported into the proxy memory stack via a dialogue state tracker. The proxy memory stack includes a dialogue behavior classification model, a joint embedding computation model, and a confidence classification model. In this embodiment, the dialogue behavior classification model classifies the user interaction information using a fine-tuned BERT classifier. The joint embedding computation model integrates semantic embedding and entity embedding to normalize the user interaction information. The confidence classification model classifies the user interaction information based on the log probability of the tokens used to generate the answer from the large model and the confidence score of the dialogue behavior classification.

[0125] More specifically, the aforementioned dialogue behavior classification model uses a BERT classifier (Bidirectional Encoder Representations from Transformers) fine-tuned on the dialogue corpus to classify the received user interaction information. Specifically, the dialogue behavior classification model converts user interaction information into... <user> u i <system>a i "For dialogue sequences, the dialogue behavior classification model outputs a probability distribution for each corresponding category. These categories can include questioning, explaining, and asserting. The category with the highest probability is then chosen as the corresponding category for the dialogue behavior, and the probability value corresponding to that category is the classification confidence C." type .

[0126] The aforementioned joint embedding computation model uses Sentence-BERT to convert the dialogue sequence into corresponding sentence vectors. Entities from the above dialogue sequence are extracted using a domain dictionary and a NER model, and entity set vectors are generated. The aforementioned Sentence-BERT is a sentence embedding model in the field of Natural Language Processing (NLP), utilizing trainable parameters W. e and b e The semantic embedding and entity embedding are fused and processed using LayerNorm to obtain the joint embedding vector e. i The joint embedding vector e i satisfy:

[0127]

[0128] In the above formula, e i For the joint embedding vector, W e b e For trainable parameters, For sentence vectors, It is a vector of entity sets.

[0129] The confidence classification model described above, combined with a large language model (LLM), generates the dialogue sequence described above, specifically the one described above. i The average log probability P of the token at that time llm Confidence C for classifying dialogue behavior type And the confidence level of the memory cell is calculated using the Sigmoid function. i Specifically, the confidence level of the aforementioned memory unit (conf) i satisfy:

[0130] conf i =σ(w1p llm +w2c tpye +b)

[0131] Where w1 and w2 are trainable parameters, b is a linear combination of biases, and P llm Let C be the logarithmic probability. type Confidence level for classifying dialogue behaviors.

[0132] The confidence level of the above memory cells (conf) i Essentially, it transforms the "raw score" calculated by the model into a probabilistic index that conforms to the semantics of "confidence" through nonlinear transformation. After transformation by the Sigmoid function, the confidence score (conf) of the aforementioned memory unit is... i The obtained value between 0 and 1 directly represents the reliability of the proxy memory stack in this step. The closer the value is to 1, the more reliable the proxy memory stack is in carrying dialogue information, providing a quantitative basis for subsequent memory stack updates and retrieval decisions.

[0133] Using the dialogue behavior classification model, joint embedding computation model, and confidence classification model included in the aforementioned proxy memory stack, this step converts the received user interaction information into structured dialogue state information S. t .

[0134] The method for updating the proxy memory stack has been described in detail in the first embodiment, so the update method will not be repeated here.

[0135] The retrieval control module 120 is used to retrieve the user interaction information and the structured dialogue status information S t An import retrieval decision-maker is used, which, based on a neural network, determines whether a retrieval is needed based on the user interaction information and the structured dialogue state information. If no retrieval is needed, the structured dialogue state information S is imported. t The noise-resistant inference module 130 is imported and processed. If retrieval is required, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain query results.

[0136] Specifically, in the aforementioned retrieval decision-maker's determination of whether a retrieval is needed based on the user interaction information and the structured dialogue state information using a neural network, the neural network structure of the retrieval decision-maker includes an input layer, a feature fusion layer, upper and lower feature extraction layers, and a decision layer; specifically,

[0137] The input layer receives the memory stack aggregation vector. With the current problem vector The current problem vector The input layer receives the memory stack aggregation vector obtained from the user interaction information received in step S10 above. The number of lines of structured dialogue state information S passed t get.

[0138] The feature fusion layer performs a nonlinear transformation on the concatenated feature vectors using the GELU activation function to obtain fused feature information. The GELU activation function satisfies the following:

[0139]

[0140] in, To fuse feature information, W f b f For trainable parameters, For the aggregation vector of the memory stack, This is the current problem vector;

[0141] The context feature extraction layer arranges the memory stack embedding vectors into a matrix in order, performs convolution using three types of convolution kernels, and each convolution kernel outputs 64 channels. After passing through the GELU activation function and Max-over-time pooling, the concatenation results in the context feature information.

[0142] The decision-making level integrates feature information. With contextual feature information The retrieval probability is output through a decision model trained on labeled dialogue data using a binary cross-entropy loss function. The decision model satisfies the following:

[0143]

[0144] W h b h W0 and b0 are trainable parameters. For contextual feature information, To fuse feature information, P retrieve This represents the retrieval probability.

[0145] When the retrieval probability P retrieve If the value exceeds the retrieval threshold, a retrieval is required. If the retrieval probability P... retrieve If the value is below the retrieval threshold, no retrieval is required. If no retrieval is needed, the user interaction information and the structured dialogue state information are imported into the noise-resistant inference engine. The specific working process of the noise-resistant inference engine will be discussed in detail in the noise-resistant inference module 130 below. It will not be repeated here. When the retrieval decision-maker determines that a retrieval is required, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain query result information R. t .

[0146] In more detail, the query generation model's workflow includes:

[0147] The user interaction information and the structured dialogue state information are imported into a fuzzy query determination model to determine whether the user interaction information and the structured dialogue state information need to be fuzzy retrieved.

[0148] In this detailed step, the user interaction information and the structured dialogue state information are only imported into the fuzzy query determination model when the retrieval decision-maker determines that a retrieval is required. The fuzzy query determination model takes the user interaction information and the structured dialogue state information as input, focuses on the completeness of core information, and determines whether it is a fuzzy query.

[0149] Specifically, the fuzzy query determination model, based on a domain dictionary and a NER (Named Entity Recognition) model, can extract key entities (such as technical terms, product names, people / scenes, etc.) from the user interaction information and the structured dialogue state information. If a key entity is missing (e.g., "the device" is not explicitly pointed to in "What are the parameters of this device?"), it is marked as requiring a fuzzy query. On the other hand, it determines whether the questions in the extracted user interaction information and the structured dialogue state information contain necessary constraints (such as time, scope, scene, etc.). If the question lacks necessary constraints (e.g., "How to apply for subsidies" does not specify the region or identity), it is determined that a fuzzy query is required.

[0150] If the fuzzy query determination model determines that no fuzzy query is needed, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain the query result information. If the model determines that a fuzzy query is needed, proactive clarification and completion information is initiated for the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain the query result information.

[0151] Specifically, the aforementioned initiative to clarify and complete information can be achieved through interactive decision tree processes. Clarification script templates are preset for different types of fuzzy queries, and a clear query is generated after multiple rounds of interaction to complete key information.

[0152] More specifically, the above-mentioned execution decision tree has built-in fuzzy query classification rules, matching scenarios according to the priority of "entity missing to condition missing to multi-dimensional missing". For example, if only the entity is missing (such as "what is the usage of this medicine"), the "entity clarification" branch is matched; for example, "Which item do you specifically refer to with the '[fuzzy reference]' you mentioned? Please supplement the name / identifier (such as model, number)".

[0153] If the entity is complete but the conditions are missing (e.g., "How to treat hypertension"), a "condition completion" branch will be matched. At the same time, standardized wording will be preset for different branches to avoid ambiguity. For example: "For an accurate answer, please provide [missing conditions] (e.g., application region / blood pressure value / allergy history)."

[0154] This step involves pushing clarification messages through the user interaction layer, receiving supplementary information from the user, and then using a fuzzy query judgment model to perform a second verification of the information's completeness. If there are still missing information, a second round of clarification is initiated (e.g., if the user only says "antihypertensive medication," ask "is it amlodipine or valsartan?"). After the information is completed, "clarity query marker V=0" is output.

[0155] After the key information is completed, the system integrates the original user interaction information, subsequent supplementary information, and structured dialogue state information into a complete requirement. The query generation model generates a precise retrieval query containing core entities and constraints, ensuring that subsequent knowledge base retrieval can locate highly relevant returned query results. t This provides high-quality knowledge input for the noise-resistant inference engine.

[0156] Specifically, the training process of the above query generation model reinforcement learning training includes:

[0157] A multi-dimensional fused state vector is constructed to characterize the training scenario. Specifically, a Transformer-based sequence generation network serves as the policy network. The encoder processes the input state features, and the decoder outputs the word sequence of the retrieval query. The network parameters are initialized using pre-trained BART-based weights. The training scenario consists of an external knowledge base and a golden answer annotation library. The external knowledge base provides retrieval feedback, and the golden answer annotation library provides the basis for semantic similarity determination.

[0158] An action is defined as a sequence of search query terms output by the query generation model. The action space is constrained by syntax validation and semantic relevance filtering. The semantic similarity between the generated query and the user's question is ≥0.5, and actions that are irrelevant to the needs are excluded. The action space must contain at least one key entity identified by the NER model (such as a disease or product name). The size of the constrained action space is greatly reduced, which significantly improves training efficiency and query effectiveness.

[0159] A multi-objective weighted reward function is used to guide the model to generate high-quality retrieval queries. This multi-objective weighted reward function guides the model r(s,a) to satisfy the following:

[0160]

[0161] Where: α, β, and γ are the weight coefficients after empirical optimization, BERTScore(R) t A gold ) for retrieving document collection R t With the golden answer A gold The maximum semantic similarity is calculated based on the word embedding similarity of the pre-trained language model; This is a standardized query length penalty. Including indicator functions for key entities; the above-mentioned standardized query length penalty can prevent the model from generating overly simplistic or redundant queries.

[0162] The policy network is trained and updated using a near-end policy optimization algorithm, and the policy network adopts a Transformer-based sequence generation network structure.

[0163] The noise-resistant reasoning module 130 is used to import the query result information and structured dialogue state information into the noise-resistant reasoning engine. The noise-resistant reasoning engine generates the enhanced answer and attention distribution corresponding to the structured dialogue state information based on the Large Language Model (LLM) and the Knowledge Perception Preference Optimization Model (KPO).

[0164] The noise-resistant reasoning module 130 utilizes a noise-resistant reasoning engine based on a large language model and a knowledge-aware preference optimization model, integrates dialogue context and reliable retrieval knowledge, and generates enhanced answers and attention distributions corresponding to the structured dialogue state information from the query result information and structured dialogue state information.

[0165] The structured dialogue state information mentioned above includes the current state of the memory stack, the dialogue behavior type / confidence / key entities of each memory unit, etc. Its core function is to provide dialogue context anchors (such as user history questions, core demand entities) for the Large Language Model (LLM) and avoid reasoning from deviating from the multi-turn dialogue scenario, such as key information such as "elderly woman" and "no history of drug allergies" in a medical scenario.

[0166] The above query result information R y The information obtained from the aforementioned retrieval control module 120 is an external knowledge source for the Large Language Model (LLM), but it may contain noisy information, such as documents unrelated to the core requirements or content with factual conflicts. This is the core target of the aforementioned noise-resistant inference engine. Specifically, the aforementioned noise-resistant inference engine includes the Large Language Model (LLM) and the Knowledge-Aware Preference Optimization Model (KPO). The training process of the KPO includes:

[0167] Constructing a knowledge conflict dataset, the process of which includes constructing a standard answer dataset A. + Negative example answer dataset A - and noise context dataset C.

[0168] The above standard answer dataset A + Based on the aforementioned user interaction information q, the most relevant document blocks are retrieved from the knowledge base. In this embodiment, the number of document blocks is 3, which are represented as: C rel =[c1,c2,c3], generally, these document blocks are written by domain experts or generated by a strong teacher model to produce the standard answer A. + .

[0169] The above noise context dataset C searches for the relationship between C and the knowledge base. rel Document blocks that contradict the facts. For example, C rel It is said that "the minimum area of ​​arable land plot is 200m²". 2 Then, search for "the minimum cultivated land area is 400m²". 2 "C" conflict Document. Incorporate a conflicting block into the above document block C. rel ,form Next, randomly select 1-2 blocks from documents whose topics are unrelated to the aforementioned user interaction information q, and mix them into the aforementioned document block C. rel Noise dataset C is formed in the middle noise Finally, a noise context dataset is formed.

[0170] The above noisy context dataset C and question q are input into the basic large language model LLM to generate enhanced answers and attention distributions.

[0171] The source tracing processing module 140 performs source tracing analysis on the enhanced answer, matches the enhanced answer with the corresponding source based on the attention distribution, constructs a source tracing mapping table, and outputs the enhanced answer and the source tracing mapping table.

[0172] In this step, the source tracing analysis matches the enhanced answer with the corresponding source based on the attention distribution obtained above, calculates the block-level source tracing score, and completes the matching of answer fragments with source blocks to generate a source tracing mapping table. The user interaction layer receives the final answer and the source tracing mapping table, and can highlight the answer and corresponding source document information and provide feedback to the user.

[0173] The system disclosed in this embodiment intelligently determines the retrieval timing based on the dynamic dialogue context state, enabling on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through a memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key conditions missing in user questions, completes information through multiple rounds of interaction, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing the system's credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value.

[0174] Another preferred embodiment of the present invention discloses a storage medium containing computer-executable instructions, which, when executed by a computer processor, implement the low-code development method based on a large language model described above.

[0175] The storage medium disclosed in this embodiment, by executing the method in the first preferred embodiment, intelligently determines the retrieval timing based on the dynamic dialogue context state, achieving on-demand retrieval, eliminating redundant computational overhead caused by "retrieving every question," improving response speed, and avoiding irrelevant information interfering with the reasoning focus. It fully utilizes structured dialogue history generation to enhance retrieval queries, resulting in more complete keywords and clearer semantics, significantly improving retrieval recall and accuracy, and providing high-quality reasoning basis for large models. Through the memory stack data structure, it achieves compression, abstraction, and structured representation of lengthy dialogue history, ensuring that downstream modules can efficiently utilize contextual information to support complex multi-turn dialogue reasoning. It automatically identifies key conditions missing in user questions, completes information through multi-turn interactions, transforming fuzzy queries into clear queries, significantly reducing the risk of model "illusion," and improving system robustness and user satisfaction. It accurately locates the specific source knowledge fragments corresponding to each fragment of the answer, providing an intuitive source traceability display, solving the problem of coarse or non-existent source traceability in existing technologies, and significantly enhancing system credibility and interpretability. By training with a knowledge conflict dataset and optimizing knowledge perception preferences, the large model's ability to resist interference in noisy environments is improved, ensuring that the reasoning process follows the most relevant and correct knowledge, guaranteeing the accuracy of the answer, and effectively overcoming the "weak state" defect of existing RAG technology. It provides a high-precision, high-reliability, and high-efficiency solution for complex multi-turn intelligent question answering in professional vertical fields, and has broad application prospects and practical value.

[0176] It should be noted that the computer storage medium described above in this disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof.

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

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

Claims

1. An adaptive retrieval and reasoning method based on memory stack and knowledge perception optimization, characterized in that, The method includes: Receive user interaction information and import the user interaction information into the created proxy memory stack to obtain structured dialogue state information; The user interaction information and the structured dialogue status information are imported into the retrieval decision-maker. The retrieval decision-maker uses a neural network to determine whether the user interaction information and the structured dialogue status information need to be retrieved. If retrieval is required, the user interaction information and the structured dialogue status information are imported into the query generation model to obtain query results. The query results and structured dialogue state information are imported into a noise-resistant inference engine. The noise-resistant inference engine generates enhanced answers and attention distributions corresponding to the structured dialogue state information based on a large language model and a knowledge-aware preference optimization model. The enhanced answer is subjected to source analysis. Based on the attention distribution, the enhanced answer is matched with the corresponding source, a source mapping table is constructed, and the enhanced answer and the source mapping table are output.

2. The method according to claim 1, characterized in that, The proxy memory stack includes a dialogue behavior classification model, a joint embedding computation model, and a confidence classification model. The behavior classification model classifies user interaction information using a fine-tuned BERT classifier. The joint embedding computation model normalizes the user interaction information by fusing semantic embedding and entity embedding. The confidence classification model classifies the user interaction information based on the log probability of the tokens generated by the large model and the confidence of the dialogue behavior classification.

3. The method according to claim 1, characterized in that, The method for updating the proxy memory stack includes: Check the proxy memory stack. If the proxy memory stack is empty, initialize it; and push the received user interaction information into the proxy memory stack as memory unit information. If the proxy memory stack is not empty, Based on the cosine similarity model, the joint embedding vector similarity information between the new memory unit and the top stack unit is obtained. The cosine similarity model satisfies: above formula S sim For cosine similarity information, Information for the top cell of the stack. For new memory unit information; When the cosine similarity information is higher than the similarity threshold, the new memory unit is concatenated to the top unit of the stack and the embedding vector and type of the top unit of the stack are recalculated; when the cosine similarity information is lower than the similarity threshold, the current memory stack is stored in long-term memory and a new stack containing the new memory unit is created; when the cosine similarity information is within the similarity threshold, the new memory unit is pushed onto the new stack.

4. The method according to claim 1, characterized in that, The method further includes importing the user interaction information and the structured dialogue state information into a retrieval decision-maker, wherein the retrieval decision-maker determines whether a retrieval is needed based on the user interaction information and the structured dialogue state information using a neural network. If no retrieval is required, the user interaction information and the structured dialogue state information are imported into the noise-resistant inference engine.

5. The method according to claim 1, characterized in that, If a retrieval is required, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain query result information, including: The user interaction information and the structured dialogue state information are imported into a fuzzy query determination model to determine whether the user interaction information and the structured dialogue state information need to be fuzzy searched. If no fuzzy search is required, the user interaction information and the structured dialogue state information are imported into the query generation model to obtain the query results. If a fuzzy search is required, proactive clarification and completion information is initiated based on the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain the query result information.

6. The method according to claim 5, characterized in that, If a fuzzy search is required, proactive clarification and completion information is initiated based on the user interaction information and the structured dialogue state information, and then imported into the query generation model to obtain query result information, including: The initiative to proactively clarify and complete information is achieved through decision tree interaction. Clarification script templates are preset for different types of fuzzy queries, and a clear query is generated after key information is completed through multiple rounds of interaction.

7. The method according to claim 1, characterized in that, In the process of determining whether a retrieval is needed based on the user interaction information and the structured dialogue state information using a neural network, the neural network structure of the retrieval decision-maker includes an input layer, a feature fusion layer, upper and lower feature extraction layers, and a decision layer; wherein... The input layer receives the memory stack aggregation vector. With the current problem vector The current problem vector The memory stack aggregation vector is obtained through the received user interaction information. The state information is obtained by structuring the number of lines in the dialogue. The feature fusion layer performs a nonlinear transformation on the concatenated feature vectors using the GELU activation function to obtain fused feature information. The GELU activation function satisfies the following: in, To fuse feature information, W f b f These are trainable parameters; The context feature extraction layer arranges the memory stack embedding vectors into a matrix in order, performs convolution using three types of convolution kernels, and each convolution kernel outputs 64 channels. After passing through the GELU activation function and Max-over-time pooling, the concatenation results in the context feature information. The decision-making level integrates feature information. With contextual feature information The retrieval probability is output through a decision model trained on labeled dialogue data using a binary cross-entropy loss function. The decision model satisfies the following: W h b h b0 are trainable parameters, P retrieve This represents the retrieval probability.

8. The method according to claim 1, characterized in that, The query generation model is trained based on reinforcement learning and includes: Construct a multi-dimensional fused state vector to characterize the training scenario; The action is defined as the sequence of search query terms output by the query generation model, and the action space is constrained by syntax validation and semantic relevance filtering. A multi-objective weighted reward function is used to guide the model in generating retrieval queries. This multi-objective weighted reward function guides the model r(s,a) to satisfy the following: Where: α, β, and γ are the weight coefficients after empirical optimization, BERTScore(R) t A gold ) for retrieving document collection R t With the golden answer A gold The maximum semantic similarity is calculated based on the word embedding similarity of the pre-trained language model; This is a standard query length penalty term; Include indicator functions for key entities; The policy network is trained and updated using a near-end policy optimization algorithm, and the policy network adopts a Transformer-based sequence generation network structure.

9. An adaptive retrieval and reasoning system based on memory stack and knowledge perception optimization, characterized in that, The system includes: The memory management module is used to receive user interaction information and import the user interaction information into the created proxy memory stack to obtain structured dialogue state information. The retrieval control module is used to import the user interaction information and the structured dialogue status information into the retrieval decision-maker. The retrieval decision-maker uses a neural network to determine whether the user interaction information and the structured dialogue status information need to be retrieved. If retrieval is required, the user interaction information and the structured dialogue status information are imported into the query generation model to obtain query result information. The noise-resistant reasoning module is used to import the query result information and structured dialogue state information into the noise-resistant reasoning engine. The noise-resistant reasoning engine generates the enhanced answer and attention distribution corresponding to the structured dialogue state information based on the large language model and the knowledge perception preference optimization model. The source tracing module is used to perform source tracing analysis on the enhanced answer, match the enhanced answer with the corresponding source based on the attention distribution, construct a source tracing mapping table, and output the enhanced answer and the source tracing mapping table.