A dynamic search-enhanced generation defense method and system
By employing a dynamic retrieval-enhanced generation defense method based on graph energy minimization and Bayesian memory, the problems of poor adaptability and high storage cost of retrieval-enhanced generation systems in dynamic environments are solved. This method achieves efficient defense and accurate generation, improving the robustness and resource utilization efficiency of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING UNIV
- Filing Date
- 2026-04-10
- Publication Date
- 2026-07-21
AI Technical Summary
Existing Retrieval Enhancement Generation (RAG) defense technologies are poorly adaptable to dynamic environments, have huge storage overhead, and are difficult to cope with continuously evolving attacks. They cannot effectively distinguish between legitimate knowledge updates and malicious attack variants, and lack a globally consistent screening mechanism, resulting in decreased system robustness and high storage costs.
We adopt a dynamic retrieval-enhanced generative defense method based on graph energy minimization and Bayesian memory. By constructing a graph cut model and a Bayesian memory update mechanism, we dynamically filter reliable content to achieve efficient defense against adversarial attacks and balance the stability and flexibility of the system with extremely low storage costs.
It significantly improves the system's robustness and response quality in complex adversarial environments, reduces the storage cost per query, enhances its adaptability to new knowledge and the accuracy of generated answers, and reduces resource consumption.
Smart Images

Figure CN122432280A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a security defense technology for a retrieval augmentation generation (RAG) system, specifically a dynamic retrieval augmentation generation defense method and system based on graph energy minimization and Bayesian memory. In dynamic retrieval environments (such as web search), it utilizes graph theory models and Bayesian inference to defend against retrieval content corruption. The aim is to solve the problems of adversarial attack defense and storage efficiency optimization in multi-turn dynamic interactions, and belongs to the field of artificial intelligence and natural language processing technology. Background Technology
[0002] With the remarkable capabilities of Large Language Models (LLMs) in natural language understanding and generation tasks, their potential in knowledge-intensive applications has gained widespread recognition. However, LLMs still face the challenge of generating illusions or unsubstantiated content. To address this issue, Retrieval-Enhanced Generation (RAG) techniques have emerged, enhancing the accuracy and credibility of models by introducing external evidence retrieval during the generation process. Early RAG systems primarily operated in static environments, relying on fixed corpora as their knowledge base. In recent years, research has gradually shifted towards RAGs based on dynamic web search, which can continuously absorb updated information from evolving sources such as the Internet and are widely used in modern search engines and intelligent assistants. To improve system robustness, existing technologies have proposed a series of defense mechanisms, mainly including document preprocessing and filtering before generation (such as Self-RAG and CRAG) and defense strategies against adversarial attacks (such as RobustRAG), aiming to mitigate the interference of erroneous information by evaluating and filtering the retrieved content.
[0003] However, despite the progress made by existing Retrieval Augmentation (RAG) and its defense techniques in static environments, significant technical bottlenecks remain when facing dynamic and continuously evolving web search applications. Specifically, existing defense mechanisms are primarily designed for static corpora and lack explicit modeling of temporal dynamics. This makes them ill-equipped to deal with continuously evolving attack methods such as corpus poisoning and hint injection, resulting in an inability to effectively distinguish between legitimate knowledge updates and malicious attack variants. The robustness of the system drops significantly when facing instantaneous or sudden threats. Furthermore, simply extending such static defenses to dynamic environments typically requires archiving all historical retrieval documents for retrospective verification. This leads to storage overhead increasing linearly or even exponentially over time, placing an unbearable burden on memory and computation for large-scale deployments. More critically, existing technologies cannot effectively solve the fundamental dilemma of "stability-plasticity," namely, the difficulty in intelligently balancing adherence to historically correct beliefs (stability) and adaptation to newly emerging evidence (plasticity) without storing large amounts of original data. This often results in a deadlock of neglecting updates due to over-reliance on history or being misled by blindly trusting new retrieval content.
[0004] Therefore, to further develop dynamic retrieval-enhanced generation technology, a more efficient and robust solution is needed that can effectively defend against dynamically evolving adversarial attacks, achieve adaptive knowledge updates with extremely low storage costs, and effectively balance system stability and flexibility. These technical challenges are precisely the problems that this invention aims to solve. Summary of the Invention
[0005] Purpose of the invention: To address the shortcomings of existing Retrieval Enhancement Generation (RAG) defense techniques, such as poor adaptability in dynamic environments, huge storage overhead, and difficulty in dealing with continuously evolving attacks, a dynamic RAG defense framework (RADAR) based on graph theory and Bayesian inference is proposed. This framework effectively balances the stability and flexibility of the system with extremely low storage costs, and significantly improves the robustness and response quality of the system in complex adversarial environments.
[0006] The specific technical issues are as follows: (1) Existing defenses fail in dynamic environments: Existing defense mechanisms (such as RobustRAG) are mainly designed for static environments, assuming that the corpus is a fixed snapshot. However, in practical applications such as dynamic web search, attackers can carry out continuous and evolving attacks (such as corpus poisoning and hint injection), causing the retrieved content to become corrupted over time. Due to the lack of explicit modeling of the time dynamics, existing static defense methods cannot effectively distinguish between "new legitimate knowledge updates" and "variants of malicious attacks," resulting in a significant decrease in defense effectiveness when facing constantly evolving threats, and failing to meet the security requirements of dynamic RAG.
[0007] (2) High storage overhead caused by dynamic defense: If the existing static defense method is simply extended to a dynamic environment, it is usually necessary to archive all historically retrieved original documents so that backtracking verification and consistency maintenance can be performed in each round of generation. In long-running dynamic search scenarios, this approach will cause storage costs to increase linearly or even exponentially with the number of interactions (for example, processing a single problem may require about 30MB of storage space). In actual large-scale deployments, this will consume huge amounts of memory and computing resources, which will greatly limit the scalability of the system.
[0008] (3) The dilemma of balancing stability and plasticity: In dynamic RAG, the system faces a dual challenge: maintaining the "stability" of historically correct knowledge to prevent being misled by sudden malicious attacks; and possessing the "plasticity" to new knowledge to adapt to legitimate knowledge updates in a timely manner. Existing technologies often compromise one aspect for the other: simple static model reuse ignores temporal continuity, leading to unstable predictions; while over-reliance on historical information hinders adaptation to new knowledge. Existing technologies lack a mechanism that can intelligently and dynamically balance the reliability of historical beliefs and new evidence without storing large amounts of original data.
[0009] (4) Lack of a reliable context-based filtering mechanism with global consistency: Existing document filtering methods (such as Self-RAG, CRAG, etc.) focus on the quality assessment of individual documents or simple voting mechanisms, often failing to fully explore the complex semantic and logical relationships (such as implication and contradiction) within the retrieved document set. When facing complex adversarial attacks, malicious documents injected by attackers may appear to be of high quality locally. Existing technologies lack a rigorous mathematical framework (such as the graph cut minimization energy function used in this invention), making it difficult to accurately identify and remove malicious content from a global perspective by utilizing the mutual corroboration relationships between documents, thus resulting in less robust generated answers.
[0010] Technical Solution: A dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory is proposed. It constructs an energy minimization model based on graph cuts, dynamically filtering reliable retrieval content by simulating continuous and evolving attacker attacks. Specifically, it can be divided into three core stages: minimizing energy graph construction, dynamic defense and Bayesian memory updating, and final answer generation.
[0011] (1) Minimize energy graph construction This stage aims to transform the problem of selecting reliable documents for retrieval into an energy minimization problem in graph theory, which is divided into three parts: The first part is atomic answer generation and NLI scoring. For each retrieved document... First, a generator is used to generate an "atomic answer". This refers to a short answer generated solely based on the document's content. Subsequently, a Natural Language Inference (NLI) model is used to calculate the pairwise entailment and contradiction relationships between documents, constructing similarity matrices accordingly. and conflict matrix The purpose of this step is to quantify the semantic consistency and degree of conflict between documents, providing a basis for edge weights in subsequent graph construction.
[0012] The second part is the calculation of eigenvector centrality, based on the similarity matrix. Calculate the eigenvector centrality of each document. This metric reflects how well a document aligns with global consensus; higher centrality indicates a document is more likely to contain accurate information. Its purpose is to identify core documents that are consistent with the majority of search results, serving as a priori basis for judging reliability.
[0013] The third part is the graph structure definition. It involves constructing a graph containing the source node. (Representing "reliable / correct") and sink node A directed graph representing "unreliable / error". Each document As a node, respectively with and connect.
[0014] Source ( ) capacity This indicates the benefit of retaining the document, derived from the document's centrality. The ranking decay function determines the ranking.
[0015] Huibian ( ) capacity The benefit of filtering this document is determined by the average degree of conflict between this document and other highly central documents.
[0016] document margins ( The capacity of ) is determined by similarity The decision is used to penalize semantically consistent documents that are assigned to different categories. Its aim is to find the globally optimal solution using a graph cut algorithm (Min-Cut) that maximizes the internal consistency of the retained document set while minimizing conflicts.
[0017] (2) Dynamic defense and Bayesian memory update This phase aims to address the issue of time continuity in dynamic environments, and is specifically divided into two parts: The first part introduces memory nodes. (In time step) At that time, a special memory node is introduced into the graph. This represents the final answer generated in the previous time step. This node is also related to... , It also connects to all new document nodes at the current moment. The aim is to explicitly incorporate historical knowledge into the decision-making process at the current moment, resolving the trade-off between stability and plasticity.
[0018] The second part is Bayesian belief updating. It utilizes Bayesian inference to update memory nodes and... , The capacity of the connected edges.
[0019] Memory - Source ( ) capacity This represents the posterior probability that the historical answer is still correct. It incorporates the prior confidence level from the previous time step. And the likelihood of the current new document supporting historical answers. Perform the calculation.
[0020] Memory - Huibian ( ) capacity The posterior probability representing an outdated historical answer is combined with the prior conflict confidence level. And the likelihood of opposition to historical answers in the current new document. The calculation aims to dynamically adjust the level of trust in historical information based on new evidence: if new evidence supports the historical answer, its retention probability is increased; if new evidence strongly refutes it, its filtering probability is increased.
[0021] (3) Generation of the final answer This stage aims to generate a final response based on the selected reliable content, and it consists of two parts: The first part is the minimum cut reasoning and post-processing. The maximum flow minimum cut algorithm is used to partition the constructed graph, identifying the source set. (Reliable) and aggregation (Unreliable). Reserved source set The documents in the dataset are analyzed, and their mean cosine similarity is calculated. Isolated documents or those that do not conform to the semantics of the group are removed to obtain the final reliable set. .
[0022] The second part is restricted generation. The filtered, reliable atomic answers are concatenated as context and input into the generator. A specific prompt word forces the model to synthesize only the provided reference answer, strictly prohibiting the addition of external information or independent interpretation. Simultaneously, based on the generated final answer... Update the prior probability for the next time step. and This completes the closed loop. Its purpose is to ensure that the output content is strictly anchored to verified and reliable evidence, minimizing interference from illusions and malicious content.
[0023] The dynamic retrieval-enhanced generative defense method based on graph energy minimization and Bayesian memory is implemented through the following steps: Step 1, Input reception: at time step Receive user queries and the document stream returned by the search engine .
[0024] Step 2, Atomic Answer Generation: (The rest of the text appears to be incomplete and requires further context.) Each document in Use a generator to generate independent atomic answers. .
[0025] Step 3, NLI Relation Calculation: Utilize a natural language reasoning model to calculate the pairwise implication scores between atomic answers and construct a similarity matrix. and conflict matrix .
[0026] Step 4, Centrality Calculation: Based on Matrix Calculate the eigenvector centrality of each document , as the initial weight for its reliability.
[0027] Step 5, Static Graph Construction: Construct a graph containing source nodes. Sink node and document nodes The graph. The source edge capacity of each node is calculated based on document centrality, retrieval ranking, and conflict level. and confluence capacity The edge capacity between documents is calculated based on similarity.
[0028] Step 6, Dynamic Memory Injection (if) ): Introduce a memory node representing the answer from the previous time step. Calculate the support level of the new document for the old answer. and opposition .
[0029] Step 7, Bayesian capacity update (if) Using Bayes' theorem, combined with prior information from the previous time step: and Calculate the source edge capacity of the memory node. and confluence capacity Add it to the diagram.
[0030] Step 8, Minimum Cut Reasoning: Run the maximum flow minimum cut algorithm to partition the graph, dividing the nodes into "reliable sets". And "unreliable sets" .
[0031] Step 9, Outlier Filtering: For reliable sets The documents in the text are calculated with mean cosine similarity, and those with similarity below a threshold are removed. From isolated documents, a final reliable set is obtained. .
[0032] Step 10, Final Answer Generation: Generate the final reliable set The atomic answers are concatenated, and the input generator produces the final answer at the current moment. .
[0033] Step 11, Prior Update: Calculate the final answer at the current time step. The consistency and conflict level with the current document set are used to update the prior probabilities for the next time step. and ,for Always be prepared.
[0034] Step 12, Output and Loop: Output the final answer. Then, proceed to the next time step to wait for new retrieval data.
[0035] A dynamic retrieval enhancement generative defense system based on graph energy minimization and Bayesian memory includes a minimum energy graph construction module, a dynamic defense and Bayesian memory update module, and a final answer generation module.
[0036] The energy minimization graph construction module aims to transform the reliability selection problem of retrieved documents into an energy minimization problem in graph theory, and is specifically divided into three parts: The first part is atomic answer generation and NLI scoring. For each retrieved document... First, a generator is used to generate an "atomic answer". This refers to a short answer generated solely based on the document's content. Subsequently, a Natural Language Inference (NLI) model is used to calculate the pairwise entailment and contradiction relationships between documents, constructing similarity matrices accordingly. and conflict matrix The purpose of this step is to quantify the semantic consistency and degree of conflict between documents, providing a basis for edge weights in subsequent graph construction.
[0037] The second part is the calculation of eigenvector centrality, based on the similarity matrix. Calculate the eigenvector centrality of each document. This metric reflects how well a document aligns with global consensus; higher centrality indicates a document is more likely to contain accurate information. Its purpose is to identify core documents that are consistent with the majority of search results, serving as a priori basis for judging reliability.
[0038] The third part is the graph structure definition. It involves constructing a graph containing the source node. (Representing "reliable / correct") and sink node A directed graph representing "unreliable / error". Each document As a node, respectively with and connect.
[0039] Source ( ) capacity This indicates the benefit of retaining the document, derived from the document's centrality. The ranking decay function determines the ranking.
[0040] Huibian ( ) capacity The benefit of filtering this document is determined by the average degree of conflict between this document and other highly central documents.
[0041] document margins ( The capacity of ) is determined by similarity The decision is used to penalize semantically consistent documents that are assigned to different categories. Its aim is to find the globally optimal solution using a graph cut algorithm (Min-Cut) that maximizes the internal consistency of the retained document set while minimizing conflicts.
[0042] The dynamic defense and Bayesian memory update module aims to solve the problem of time continuity in dynamic environments, and is specifically divided into two parts: The first part introduces memory nodes. (In time step) At that time, a special memory node is introduced into the graph. This represents the final answer generated in the previous time step. This node is also related to... , It also connects to all new document nodes at the current moment. The aim is to explicitly incorporate historical knowledge into the decision-making process at the current moment, resolving the trade-off between stability and plasticity.
[0043] The second part is Bayesian belief updating. It utilizes Bayesian inference to update memory nodes and... , The capacity of the connected edges.
[0044] Memory - Source ( ) capacity This represents the posterior probability that the historical answer is still correct. It incorporates the prior confidence level from the previous time step. And the likelihood of the current new document supporting historical answers. Perform the calculation.
[0045] Memory - Huibian ( ) capacity The posterior probability representing an outdated historical answer is combined with the prior conflict confidence level. And the likelihood of opposition to historical answers in the current new document. The calculation aims to dynamically adjust the level of trust in historical information based on new evidence: if new evidence supports the historical answer, its retention probability is increased; if new evidence strongly refutes it, its filtering probability is increased.
[0046] The final answer generation module aims to generate a final response based on the selected reliable content, and it consists of two parts: The first part is the minimum cut reasoning and post-processing. The maximum flow minimum cut algorithm is used to partition the constructed graph, identifying the source set. (Reliable) and aggregation (Unreliable). Reserved source set The documents in the dataset are analyzed, and their mean cosine similarity is calculated. Isolated documents or those that do not conform to the semantics of the group are removed to obtain the final reliable set. .
[0047] The second part is restricted generation. The filtered, reliable atomic answers are concatenated as context and input into the generator. A specific prompt word forces the model to synthesize only the provided reference answer, strictly prohibiting the addition of external information or independent interpretation. Simultaneously, based on the generated final answer... Update the prior probability for the next time step. and This completes the closed loop. Its purpose is to ensure that the output content is strictly anchored to verified and reliable evidence, minimizing interference from illusions and malicious content.
[0048] The implementation process and methods of the system are the same and will not be described again.
[0049] Beneficial Effects: This invention provides an end-to-end defense solution for dynamic retrieval enhancement generation systems. This solution achieves efficient and accurate defense against content corruption (such as corpus poisoning and hint injection) by constructing a graph-cut-based energy minimization model and combining it with a Bayesian memory update mechanism. In dynamically evolving attack environments, the method significantly improves the system's response accuracy and reduces the attack success rate (ASR). For example, under the most challenging first-pick hint injection attack, the accuracy reaches 63.60%, representing a breakthrough in robustness compared to existing technologies (such as ReliabilityRAG's 53.61%). Simultaneously, this invention employs Bayesian memory node technology, maintaining the "stability" of historically correct knowledge while possessing keen "plasticity" for new knowledge, enabling adaptive handling of threats evolving over time. Furthermore, by optimizing the storage mechanism, this method completely overcomes the drawback of traditional dynamic defenses requiring the archiving of massive historical documents, significantly reducing the storage cost per query from approximately 30MB in existing technologies to only approximately 1KB, greatly reducing system resource consumption and storage pressure. By leveraging Natural Language Inference (NLI)-driven global consistency verification, this invention effectively enhances the model's generalization ability in the face of complex adversarial attacks, enabling it to better adapt to constantly changing attack strategies and new tasks. The method further simplifies the cleaning process for dynamic data streams, achieving fully automated security protection from retrieval to generation, and improving the real-time performance and reliability of operations. Through dynamic graph construction and minimum cut inference techniques, this invention can more flexibly handle data from untrusted sources (such as open networks), improving the adaptability of data processing. This invention can be widely applied in artificial intelligence fields such as real-time web search engines, large-scale language model intelligent assistants, and decision support systems, and has broad market application prospects. Attached Figure Description
[0050] Figure 1 shows the overall architecture and processing flow of the Adversarial Defense Framework (RADAR) for Dynamic Retrieval Enhancement Generation System described in this invention. Detailed Implementation
[0051] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading the present invention, any modifications of the present invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.
[0052] A dynamic retrieval augmentation generative defense method based on graph energy minimization and Bayesian memory is proposed. Targeting the adversarial defense framework (RADAR) of dynamic retrieval augmentation generative systems, this method models context filtering as a graph cut problem, constructs a flow network using geometrically averaged symmetric natural language inference (NLI) scoring, and introduces Bayesian memory nodes to process dynamic data flows. The implementation steps of the dynamic retrieval augmentation generative defense method based on graph energy minimization and Bayesian memory are as follows: Step 1, Input reception: at time step Receive user queries and the document stream returned by the search engine .
[0053] Step 2, Atomic Answer Generation: (The rest of the text appears to be incomplete and requires further context.) Each document in Use a generator to generate independent atomic answers. .
[0054] Step 3, NLI Relation Calculation: Utilize a natural language reasoning model to calculate the pairwise implication scores between atomic answers and construct a similarity matrix. and conflict matrix .
[0055] Step 4, Centrality Calculation: Based on Matrix Calculate the eigenvector centrality of each document , as the initial weight for its reliability.
[0056] Step 5, Static Graph Construction: Construct a graph containing source nodes. Sink node and document nodes The graph. The source edge capacity of each node is calculated based on document centrality, retrieval ranking, and conflict level. and confluence capacity The edge capacity between documents is calculated based on similarity.
[0057] Step 6, Dynamic Memory Injection (if) ): Introduce a memory node representing the answer from the previous time step. Calculate the support level of the new document for the old answer. and opposition .
[0058] Step 7, Bayesian capacity update (if) Using Bayes' theorem, combined with prior information from the previous time step: and Calculate the source edge capacity of the memory node. and confluence capacity Add it to the diagram.
[0059] Step 8, Minimum Cut Reasoning: Run the maximum flow minimum cut algorithm to partition the graph, dividing the nodes into "reliable sets". And "unreliable sets" .
[0060] Step 9, Outlier Filtering: For reliable sets The documents in the text are calculated with mean cosine similarity, and those with similarity below a threshold are removed. From isolated documents, a final reliable set is obtained. .
[0061] Step 10, Final Answer Generation: Generate the final reliable set The atomic answers are concatenated, and the input generator produces the final answer at the current moment. .
[0062] Step 11, Prior Update: Calculate the final answer at the current time step. The consistency and conflict level with the current document set are used to update the prior probabilities for the next time step. and ,for Always be prepared.
[0063] Step 12, Output and Loop: Output the final answer. Then, proceed to the next time step to wait for new retrieval data.
[0064] The specific implementation method is as follows: I. Method Overview and Structural Framework This method is based on a dynamic RAG architecture and mainly consists of three core processing stages: Atomic answer generation and NLI scoring: Transform retrieved documents into independent viewpoints and calculate logical relationships.
[0065] Minimum Cut Graph Construction and Reasoning: Construct an energy-minimizing graph containing source, sink, document, and memory nodes.
[0066] Dynamic Bayesian Update: Updates the confidence level of historical answers based on new evidence.
[0067] 2. Best practice for constructing minimum cut graphs To achieve precise contextual filtering, a flow network graph is constructed. The specific construction steps and formulas are as follows: (1) Atomic answer generation: For the retrieved document set Each document in Generate atomic answers using a generator. The calculation formula is as follows: in, It is an atomic answer generated based on a single document; It is a large language generation model (such as GPT-4o or DeepSeek); It is a user query; It is the first The retrieved documents.
[0068] (2) NLI matrix construction (symmetry processing): The logical relationships between atomic answer pairs are calculated using a Natural Language Inference (NLI) model. To eliminate directional bias, this embodiment employs geometric averaging for symmetry processing. Similarity matrix (Based on implied probability): in, It is a document and Symmetric similarity score between them; The NLI model predicts the atomic answer. Contains The probability value; It is an atomic answer. Contains The probability value.
[0069] Conflict Matrix (Based on the probability of contradiction): in, It is a document and Symmetrical conflict scores between them; The NLI model predicts the atomic answer. and Contradictory probability values; It is an atomic answer. and Conflicting probability values.
[0070] (3) Calculation of eigenvector centrality: Based on similarity matrix (Add self-loop) ,in The principal eigenvectors are calculated using the power iteration method. and normalized to The interval. Wherein, Document The eigenvector centrality score reflects the degree of consistency between the document and the consensus of the global search results.
[0071] (4) Definition of graph structure and edge capacity Build a system containing source nodes (Reserved), Sink node (Filtering) and the graph of document nodes.
[0072] Source-edge capacity ( ): in, It is the source node Point to document node The capacity of directed edges; It is a document The centrality score; It is the ranking index of the document in the search list (starting from 1); This is the total number of documents retrieved (e.g., 10 or 50). It is an exponential function used to reduce the weight of low-ranked documents.
[0073] Edge capacity ( ): in, It is a document node Point to sink node The capacity of directed edges; It is a document and Conflict scores between them; It is a neighbor document Central score; summation symbol Indicates the exclusion All documents except those listed are weighted and summed.
[0074] Document margin capacity: connections and The capacity is This is used to punish violations of semantic consistency.
[0075] III. Best Practices for Dynamic Bayesian Memory Update exist In dynamic scenarios, memory nodes are introduced. (The final answer from the previous time step), and update its connection weights using Bayesian rules: Likelihood estimation: Calculates the current new document set Support for historical answers and degree of rebuttal : in, It is the support likelihood value at the current moment; This represents the total number of new documents retrieved at the current moment. It is the first in the search set One document; Is it the answer of history and the first Implied scores between new documents.
[0076] in, It is the conflict likelihood value at the current moment; Is it the answer of history and the first The contradictory scores between the new documents.
[0077] Bayesian capacity update: Calculate the edge capacity of the memory node by combining the prior probability from the previous time step. Memory - Source ( ): in, It is a memory node Connect to the source node Update capacity (posterior probability); It was the previous moment The prior reliability probability calculated at the end; It is the support likelihood value at the current moment.
[0078] Memory - Huibian ( ): in, It is a memory node Connect to the sink node Update capacity (posterior probability); It was the previous moment The prior conflict probability calculated at the end; It is the conflict likelihood value at the current moment.
[0079] Fourth, Reasoning, Generation, and State Loops Minimum cut solution: The maximum flow minimum cut is solved using the Highest Label Preflow Push (HLPP) algorithm. The cut set partitions the nodes into source sets. (Reliable) and aggregation (Unreliable).
[0080] Post-processing: Calculate the source set The average cosine similarity of Chinese documents is used to remove documents with similarity below a threshold. Isolated document: in, It is the final collection of reliable documents selected; This is the initial source set selected by the minimum cut algorithm; It is a document Mean cosine similarity with other documents in the set; This is a preset filtering threshold, which is set to 0.3 in this embodiment.
[0081] Prior state update: based on the generated final answer Calculate the prior probability for the next time step: in, and They are used for The new prior reliability and prior conflict probability at each moment; It is the total number of new documents retrieved at the current moment (i.e. ); It is the final answer generated at the current moment; It is the first in the search set One document.
[0082] 5. Specific Implementation Parameter Configuration To ensure the reproducibility of the technical solution, the specific parameter configurations are as follows: NLI model: using DeBERTa-v3-large-mnli with a batch size of 16.
[0083] Generative models: DeepSeek-V3, GPT-4o, or Grok-4-fast.
[0084] Search volume : 10 or 50.
[0085] Centrality calculation parameter: smoothing term Number of exponentiation iterations .
[0086] Post-processing threshold : 0.3.
[0087] Hardware environment: Single NVIDIA RTX 4090 GPU.
[0088] Detailed instructions for reproducing the invention: Technicians can construct the graph structure using Python's networkx library and implement the HLPP algorithm using the scipy library. The NLI part loads the HuggingFace open-source model. The matrices and edge weights are calculated according to the above formulas; reproducing the algorithm requires only inference, without needing to retrain a large model.
Claims
1. A dynamic retrieval-enhanced generative defense method based on graph energy minimization and Bayesian memory, characterized in that, The implementation steps are as follows: Step 1, Input reception: at time step Receive user queries and the document stream returned by the search engine ; Step 2, Atomic Answer Generation: (The rest of the text appears to be incomplete and requires further context.) Each document in Use a generator to generate independent atomic answers. ; Step 3, NLI Relation Calculation: Utilize a natural language reasoning model to calculate the pairwise implication scores between atomic answers and construct a similarity matrix. and conflict matrix ; Step 4, Centrality Calculation: Based on Matrix Calculate the eigenvector centrality of each document , as the initial weight for its reliability; Step 5, Static Graph Construction: Construct a graph containing source nodes. Sink node and document nodes The graph; calculate the source edge capacity of each node based on document centrality, retrieval ranking, and conflict level. and confluence capacity Calculate the edge capacity between documents based on similarity; Step 6, Dynamic Memory Injection (if) ): Introduce a memory node representing the answer from the previous time step. ; Calculate the support level of the new document for the old answer. and opposition ; Step 7, Bayesian capacity update (if) Using Bayes' theorem, combined with prior information from the previous time step: and Calculate the source edge capacity of the memory node. and confluence capacity Add it to the diagram; Step 8, Minimum Cut Reasoning: Run the maximum flow minimum cut algorithm to partition the graph, dividing the nodes into reliable sets. and unreliable sets ; Step 9, Outlier Filtering: For reliable sets The documents in the text are calculated with mean cosine similarity, and those with similarity below a threshold are removed. From isolated documents, a final reliable set is obtained. ; Step 10, Final Answer Generation: Generate the final reliable set The atomic answers are concatenated, and the input generator produces the final answer at the current moment. ; Step 11, Prior Update: Calculate the final answer at the current time step. The consistency and conflict level with the current document set are used to update the prior probabilities for the next time step. and ; Step 12, Output and Loop: Output the final answer. Then, proceed to the next time step to wait for new retrieval data.
2. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 2, for the retrieved document set Each document in Generate atomic answers using a generator. The calculation formula is as follows: in, It is an atomic answer generated based on a single document; It is a large language generation model; It is a user query; It is the first The retrieved documents.
3. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 3, the logical relationship between atomic answer pairs is calculated using a natural language reasoning model; to eliminate directional bias, geometric mean is used for symmetry processing. Similarity matrix : in, It is a document and Symmetric similarity score between them; The NLI model predicts the atomic answer. Contains The probability value; It is an atomic answer. Contains The probability value; Conflict Matrix : in, It is a document and Symmetrical conflict scores between them; The NLI model predicts the atomic answer. and Contradictory probability values; It is an atomic answer. and Conflicting probability values.
4. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 4, based on the similarity matrix The principal eigenvectors are calculated using the power iteration method. and normalized to The interval; where, Document The eigenvector centrality score reflects the degree of consistency between the document and the consensus of the global search results.
5. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 5, a system containing source nodes is constructed. Sink node A graph of document nodes; Source-edge capacity ( ): in, It is the source node Point to document node The capacity of directed edges; It is a document The centrality score; It is the ranking index of the document in the search list; It represents the total number of documents retrieved; It is an exponential function used to reduce the weight of low-ranked documents; Edge capacity ( ): in, It is a document node Point to sink node The capacity of directed edges; It is a document and Conflict scores between them; It is a neighbor document Central score; summation symbol Indicates the exclusion All documents except those listed are summed using a weighted average. Document margin capacity: connections and The capacity is This is used to punish violations of semantic consistency.
6. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 6, In dynamic scenarios, memory nodes are introduced. This is the final answer from the previous time step, and its connection weights are updated using Bayesian rules: Likelihood estimation: Calculates the current new document set Support for historical answers and degree of rebuttal : in, It is the support likelihood value at the current moment; This represents the total number of new documents retrieved at the current moment. It is the first in the search set One document; Is it the answer of history and the first Implied scores among new documents; in, It is the conflict likelihood value at the current moment; Is it the answer of history and the first The contradictory scores between the new documents.
7. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, In step 7, the Bayesian capacity is updated by combining the prior probabilities from the previous time step with the edge capacity of the memory node. Memory - Source ( ): in, It is a memory node Connect to the source node Update capacity; It was the previous moment The prior reliability probability calculated at the end; It is the support likelihood value at the current moment; Memory - Huibian ( ): in, It is a memory node Connect to the sink node Update capacity (posterior probability); It was the previous moment The prior conflict probability calculated at the end; It is the conflict likelihood value at the current moment.
8. The dynamic retrieval enhancement generative defense method based on graph energy minimization and Bayesian memory according to claim 1, characterized in that, Minimum cut solution: The maximum flow minimum cut is solved using the highest label pre-flow push algorithm; the cut set partitions the nodes into source sets. and convergence ; Post-processing: Calculate the source set The average cosine similarity of Chinese documents is used to remove documents with similarity below a threshold. Isolated document: in, It is the final collection of reliable documents selected. This is the initial source set selected by the minimum cut algorithm; It is a document Mean cosine similarity with other documents in the set; It is the preset filtering threshold; Prior state update: based on the generated final answer Calculate the prior probability for the next time step: in, and They are used for The new prior reliability and prior conflict probability at each moment; It is the total number of new documents retrieved at the current moment (i.e. ); It is the final answer generated at the current moment; It is the first in the search set One document.
9. A dynamic retrieval-enhanced generative defense system based on graph energy minimization and Bayesian memory, characterized in that, It includes a module for minimizing the energy graph, a module for dynamic defense and Bayesian memory update, and a module for generating the final answer; The energy minimization graph construction module aims to transform the reliability selection problem of retrieved documents into an energy minimization problem in graph theory. The dynamic defense and Bayesian memory update module aims to solve the problem of time continuity in dynamic environments, and is specifically divided into two parts: The first part introduces memory nodes; in the time step At that time, a special memory node is introduced into the graph. This node represents the final answer generated in the previous moment; this node is also related to... , And connect to all new document nodes at the current moment; The second part is Bayesian belief updating; updating memory nodes using Bayesian inference. , Connected edge capacity; Memory - Source ( ) capacity The posterior probability that the historical answer is still correct; Memory - Huibian ( ) capacity The posterior probability that a historical answer is outdated; The final answer generation module aims to generate a final response based on the selected reliable content, and it consists of two parts: The first part is minimum cut reasoning and post-processing; the maximum flow minimum cut algorithm is used to partition the constructed graph and divide it into source sets. and convergence ;Preserve source set The documents in the dataset are analyzed, and their mean cosine similarity is calculated. Isolated documents or those that do not conform to the semantics of the group are removed to obtain the final reliable set. ; The second part is restricted generation; the filtered reliable atomic answers are concatenated as context and input into the generator; specific prompts force the model to synthesize only the provided reference answers; simultaneously, based on the generated final answer... Update the prior probability for the next time step. and This completes the closed loop; The energy minimization graph construction module aims to transform the reliability selection problem of retrieved documents into an energy minimization problem in graph theory.
10. The dynamic retrieval enhanced generative defense system based on graph energy minimization and Bayesian memory as described in claim 9, characterized in that, The minimum energy map construction module is specifically divided into three parts: The first part is atomic answer generation and NLI scoring; for each retrieved document... First, a generator is used to generate an "atomic answer". This refers to a short answer generated solely based on the content of that document. Subsequently, a natural language reasoning model was used to calculate the implication and contradiction relationships between each document, and similarity matrices were constructed accordingly. and conflict matrix ; The second part is the calculation of eigenvector centrality; based on the similarity matrix. Calculate the eigenvector centrality of each document. ; The third part is the graph structure definition; constructing a graph containing the source node. Hehui Node A directed graph; each document As a node, respectively with and connect; Source ( ) capacity This indicates the benefit of retaining the document, derived from the document's centrality. And the retrieval ranking decay function determines it; Huibian ( ) capacity The benefit of filtering this document is determined by the average degree of conflict between this document and other highly central documents; document margins ( The capacity of ) is determined by similarity The decision is used to penalize semantically consistent documents that are assigned to different categories. The goal is to find the global optimal solution using a graph cut algorithm, so that the internal consistency of the retained document set is maximized and the conflicts are minimized.