Large model knowledge representation editing method based on dynamic query routing
By using a dynamic query routing mechanism and a authenticity-hierarchical preference guidance mechanism, attention heads are dynamically selected and query-specific guidance vectors are generated. This solves the problem of frequent hallucinations in large language models, achieves efficient and accurate knowledge representation optimization, and improves the authenticity and consistency of generated content.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-03-13
AI Technical Summary
Existing large-scale language models, in the process of knowledge representation and factual content generation, use fixed head selection and universal guiding vectors, making it difficult to achieve query-specific knowledge calibration. This leads to frequent illusion phenomena and fails to meet the diverse knowledge types and complex contextual needs of commercial systems.
We employ a large model knowledge representation editing method based on dynamic query routing. Through a divergence-supervised dynamic query routing mechanism (DHR) and a truth-hierarchical preference guidance mechanism (TPS), we dynamically select the most sensitive attention head and generate query-specific guidance vectors to optimize the knowledge representation of the large model.
It significantly improves the authenticity, knowledge consistency, and interpretability of model-generated content, reduces the probability of hallucination generation, and enhances the reliability and controllability of commercial scenarios such as intelligent dialogue and question-answering systems.
Smart Images

Figure CN121659903A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of text processing, and in particular relates to a method for editing large model knowledge representations based on dynamic query routing. Background Technology
[0002] Despite significant advancements in commercial applications such as natural language processing, intelligent dialogue, knowledge-based question answering, and content generation, large language models (LLMs) remain susceptible to "illusion" phenomena—generating content that appears plausible but contradicts facts or knowledge. This problem is particularly pronounced in high-knowledge-reliability scenarios like intelligent customer service, financial consulting, medical question answering, legal document drafting assistance, and semantic decision-making for autonomous driving, severely hindering the reliable deployment and oversight of large models in real-world commercial systems. Existing research largely focuses on training-based paradigms, such as instruction tuning and human feedback-based reinforcement learning (RLHF), to mitigate illusions and knowledge errors. However, these methods rely on large amounts of carefully selected data and expensive computing resources, limiting their scalability and real-time adaptability, making it difficult to meet dynamic commercial demands such as real-time knowledge updates and maintaining consistency in contextual reasoning.
[0003] To achieve more efficient knowledge consistency maintenance and representation optimization, inference-time activation editing, a lightweight knowledge correction approach proposed in recent years, has emerged. This method directly intervenes in the model's internal activation state during the inference phase, dynamically guiding representations that deviate from true knowledge to a fact-consistent semantic space, thereby improving the knowledge credibility and semantic stability of the generated content.
[0004] Traditional approaches typically identify a fixed set of "relevance-related" attention heads from the entire corpus or dataset based on the global average score, and then statically modify the activations of these heads using pre-computed general edit vectors. However, such fixed-route editing strategies lack flexibility and cannot adaptively adjust to differences in the knowledge domains or semantic structures involved in different queries. Therefore, they are difficult to apply to diverse knowledge types and complex contextual requirements in commercial dialogue systems.
[0005] To address these limitations, some research has begun exploring more adaptive knowledge representation editing techniques. For example, ACT generates multiple sets of guiding vectors for different hallucination categories and performs adaptive vector aggregation; SADI identifies editing locations through a binary masking mechanism and then achieves semantic adaptation through feature scaling. Although these methods have made initial progress in hallucination mitigation, they generally overlook the fact that the root cause of hallucination lies in the differences in query-specific knowledge reasoning paths. In other words, different input queries activate drastically different knowledge representations and reasoning pathways within a large language model, making it difficult to achieve targeted knowledge representation correction relying solely on global or static editing methods. Figure 1 As shown, existing methods, in the two key stages of "header selection" and "activation editing", are as follows: Figure 1 As shown, existing methods still have significant bottlenecks in the two key stages of "head selection" and "activation editing": (1) Studies have shown that different queries activate different attention paths within the model, resulting in their own unique distribution of non-real knowledge representations. Fixed head selection strategies cannot perceive these query-specific differences, resulting in subsequent editing being unable to effectively act on the key knowledge nodes that produce illusions; (2) In addition, the activation representations of different queries differ in the direction of knowledge authenticity, while the general editing vector lacks targeted calibration, resulting in single editing results and insufficient accuracy.
[0006] The existing technology has the following main drawbacks: 1. While existing technologies have improved the interpretability and effectiveness of activation editing to varying degrees, they generally rely on fixed head selection strategies and globally universal edit vectors. This results in the model's inability to adaptively capture specific inference paths and fact bias directions when faced with different queries. Specifically, existing technologies lack query-specific dynamic calibration mechanisms, making it difficult to handle the diversity of input semantics and contextual changes, thus limiting the robustness and accuracy of illusion suppression effects. 2. While these methods introduce adaptability in editing intensity adjustment and vector generation, they still have structural limitations: On the one hand, they only focus on adjusting local editing parameters (such as intensity or position) and fail to jointly model query-specific inference path differences; on the other hand, they lack a dynamic query routing mechanism oriented towards "key truth headers," and cannot automatically determine the optimal editing target and calibration direction based on input semantics. Furthermore, the guiding vectors in existing technologies are mostly locally or semi-statically adaptively constructed, lacking the ability to customize direction calibration for query characteristics at the global semantic level. Therefore, these methods struggle to simultaneously achieve "dynamic activation path selection" and "semantic adaptation of guiding vectors." Summary of the Invention
[0007] To address the aforementioned shortcomings in existing technologies, this invention provides a large-scale model knowledge representation editing method based on dynamic query routing, which solves problems such as fixed header selection, universal guiding vectors, and difficulty in achieving query-specific knowledge calibration in the knowledge representation and factual content generation processes of existing large-scale language models.
[0008] To achieve the above objectives, the technical solution adopted by this invention is: a method for editing large-scale model knowledge representation based on dynamic query routing, comprising the following steps: S1. Obtain a large-scale knowledge question-answering dataset containing query-answer pairs and label the answers with authenticity information; S2. Input the labeled query-real / non-real answer pairs into the large model, and maximize the authenticity of the generated answers by using a divergence-based dynamic query routing mechanism and a authenticity hierarchy preference guidance mechanism, thereby completing the knowledge representation editing of the large model.
[0009] Further, S2 includes the following steps: S201. Input the labeled query-real / non-real answer pairs into the large model to extract activation values; S202. Based on the semantic and knowledge features of the input query, the activation distribution divergence between real and non-real knowledge clusters in the DRH query, which is based on divergence supervision, is used as a sensitivity metric. The activation distribution divergence is used as a supervision signal for training the head estimator. S203. Based on sensitivity metrics, utilize a query-specific head estimator to quantify the sensitivity scores for different head authenticitys. The head estimator is trained by minimizing the mean squared error between the predicted score and the supervised divergence score. ; S204, Based on Sensitivity Score By adaptively selecting the most sensitive front K Each header is assigned a value, and user queries are adaptively routed to the header most relevant to their authenticity. This yields a set of sensitive headers, enabling dynamic knowledge routing and representation optimization oriented towards query semantic features; S205. Utilize the authenticity-hierarchical preference guidance mechanism to perform representation-level intervention on the sensitive head set, maximize the authenticity of the generated answers, and complete the knowledge representation editing of the large model.
[0010] Furthermore, the training head estimator The expression for the mean square error is as follows:
[0011]
[0012] in, This represents the loss function of the Dynamic Query Routing (DRH) mechanism. This represents the triplet dataset used to activate the edit, containing the query, the true answer, and the false answer. , This represents the set of Cartesian products of all attention heads in a large language model (LLM). This represents the head estimator. Head estimator The parameters, This indicates the input query In the Layer The activation value extracted by the attention head. Indicates supervised divergence, Indicates for query In the head Extracted real activation clusters The average vector, Indicates for query In the head Extracted non-real activation clusters The average vector, Indicates the real active cluster variance Indicates non-real activation clusters variance Represents positive numbers. This represents the true answer. This indicates a non-true answer.
[0013] Furthermore, the head The expression is as follows: ; ; Among them, among them, This represents the head estimator. Head estimator The parameters, This indicates the input query In the Layer The activation value extracted by the attention head. Indicates query The corresponding number j The most sensitive point of attention, i Indicates the index of the input query. Represents the Cartesian product of the LLM attention head. Indicates query The first in all heads High sensitivity score.
[0014] Furthermore, step S205 includes the following steps: Define the orientation calibration strategy between the global edit vector and the query-specific guide vector. The orientation calibration strategy Used to perceive the semantics of environmental queries and for the global vector Perform the optimal orientation calibration action; Optimize orientation calibration strategy using realism hierarchy preference loss ; Using the optimized orientation calibration strategy By generating the corresponding optimal guiding vector for the input query, the authenticity of the generated answer is maximized, thus completing the knowledge representation editing of the large model.
[0015] Furthermore, the aforementioned authenticity hierarchy preference loss The expression is as follows: ; ; ; in, Expressing expectations, Indicates the dataset Triples sampled in the middle Seeking expectations, Indicates a query. Indicates query A collection of real answers Indicates query A collection of unreal answers Represents the logical stith function, Indicates the set of true answers All real answers sampled from the middle Seeking expectations, Indicate the best answer For query After orientation calibration strategy The calibrated reward Indicates the true answer For query After orientation calibration strategy The calibrated reward This indicates a set of non-true answers. All real answers sampled from the middle Seeking expectations, Indicates a non-true answer For query After orientation calibration strategy The calibrated reward This represents the loss from unreal to real preference. This represents the loss from the true to the optimal preference.
[0016] The beneficial effects of this invention are: The core innovation of this invention lies in proposing a large-model knowledge representation editing method based on dynamic query routing. This invention can adaptively optimize the internal knowledge representation of the model during the inference stage, thereby accurately alleviating the "illusion" problem of large language models (LLMs) and enhancing the factuality and consistency of text output. This technology overcomes the limitations of existing activation editing methods, which are characterized by "query irrelevance and rigid editing," achieving dynamic representation optimization at the knowledge level and directly improving the output quality of intelligent dialogue, question-answering systems, and text generation tasks. It has at least the following effects: This invention proposes a divergence-supervised dynamic query routing method (Divergence-sensitive Head Routing (DHR)) to establish a query-aware attention head selection criterion. In text generation or intelligent question-answering scenarios, DHR dynamically identifies the attention heads most sensitive to knowledge facts based on the input query and routes the query to these key positions. By capturing non-real knowledge paths activated by different queries, DHR ensures that the model prioritizes credible knowledge representations when generating text, reducing illusory content from the source. For example, in question-answering systems, DHR can guide the model to select the knowledge fragment most relevant to the current question, thereby generating a more accurate answer. Truth-hierarchical Preference Steering (TPS) is a knowledge representation guidance mechanism that constructs a hierarchical preference structure of "non-truth—truth—optimal factual knowledge" to achieve query-specific calibration of the global guidance vector. In text generation, TPS fine-tunes the model activation, gradually transitioning the output content from potentially biased text to a factually consistent and knowledge-complete expression. For example, when an intelligent dialogue system answers complex questions, TPS can dynamically adjust the expression of key knowledge points in the generated text, ensuring the answer is both factually accurate and fluently natural, thereby improving user experience and text credibility. This invention employs a collaborative optimization mechanism for specific knowledge representations: It organically integrates the Dynamic Query Routing (DHR) mechanism with the Truth-Based Hierarchical Preference Guidance (TPS) mechanism, forming a collaborative structure of "Dynamic Query Routing + Hierarchical Knowledge-Guided Optimization." During text generation, the DHR mechanism locates and activates key knowledge, while the TPS mechanism performs fine-tuning. Together, they optimize the consistency of knowledge across words and sentences within the text content. Through this collaborative mechanism, the model can generate highly factual, semantically coherent, and interpretable text outputs for different queries, effectively reducing the probability of illusion generation and improving the overall text quality in scenarios such as intelligent dialogue and text question answering. Attached Figure Description
[0017] Figure 1 This is a comparison chart of previous methods and the proposed QRAE in terms of head selection and activation editing.
[0018] Figure 2 This is a framework diagram of the Dynamic Query Routing (DHR) mechanism and the Authenticity Hierarchy Preference Guidance (TPS) mechanism.
[0019] Figure 3 This is a flowchart of the method of the present invention. Detailed Implementation
[0020] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0021] Example This invention addresses the problems of fixed head selection, generic guiding vectors, and difficulty in achieving query-specific knowledge calibration in existing large-scale language models during knowledge representation and factual content generation. It proposes a large-scale model knowledge representation editing method based on dynamic query routing (QRAE). The core idea of this invention is to introduce a divergence-sensitive head routing (DHR) mechanism to construct a query-aware attention head selection standard. This allows different input queries to be dynamically routed to their specific inference paths that contribute most to factuality and knowledge consistency, fundamentally overcoming the shortcomings of fixed head selection and inability to capture query-specific knowledge activation differences in existing technologies. Building on this, this invention further proposes a truth-hierarchical preference steering (TPS) mechanism. Through a hierarchical preference optimization strategy, it adaptively calibrates and generates specific guiding vectors for different query semantics, achieving layer-by-layer, progressive optimization of the model's internal knowledge representation. This mechanism dynamically adjusts the knowledge direction and factual hierarchy, ensuring semantic consistency and enhancing factual accuracy during the editing process. This effectively addresses the lack of semantic and knowledge customization capabilities in existing general editing vectors. Through the synergistic effect of the Dynamic Query Routing (DHR) mechanism and the Truth Hierarchy Preference Guidance (TPS) mechanism, this invention achieves dynamic routing and refined editing optimization of knowledge representations within large models. Without significantly increasing computational costs, it adaptively guides activation states deviating from factual or knowledge truth caused by specific query reasoning paths back to a consistent knowledge space and factual semantic direction. This invention is applicable to commercial large-scale model applications such as intelligent dialogue systems and knowledge question-answering platforms. It significantly improves the authenticity, knowledge consistency, and interpretability of model-generated content, achieving efficient and accurate knowledge representation optimization and illusion suppression for complex semantic queries, thereby enhancing the reliability and controllability of the system in real-world business scenarios.
[0022] like Figure 3 As shown, this invention provides a method for editing the knowledge representation of a large model based on dynamic query routing, and its implementation method is as follows: S1. Obtain a large-scale knowledge question-answering dataset containing query-answer pairs and label the answers with authenticity information.
[0023] In this embodiment, a large-scale knowledge-based question-answering dataset is collected, containing query-answer pairs, and the answers are labeled with veracity (best / true / not true) to construct a training set. The labeled query-answer pairs are then input into a large model. In a production environment, users input text queries into an intelligent dialogue system or question-answering system, which are then delivered to a large model for further processing.
[0024] S2. Input the labeled query-real / non-real answer pairs into the large model, and maximize the realism of the generated answers using a divergence-supervised dynamic query routing mechanism and a realism hierarchy preference guidance mechanism, thereby completing the knowledge representation editing of the large model. The implementation method is as follows: S201. Input the labeled query-real / non-real answer pairs into the large model to extract activation values; S202. Based on the semantic and knowledge features of the input query, the activation distribution divergence between real and non-real knowledge clusters in the DRH query, which is based on divergence supervision, is used as a sensitivity metric. The activation distribution divergence is used as a supervision signal for training the head estimator. S203. Based on sensitivity metrics, utilize a query-specific head estimator to quantify the sensitivity scores for different head authenticitys. The head estimator is trained by minimizing the mean squared error between the predicted score and the supervised divergence score. ; S204, Based on Sensitivity Score By adaptively selecting the most sensitive front K Each header is assigned a value, and user queries are adaptively routed to the header most relevant to their authenticity. This yields a set of sensitive headers, enabling dynamic knowledge routing and representation optimization oriented towards query semantic features; S205. Utilizing the Authenticity Hierarchical Preference Guidance Mechanism (TPS), representation-level intervention is performed on the sensitive head set to maximize the authenticity of the generated answers, thereby completing the knowledge representation editing of the large model. Specifically: Define the orientation calibration strategy between the global edit vector and the query-specific guide vector. The orientation calibration strategy Used to perceive the semantics of environmental queries and for the global vector Perform the optimal orientation calibration action; Optimize orientation calibration strategy using realism hierarchy preference loss ; Using the optimized orientation calibration strategy By generating the corresponding optimal guiding vector for the input query, the authenticity of the generated answer is maximized, thus completing the knowledge representation editing of the large model.
[0025] In this embodiment, the prediction score is the prediction value of the Dynamic Query Routing (DRH) mechanism for the current problem during the training and inference phases; the supervision divergence score is a value calculated based on the activation distribution divergence between real and non-real knowledge clusters and is used to train the head estimator during the training phase. Indicate the best answer For query After orientation calibration strategy The calibrated reward Indicates the true answer For query After orientation calibration strategy The calibrated reward This indicates a set of non-true answers. All real answers sampled from the middle Seeking expectations, Indicates a non-true answer For query After orientation calibration strategy The calibrated reward This represents the loss from unreal to real preference. This represents the loss from the true to the optimal preference.
[0026] Given a by Layers and Large Language Model (LLM) composed of attention heads The model is the input query Generate an answer However, when the knowledge relevant to the query is not properly activated, internal activation tends to be untrue, leading to an incorrect answer. This can induce hallucinations. Therefore, inference-time activation editing techniques are designed to directly guide non-realistic activations, thereby promoting realistic responses.
[0027] Typically, given a query The real answer Inauthentic answers ,from and Sample a triplet dataset Used to activate editing. Then, and With query splicing to extract each Corresponding activation and ,in This represents the Cartesian product of the LLM attention head.
[0028] For each head The activation of the edit method first calculates a fixed score. (For example, head-to-head binary classifiers on the validation set) The validation accuracy (on the metric) is used to represent the average importance of all queries.
[0029] in, Represents a binary classifier. This represents the classification threshold (default is 0.5). Indicates a binary authenticity label, Indicates the indicator function. Based on the fraction... ,from Select before The sizes form a fixed set. This set is considered to contain heads that have an equal potential to generate non-real activations for all queries. Therefore, for each selected head... Construct a global edit vector (For example, by means of) The average activation difference between real and unreal samples is as follows: ; Then, the global vector With fixed strength Acts on each head The activation value, where : ; However, the previously fixed set of selected heads For a given query, the most informative headers may not be included. In contrast, the Dynamic Query Routing (DHR) mechanism proposed in this invention can dynamically route each inferred query to its most sensitive headers. Furthermore, previous editing strategies ignored query-specific guidance directions and applied a globally averaged edit vector. The Authenticity Hierarchy Preference Guidance Mechanism (TPS) provided by this invention learns to... Optimize into an optimal, query-aware vector. This maximizes the authenticity of the generated answers. For example... Figure 2As shown, the Dynamic Query Routing (DHR) mechanism dynamically selects attention heads relevant to the query by estimating the sensitivity of each attention head in the activation cluster to truth or falsehood information. The Truth-Level Preference Guidance (TPS) mechanism then optimizes the query-specific guidance vector through coarse-to-fine preference calibration based on a truth-and-false hierarchical answer set, thereby achieving precise and adaptive activation editing. Specifically, the Dynamic Head Selection (DHR) mechanism predicts the truth sensitivity of attention heads based on the input query and selects the attention head most relevant to the current query; the Query-Specific Representation Calibration (TPS) mechanism adaptively generates query-specific guidance vectors for the selected attention heads, optimizing the model's internal knowledge representation. This effectively mitigates the generation of illusory content and improves the factual consistency, knowledge accuracy, and semantic reliability of the output text in intelligent dialogue, question answering, and other commercial text generation scenarios.
[0030] In this embodiment, to overcome the technical limitations of traditional activation editing methods that rely on fixed head sensitivity standards and struggle to capture specific knowledge activation differences, this invention proposes a Divergence-sensitive Head Routing (DRH) mechanism (i.e., a dynamic query routing mechanism). The DRH mechanism aims to adaptively route queries to the set of attention heads most semantically relevant to the input query based on its semantic and knowledge features, thereby achieving targeted knowledge representation optimization. The DRH mechanism uses the activation distribution divergence between query-related real and non-real knowledge clusters as a sensitivity metric, characterizing the responsiveness of each attention head to factuality and knowledge consistency at the knowledge representation level. Based on this sensitivity metric, this invention constructs a query-specific head estimator that can accurately quantify the realism sensitivity scores of different heads and adaptively select the attention path with the greatest correction potential, achieving dynamic knowledge routing and representation optimization oriented towards query semantic features. Through this DRH mechanism, the model can automatically determine the optimal information flow path during the inference stage based on the knowledge type and contextual features of the input query, significantly improving the targeting and accuracy of knowledge editing. The Dynamic Query Routing (DRH) mechanism effectively breaks the limitations of traditional fixed head selection strategies, providing a high-value knowledge entry point for subsequent Truth Hierarchy Preference Guidance (TPS) mechanisms. This provides more reliable knowledge representation correction capabilities for large models in commercial scenarios such as intelligent dialogue, knowledge question answering, and text generation.
[0031] Specifically, the first step is to design a query-specific head estimator. ,in, express The parameters are used to dynamically quantify which attention heads are most likely involved in the inference path for a given user query. This differs from traditional fixed-score methods. In contrast, the head estimator activates... Effectively captures individual user queries The internal hallucination patterns and predictions of the head Adaptive sensitivity score : ; This score reflects the potential of the head (or similar indicator) to enhance factual accuracy within a specific reasoning path of a user query. Therefore, by selecting the head with the highest sensitivity... The former Each header adaptively routes user queries to the header most relevant to their authenticity. : ; in, This represents the head estimator. Head estimator The parameters, This indicates the input query In the Layer The activation value extracted by the attention head. Indicates query The corresponding number j The most sensitive point of attention, i Indicates the index of the input query. Represents the Cartesian product of the LLM attention head. Indicates query The first in all heads High sensitivity score.
[0032] In summary, query the header of the route The differences between different queries reveal the query-specific nature of fact-sensitive reasoning paths.
[0033] Inspired by the finding that "information-rich attention head activations tend to cluster into functional clusters in the latent space," this invention proposes using activation distribution divergence as a training estimator. The supervisory signal indicates the header's sensitivity to query-centric truthfulness. Specifically, for each query... Using real answers Inauthentic answers Extract from the head respectively The real activation cluster at the location Non-real activation clusters Supervised divergence The calculation is as follows: ; in, Indicates supervised divergence, Indicates for query In the head Extracted real activation clusters, Indicates for query In the head Extracted non-real activation clusters variance Represents positive numbers. This represents the mean vector of the activated cluster. Indicate its variance. It is a tiny positive constant used to maintain numerical stability. This indicates the activation of a cluster.
[0034] Guided by divergence, we train the estimator by minimizing the mean squared error between the predicted score and the supervised divergence score. :
[0035] in, This represents the loss function of the Dynamic Query Routing (DRH) mechanism. This represents the triplet dataset used to activate the edit, containing the query, the true answer, and the false answer. , This represents the set of Cartesian products of all attention heads in a large language model (LLM). This represents the head estimator. Head estimator The parameters.
[0036] Specifically, this invention provides a dynamic head selection method based on divergence supervision, comprising: training a head estimator using the activation distribution divergence between real and non-real activation clusters as a supervision signal; during the inference phase, using the trained estimator to predict sensitivity scores for the input query, and dynamically selecting an attention head set for knowledge representation optimization accordingly. Thus, during text generation, key knowledge paths can be automatically located for different queries, ensuring the accuracy and consistency of knowledge content in the generated text.
[0037] Therefore, the Dynamic Query Routing (DHR) mechanism can route diverse user queries to promising, query-specific headers. For subsequent editing.
[0038] In this embodiment, to further adapt to the dynamic differences in knowledge representation and factual orientation of different user queries, this invention proposes a Truth-hierarchical Preference Steering (TPS) mechanism. This mechanism generates an optimal activation guidance strategy for each query, achieving precise optimization of the model's internal knowledge representation. The TPS mechanism introduces a query guidance direction calibration strategy, which adaptively optimizes the direction based on the global knowledge guidance vector, thereby achieving personalized knowledge correction oriented towards query semantics and factual needs. The TPS mechanism constructs a truth-hierarchical answer system, including a three-level hierarchy of "non-truthful—truthful—optimal factual knowledge," and performs progressive preference optimization guided by this hierarchy. Through this hierarchical structure, the TPS mechanism enables the model to gradually learn the path of migration from low factual representation to high-consistency knowledge representation during the training or inference phase, achieving coarse-to-fine knowledge correction and semantic refinement. At the application level, the Truthfulness Hierarchy Preference Guidance Mechanism (TPS) intervenes at the representational level on the sensitive head set obtained by the Dynamic Query Routing Mechanism (DHR). This guides the continuous adjustment of the model's internal activation states along the direction of factual consistency, effectively correcting knowledge representations that deviate from true semantics. Through the synergistic effect of DHR and TPS, the model can significantly improve factual expression and knowledge consistency in commercial language processing scenarios such as intelligent question answering and text generation, providing technical support for highly reliable semantic generation.
[0039] First, this invention designs a direction calibration strategy for querying specific guidance. It perceives the semantics of the environment query. And for the global vector Perform optimal orientation calibration actions. This is to effectively guide the orientation calibration strategy. This invention generates the optimal guidance vector that maximizes the responsiveness to factuality by using a truth-level preference to optimize the orientation calibration strategy. This preference transitions from unrealistic to realistic, and ultimately to the optimal answer. Specifically: (1) Basic non-real to real preference: First, the loss of non-real to real preference. Ensures optimized query-specific calibration strategy It demonstrates a fundamental advantage in distinguishing between 'real' and 'unreal' states. Specifically, the orientation calibration strategy... In real activation Calibration under the guidance of Generate real vectors ,in:
[0040] These vectors are expected to guide the LLM to make a realistic response. Similarly, the orientation calibration strategy... Using non-real activation To optimize global edit vectors Generate non-real vectors These vectors maximize the probability of the hallucination response, where:
[0041] Therefore, preference loss Rewards that constrain all true answers Higher reward than all non-true answers .award The formula is as follows:
[0042] in, Indicates reward One of the proportionality constants in the formula, Indicates the direction calibration strategy for query guidance The parameters, This indicates that the Large Language Model (LLM) applies global edit vectors. The distribution of the answers afterward The answer generated by the Large Language Model (LLM) Indicates will The calibrated guide vector is applied to the head of the DHR selection. Afterwards, the distribution of LLM answers :
[0043] in, This indicates the header applied to the selection of the Dynamic Query Router (DHR). The head activation value.
[0044] and Indicates based on sensitivity score The query specifies the intensity of the edit. Accordingly, Indicates the use of global edit vectors The distribution of LLM over time. The entire... Preferences can be formulated as follows: ; (2) Progressive preference from real to optimal: Furthermore, this invention constructs a more advanced preference from real to optimal. To implement a query-aware calibration strategy From merely correct to progressively optimizing to optimal. To this end, this invention performs finer-grained stratification of the actual answers and... Choose the best answer At the answer level middle, As the most truthful and comprehensive answer, thus providing Derivation of the optimal vector Provides optimal calibration assistance:
[0045] This optimal vector should be smaller than the true vector. All true vectors produce higher rewards Thus establishing preferences : ; That is, the present invention provides a guided vector calibration method based on authenticity-level preference optimization, comprising: Define the calibration strategy between the global edit vector and the query-specific guide vector; Optimization is achieved through a truth-level preference loss, which includes at least: a "non-truth-truth" preference loss to establish basic fact distinctions; and a "truth-optimal" preference loss to achieve asymptotic optimization in the factual direction. Based on the above optimization results, an optimal guiding vector is generated for the input query to improve the model's knowledge authenticity and representation stability, and reduce the probability of illusion generation. This improves the model's knowledge authenticity and representation stability in commercial text scenarios (such as intelligent dialogue and text question answering systems), reduces illusion generation, and enhances the credibility of text output and user experience.
[0046] Finally, by combining Incremental optimization and orientation calibration strategy It can effectively convert global vectors Adjust to query the optimal guiding vector This maximizes the authenticity of the response.
[0047] in, Expressing expectations, Indicates the dataset Triples sampled in the middle Seeking expectations, Indicates a query. Indicates query A collection of real answers Indicates query A collection of unreal answers Represents the logical stith function, Indicates the set of true answers All real answers sampled from the middle Seeking expectations, Indicate the best answer For query After orientation calibration strategy The calibrated reward Indicates the true answer For query After orientation calibration strategy The calibrated reward This indicates a set of non-true answers. All real answers sampled from the middle Seeking expectations, Indicates a non-true answer For query After orientation calibration strategy The calibrated reward This represents the loss from unreal to real preference. This represents the loss from the true to the optimal preference.
[0048] In this embodiment, by progressively editing the activation states within the model, representations that deviate from facts or are inconsistent with knowledge are guided back to a consistent knowledge space. Through this dynamic representation optimization, the model can accurately reflect knowledge points when generating text and reduce the probability of illusions or false facts. The model generates the final text response based on the optimized activation states, ensuring that the output content is: highly factual; closely corresponds to the query semantics; and is fluent, understandable, and suitable for intelligent dialogue or question-answering scenarios.
[0049] The proposed large model knowledge representation editing technique (QRAE) based on dynamic query routing significantly alleviates the "illusion" phenomenon generated by large language models (LLMs) during reasoning and text generation, and demonstrates superior factual enhancement capabilities in multiple public benchmark tests. In terms of illusion suppression and factual enhancement, this invention achieves significant performance improvements compared to existing techniques. On the widely adopted TruthfulQA illusion evaluation benchmark, this invention performs excellently across all key metrics: in the open generation task, the True*Info score reaches 85.1%, an improvement of 23.1 percentage points compared to the baseline model (62.0%); in the multiple choice task (MC1), the accuracy reaches 63.3%, an improvement of 13.2% compared to the suboptimal method. These results fully demonstrate that the divergence-sensitive head routing (DHR) and truth-hierarchical preference guidance (TPS) mechanism of this invention can synergistically achieve query-specific knowledge representation optimization, significantly enhancing the factual consistency of the model in different semantic and knowledge contexts, fundamentally reducing the probability of generating illusory content. Furthermore, this invention also demonstrates superior performance in terms of model generalization and knowledge robustness. This technique not only significantly improves factual metrics on the LLaMA-3 model, but also achieves an average 24.4% improvement in knowledge factuality across various mainstream large-scale language models. Furthermore, it maintains stable transfer performance on out-of-distribution benchmark sets (such as TriviaQA and Natural Questions). This demonstrates that the dynamic query routing mechanism proposed in this invention can effectively capture the true reasoning paths under different input semantics, achieving cross-contextual adaptive correction of knowledge representation biases, and possesses excellent versatility and stability.
[0050] This invention introduces a dual mechanism of "dynamic query routing and hierarchical knowledge representation optimization" to achieve refined guidance and adaptive calibration of the activation state within a large model. This scheme reduces the risk of illusion in complex semantic and knowledge-intensive scenarios at the mechanism level, significantly improving the factual accuracy, knowledge reliability, and semantic consistency of the model-generated content. Furthermore, this invention can be widely applied in commercial natural language processing fields such as intelligent dialogue systems, knowledge question answering, and text generation, providing crucial technical support for achieving highly reliable language intelligence.
Claims
1. A method for editing large-scale model knowledge representation based on dynamic query routing, characterized in that, Includes the following steps: S1. Obtain a large-scale knowledge question-answering dataset containing query-answer pairs and label the answers with authenticity information; S2. Input the labeled query-real / non-real answer pairs into the large model, and maximize the authenticity of the generated answers by using a divergence-based dynamic query routing mechanism and a authenticity hierarchy preference guidance mechanism, thereby completing the knowledge representation editing of the large model.
2. The method for editing large model knowledge representations based on dynamic query routing according to claim 1, characterized in that, S2 includes the following steps: S201. Input the labeled query-real / non-real answer pairs into the large model to extract activation values; S202. Based on the semantic and knowledge features of the input query, the activation distribution divergence between real and non-real knowledge clusters in the DRH query, which is based on divergence supervision, is used as a sensitivity metric. The activation distribution divergence is used as a supervision signal for training the head estimator. S203. Based on sensitivity metrics, utilize a query-specific head estimator to quantify the sensitivity scores for different head authenticitys. The head estimator is trained by minimizing the mean squared error between the predicted score and the supervised divergence score. ; S204, Based on Sensitivity Score By adaptively selecting the most sensitive front K Each header is assigned a value, and user queries are adaptively routed to the header most relevant to their authenticity. This yields a set of sensitive headers, enabling dynamic knowledge routing and representation optimization oriented towards query semantic features; S205. Utilize the Authenticity Hierarchical Preference Guidance Mechanism (TPS) to perform representational-level intervention on the sensitive head set, maximizing the authenticity of the generated answers and completing the knowledge representation editing of the large model.
3. The method for editing large model knowledge representations based on dynamic query routing according to claim 2, characterized in that, The training head estimator The expression for the mean square error is as follows: in, This represents the loss function of the Dynamic Query Routing (DRH) mechanism. This represents the triplet dataset used to activate the edit, containing the query, the true answer, and the false answer. , This represents the set of Cartesian products of all attention heads in a large language model (LLM). This represents the head estimator. Head estimator The parameters, This indicates the input query In the Layer The activation value extracted by the attention head. Indicates supervised divergence, Indicates for query In the head Extracted real activation clusters The average vector, Indicates for query In the head Extracted non-real activation clusters The average vector, Indicates the real active cluster variance Indicates non-real activation clusters variance Represents positive numbers. This represents the true answer. This indicates a non-true answer.
4. The method for editing large model knowledge representations based on dynamic query routing according to claim 2, characterized in that, The head The expression is as follows: ; ; in, This represents the head estimator. Head estimator The parameters, This indicates the input query In the Layer The activation value extracted by the attention head. Indicates query The corresponding number j The most sensitive point of attention, i Indicates the index of the input query. Represents the Cartesian product of the LLM attention head. Indicates query The first in all heads High sensitivity score.
5. The method for editing large model knowledge representations based on dynamic query routing according to claim 2, characterized in that, S205 includes the following steps: Define the orientation calibration strategy between the global edit vector and the query-specific guide vector. The orientation calibration strategy Used to perceive the semantics of environmental queries and for the global vector Perform the optimal orientation calibration action; Using authenticity level preference loss Optimized direction calibration strategy ; Using the optimized orientation calibration strategy By generating the corresponding optimal guiding vector for the input query, the authenticity of the generated answer is maximized, thus completing the knowledge representation editing of the large model.
6. The method for editing large model knowledge representations based on dynamic query routing according to claim 5, characterized in that, The authenticity hierarchy preference loss The expression is as follows: ; ; ; in, Expressing expectations, Indicates the dataset Triples sampled in the middle Seeking expectations, Indicates a query. Indicates query A collection of real answers Indicates query A collection of unreal answers Represents the logical stith function, Indicates the set of true answers All real answers sampled from the middle Seeking expectations, Indicate the best answer For query After orientation calibration strategy The calibrated reward Indicates the true answer For query After orientation calibration strategy The calibrated reward This indicates a set of non-true answers. All real answers sampled from the middle Seeking expectations, Indicates a non-true answer For query After orientation calibration strategy The calibrated reward This represents the loss from unreal to real preference. This represents the loss from the true to the optimal preference.