Method and device for resolving context conflicts of large model based on dynamic coordination decoding
By dynamically coordinating the decoding method and using the Transformer model's attention map to predict conflicts and adjust decoding weights, it solves the context and memory conflict problems of large-scale language models in long text and multi-round dialogue tasks, improves the accuracy and consistency of generation, and is applicable to a variety of large open source models.
Patent Information
- Application Number
- CN202510938697.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-07-08
AI Technical Summary
Existing large-scale language models face problems with generation accuracy and consistency caused by context and memory conflicts when processing long texts and multi-round dialogue tasks. Existing methods such as prompt design and fine-tuning are cumbersome and have poor generalization, and contrastive learning methods interfere with the generation process in the absence of conflicts.
Through a method based on dynamic coordinated decoding, the attention map of the Transformer model is used to predict conflicts, dynamically adjust the decoding balance weight, introduce a conflict perception mechanism and dynamic decoding path routing, and optimize the generation process.
Without modifying the model structure, it improves the accuracy and consistency of generation, adapts to complex scenarios, reduces the intervention of non-conflicting inputs, is applicable to a variety of open source large models, and has good cross-model compatibility.
Smart Images

Figure CN120449863B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a large model context conflict resolution method and device based on dynamic coordinated decoding. Background Art
[0002] With the widespread application of large-scale language models (LLMs) in natural language processing tasks, their ability to understand and utilize context has become a key factor in model performance. To enhance the model's ability to access external knowledge, Retrieval-Augmented Generation (RAG) has become a research hotspot in recent years. By incorporating information from external knowledge bases, RAG improves the model's reasoning accuracy and generalization capabilities in tasks such as open-domain question answering and dialogue systems.
[0003] In practical applications, especially in long text processing, multi-turn conversations, and knowledge-intensive tasks, models often encounter "knowledge conflict" issues. This refers to the situation where the generated results are influenced by both the current context and the model's internal parameterized knowledge. These two factors can be inconsistent, impacting the correctness and consistency of the output. Existing research generally categorizes knowledge conflict into three categories: memory-memory conflict, context-memory conflict, and context-context conflict. Context-memory conflict is particularly common, referring to situations where the knowledge a model should generate based on the current context conflicts with outdated or erroneous information stored in its inherent parameters.
[0004] To address this conflict, existing approaches primarily include prompt design and fine-tuning. The former relies on manually constructed prompts to guide the model to ignore prior knowledge and prioritize contextual information. However, prompt design is cumbersome, task-dependent, and difficult to generalize. The latter, on the other hand, adapts the model to the target knowledge through task-specific fine-tuning. However, this approach consumes significant computational resources and suffers from poor generalization, making it difficult to adapt to dynamically changing knowledge environments.
[0005] In recent years, some research has also adopted contrastive learning to design decoding strategies, guiding the model to generate answers based on contextual preferences. For example, the context-aware decoding method strengthens the model's reliance on contextual information by comparing the output distribution differences between models with and without context; the COIECD method identifies knowledge conflicts by analyzing changes in output entropy at the token level and dynamically adjusts the generation process; and the ADACAD method uses the Jensen-Shannon divergence (JSD) to quantify the degree of knowledge conflict and adjust hyperparameters accordingly during the generation process. However, these methods often interfere with the generation process of all tokens even in the absence of conflict. Furthermore, their conflict modeling is coarse-grained, with only simple judgments at the token level, making them difficult to adapt to more complex real-world scenarios and affecting the fluency and accuracy of answer generation. Summary of the Invention
[0006] In order to solve the technical problem of low accuracy of answering questions due to context and memory conflicts in the existing technology, the embodiment of the present invention provides a large model context conflict resolution method and device based on dynamic coordinated decoding. The technical solution is as follows:
[0007] In one aspect, a large model context conflict resolution method based on dynamic coordinated decoding is provided. The method is implemented by a large model context conflict resolution device based on dynamic coordinated decoding. The method includes:
[0008] S1, Transformer model that obtains question text, target context, and answers the question;
[0009] S2, based on the question text token, target context token, generated token and multiple parallel attention heads of the Transformer model, determines the context fidelity and determines the conflict prediction result according to the context fidelity;
[0010] S3. When the conflict prediction result is true, based on the dynamic adjustment mechanism, the balance weight in decoding is adjusted, and according to the adjusted balance weight, the dynamic comparative decoding distribution is determined. According to the dynamic comparative decoding distribution, the answer text corresponding to the question text is output.
[0011] On the other hand, a large model context conflict resolution device based on dynamic coordinated decoding is provided, which is applied to the large model context conflict resolution method based on dynamic coordinated decoding, and the device includes:
[0012] The acquisition unit is used to obtain the question text, target context, and the Transformer model for answering the question;
[0013] The determining unit is configured to determine the context fidelity based on the question text token, the target context token, the generated token, and a plurality of parallel attention heads of the Transformer model, and determine the conflict prediction result according to the context fidelity.
[0014] The adjusting unit is configured to, when the conflict prediction result is true, adjust the balance weight in the decoding based on a dynamic adjustment mechanism, determine a dynamic contrast decoding distribution according to the adjusted balance weight, and output the answer text corresponding to the question text according to the dynamic contrast decoding distribution.
[0015] In another aspect, a large model context conflict resolution device based on dynamic coordinated decoding is provided, which comprises a processor and a memory having computer readable instructions stored thereon, wherein the computer readable instructions are executed by the processor to implement any one of the above-mentioned large model context conflict resolution methods based on dynamic coordinated decoding.
[0016] In another aspect, a computer readable storage medium is provided, wherein the storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement any one of the above-mentioned large model context conflict resolution methods based on dynamic coordinated decoding.
[0017] The technical scheme provided by the embodiments of the present application has at least the following beneficial effects:
[0018] In the embodiments of the present application, for conflict-free input, the intervention of contrast decoding is minimized to maintain natural and smooth generation; for input with conflicts, the output influence between context information and model memory is dynamically balanced to improve the correctness and robustness of generation. Moreover, without additional fine-tuning of the language model, the decoding strategy can be directly integrated into existing multiple open source large models (such as Llama2, Llama3, Mistral, etc.), which has good cross-model compatibility and engineering deployment convenience. By introducing a conflict perception mechanism and a dynamic decoding path routing in the inference process of a large language model, the generation accuracy and context consistency of the model in a knowledge conflict scenario are significantly improved. In summary, without modifying the model structure, the present application introduces a lightweight inference control strategy to realize efficient coordination among conflict perception, dynamic adjustment, and context enhancement, providing a general and effective technical path for reliable inference and stable generation of large language models, which has significant practical application value and promotion prospects. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0020] Figure 1 is a flow chart of a large model context conflict resolution method based on dynamic coordination decoding provided by an embodiment of the present application.
[0021] Figure 2 is a block diagram of a large model context conflict resolution device based on dynamic coordination decoding provided by an embodiment of the present application.
[0022] Figure 3 is a structural schematic diagram of a large model context conflict resolution device based on dynamic coordination decoding provided by an embodiment of the present application. DETAILED DESCRIPTION
[0023] The technical solutions in the present application will be described below with reference to the drawings.
[0024] In the embodiments of the present application, the words such as "example", "for example" and the like are used to represent as an example, illustration or description. Any embodiment or design scheme described as "example" in the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the word "example" is intended to present the concept in a specific manner. In addition, in the embodiments of the present application, the meaning expressed by "and / or" can be both, or can be one of the two.
[0025] In the embodiments of the present application, "image" and "picture" can be used interchangeably at times. It should be pointed out that when the distinction is not emphasized, the meanings expressed are consistent. "Of", "corresponding" and "corresponding" can be used interchangeably at times. It should be pointed out that when the distinction is not emphasized, the meanings expressed are consistent.
[0026] In the embodiments of the present application, sometimes the subscript such as W1 can be written in the form of non-subscript such as W1. When the distinction is not emphasized, the meanings expressed are consistent.
[0027] In order to make the technical problems, technical solutions and advantages to be solved by the present application more clear, the following will be described in detail with reference to the drawings and specific embodiments.
[0028] An embodiment of the present invention provides a large-model context conflict resolution method based on dynamic coordinated decoding, which can be implemented by a large-model context conflict resolution device based on dynamic coordinated decoding, and the large-model context conflict resolution device based on dynamic coordinated decoding can be a terminal or a server. This method can solve the generation error problem caused by the conflict between context information and model memory during the reasoning process of a large-scale language model (LLM). The design inspiration of this method comes from the theory of cognitive dissonance: when the model faces non-conflicting information, if an additional correction process is forcibly added, it may lead to erroneous or inconsistent generation results. Therefore, from the perspective of cognitive coordination, the present invention achieves a balance between context consistency and generation stability through a strategy that combines conflict prediction with dynamic decoding. The technical solution of the present invention consists of two main modules, namely a conflict prediction module based on attention graph and a cognitive coordination decoding module. As Figure 1 The flow chart of the large-model context conflict resolution method based on dynamic coordination decoding is shown. The operation of the attention map-based conflict prediction module is as follows S2, and the operation of the cognitive coordination decoding module is as follows S3. The processing flow of the method may include the following steps:
[0029] S1, Transformer model that obtains question text, target context, and answers the question.
[0030] In one possible implementation, the question text and the target context are used to input a Transformer model for answering the question, and the Transformer model is used to find the answer to the question text in the target context.
[0031] S2, based on the question text token, target context token, generated token and multiple parallel attention heads of the Transformer model, determines the context fidelity and determines the conflict prediction result according to the context fidelity.
[0032] In one feasible implementation, the design of the attention-graph-based conflict prediction module in this step is based on a core assumption: the more a language model relies on the input context during generation, the less likely its output will conflict with the model's parameter memory. Conversely, if the model deviates from the context, it is more likely to produce incorrect generation. Therefore, this module models the context-memory conflict as a binary classification problem and introduces "context fidelity" as a key discriminant feature.
[0033] Context-fidelity features are obtained by extracting attention maps from the model's multi-layer Transformer structure. For example, a GPT-style language model consists of several Transformer layers, each with multiple parallel attention heads. As the model processes the input context and the generated sequence, the attention map reflects the degree to which each generated token depends on the input content. This module aggregates the attention weights from each head across each layer as feature input representing contextual dependencies. This input is fed into a single-layer Multi-Layer Perceptron (MLP) classifier, which outputs a prediction of whether a conflict exists.
[0034] Optionally, the specific operation steps of S2 may include the following S21-S25:
[0035] S21. Based on the question text token and the context token, determine the average attention weight of the h-th attention head on the context part.
[0036] In a feasible implementation, during the generation process, the attention weight reflects the degree of dependence of the current generated token on the context. Attention weight relative to query Q It is defined as follows (1):
[0037] (1)
[0038] in, represents the dimensions of vectors Q and K, and T represents matrix transpose.
[0039] Based on (1) above, given the context input , for each attention head, the average attention weight of its context can be expressed as follows (2):
[0040] (2)
[0041] in, represents the average attention weight of the hth attention head on the context. When calculating this formula, Q in formula (1) is obtained by linearly transforming the current input and used as the "query" to calculate the attention weight. K is obtained by linearly transforming the current input and used as the "key" to calculate the attention weight. The similarity between the "query" and the "key" determines the relevance between the current word and other words.
[0042] S22. Based on the question text token and the generated token, determine the average attention weight of the h-th attention head on the output part.
[0043] In one feasible implementation, based on (1) above, given the output sequence , for each attention head, the average attention weight of its output part can be expressed as the following formula (3):
[0044] (3)
[0045] in, It represents the average attention weight of the h-th attention head on the output part.
[0046] S23. Determine the ratio of the average attention weight of the output part to the average attention weight of the context part as the context fidelity.
[0047] In a feasible implementation, in order to characterize the degree of dependence of the model on the context when generating new sequences, an embodiment of the present invention defines the concept of context fidelity: the ratio of the average attention weight of the output part to the average attention weight of the context part is determined as the context fidelity.
[0048] S24: Aggregate multiple context fidelity measures to obtain a context fidelity aggregation result.
[0049] In a feasible implementation, multiple ratios are aggregated, and the obtained aggregation result can be regarded as an array.
[0050] S25. Input the context fidelity aggregation result into a single-layer multi-layer perceptron classifier, and determine the conflict prediction result through binary classification.
[0051] In one feasible implementation, the embodiment of the present invention trains a single-layer multi-layer perceptron (MLP) classifier, whose input is the aggregated result of the contextual fidelity scores from all L layers of Transformers and H attention heads, and the output is the conflict prediction result. , as shown in formula (4):
[0052] (4)
[0053] in, n represents the sequence length, l Indicates the number of layers of Transformer, classifier() indicates the processing of a single-layer multi-layer perceptron classifier, represents the weight of a single-layer multilayer perceptron classifier, express l The aggregation result of the attention weights of h Transformer layers and h attention heads. There are many ways to calculate the aggregation, one of which is to calculate the sum and average.
[0054] The conflict prediction result will be used as the routing judgment standard for the subsequent decoding path, so that differentiated processing strategies can be adopted for conflicts of different levels during decoding.
[0055] By proposing a "context fidelity" indicator and combining it with an attention map for conflict prediction, the embodiment of the present invention can identify potential context-memory conflicts before decoding, implement targeted intervention, and avoid model generation being disturbed by false memories.
[0056] Traditional decoding methods often uniformly apply contextual intervention to all tokens, which can lead to performance degradation for non-conflicting inputs. This invention introduces conflict routing judgment and employs lightweight greedy decoding in non-conflicting situations, effectively avoiding excessive intervention and maintaining the original model generation capability.
[0057] S3. When the conflict prediction result is true, based on the dynamic adjustment mechanism, the balance weight in decoding is adjusted, and according to the adjusted balance weight, the dynamic comparative decoding distribution is determined. According to the dynamic comparative decoding distribution, the answer text corresponding to the question text is output.
[0058] In one implementation, this module mitigates the conflict between context and model memory through a dynamic contrastive decoding mechanism. During the generation process, this module computes the output distribution of the model when generated solely based on its parameters (i.e., in the absence of context) and when the model incorporates contextual information. The goal of contrastive decoding is to amplify the difference between the two distributions, thereby increasing the dominance of contextual knowledge on the output and reducing the model's reliance on its internal memory.
[0059] Existing context-aware decoding methods typically use fixed hyperparameters to balance the influence of contextual information and model memory. However, this fixed parameter approach struggles to adapt to the dynamic changes in conflict levels in reality. To address this, the present invention introduces a dynamic adjustment mechanism based on contextual fidelity.
[0060] There are two cases for conflict prediction results: the conflict is true or the conflict is false. Based on the output of the conflict prediction module, the system automatically selects a decoding strategy: if the prediction result shows that there is no conflict in the input content, that is, when the conflict prediction result is false, the question text and the target context are input into the Transformer model based on greedy decoding (GD), and the answer text corresponding to the question text is output; if there is a potential conflict, the dynamic contrastive decoding (DCD) method is used to generate a more consistent and accurate output by enhancing the context guidance. Given the context c, the question q, and the conflict prediction result , the decoding routing process is as follows:
[0061] like Is true (a conflict exists):
[0062] like is false (no conflict):
[0063] Among them, DCD() indicates that dynamic contrast decoding is used for processing, and GD() indicates that greedy decoding is used for processing.
[0064] Optionally, when the conflict result is true, specific operations include the following S31-S33:
[0065] S31. Based on the normalized context fidelity, the hyperparameters for controlling context sensitivity, and the original decoding weights, an adjusted balance weight is obtained.
[0066] In a feasible implementation, for each generated token, the balance weight in decoding is adaptively adjusted, specifically in the following form (5):
[0067] (5)
[0068] in, represents the balance weight, represents the original weight, represents the normalized context fidelity, is a hyperparameter that controls context sensitivity. This mechanism allows for fine-grained conflict mitigation at the token level. Normalization involves averaging multiple values to obtain the feature value.
[0069] S32: Determine a dynamic contrast decoding distribution based on the adjusted balance weight, the model's prediction results, the target context, and the input sequence.
[0070] In a feasible implementation, the final dynamic contrast decoding distribution is defined as follows (6):
[0071] (6)
[0072] in, Representation parameters The conditional probability distribution of the model defined, Indicates the current The prediction results of the moment model, Indicates context, represents the input sequence, express The sequence at which the moment has been generated.
[0073] S33. Adjust the decoding distribution of the Transformer model according to the dynamic contrast decoding distribution, input the question text and the target context into the adjusted Transformer model, and output the answer text corresponding to the question text.
[0074] The embodiment of the present invention introduces a dynamic contrast decoding mechanism in the decoding stage, adaptively adjusts the context guidance strength according to the predicted conflict level, and realizes fine-grained control of different conflict levels, thereby improving the model's adaptability to complex question-answering tasks.
[0075] In addition, in order to evaluate the decoding performance of large language models in handling context-memory conflicts, an embodiment of the present invention designs and constructs a knowledge conflict benchmark dataset ConflictQA for question-answering tasks, which can be closer to real application scenarios and is particularly suitable for situations where knowledge is frequently updated but the model is not updated in a timely manner.
[0076] The method comprises the following steps:
[0077] (1) Knowledge extraction:
[0078] The present invention is based on high-quality structured knowledge base (such as Wikidata) for context construction. Knowledge is in the form of triples Represents, corresponding to the subject, relation and object respectively. For a given question, retrieve the subgraph related to it from the knowledge base , as knowledge support for the current problem.
[0079] (2) Conflict structure:
[0080] To simulate knowledge conflict, select triples containing the correct answer from the subgraph , replacing its object with an entity with similar semantics but contradictory content , construct conflicting triples , and generate the corresponding conflict subgraph .
[0081] (3) Context generation:
[0082] The present invention uses a large language model (LLM) to generate language for the original knowledge subgraph and the conflict subgraph respectively, and obtains a natural and fluent context paragraph. and Input into the predefined template to guide the large language model to generate conflict-free context and conflict context.
[0083] (4) Data quality control:
[0084] During the construction process, multi-level quality screening is performed, including: filtering invalid questions (such as no answers or an abnormal number of answers); verifying the type consistency and semantic opposition of conflicting entities; and comparing the generated text with the sub-graph content to ensure that the knowledge points embedded in the context are authentic and accurate.
[0085] The dataset constructed by this method can be used to accurately evaluate the model's responsiveness and decoding stability under real knowledge conflict conditions, providing strong support for the development and verification of conflict perception generation technology.
[0086] In an embodiment of the present invention, for non-conflicting inputs, the intervention of contrastive decoding is minimized to maintain natural and smooth generation; for conflicting inputs, the output influence between contextual information and model memory is dynamically balanced, thereby improving the correctness and robustness of generation. Moreover, there is no need for additional fine-tuning of the language model, and as a decoding strategy, it can be directly integrated into a variety of existing open source large models (such as Llama2, Llama3, Mistral, etc.), with good cross-model compatibility and engineering deployment convenience. By introducing a conflict perception mechanism and dynamic decoding path routing in the large language model inference process, the generation accuracy and context consistency of the model in knowledge conflict scenarios are significantly improved. In summary, the present invention achieves efficient coordination between conflict perception, dynamic adjustment and context enhancement by introducing a lightweight inference control strategy without modifying the model structure, providing a universal and effective technical path for the trusted reasoning and stable generation of large language models, with significant practical application value and promotion prospects.
[0087] Figure 2 This is a block diagram of a large model context conflict resolution device based on dynamic coordinated decoding provided by an embodiment of the present invention. The device is used in a large model context conflict resolution method based on dynamic coordinated decoding. Figure 2 The device includes an acquisition unit 210, a determination unit 220, and an adjustment unit 230.
[0088] An acquisition unit 210 is used to acquire the question text, the target context, and the Transformer model that answers the question;
[0089] a determination unit 220 for determining context fidelity based on the question text token, the target context token, the generated token, and multiple parallel attention heads of the Transformer model, and determining a conflict prediction result according to the context fidelity;
[0090] The adjustment unit 230 is used to adjust the balance weight in decoding based on the dynamic adjustment mechanism when the conflict prediction result is true, determine the dynamic comparison decoding distribution according to the adjusted balance weight, and output the answer text corresponding to the question text according to the dynamic comparison decoding distribution.
[0091] In this embodiment of the present invention, for non-conflicting inputs, contrastive decoding intervention is minimized to maintain natural and smooth generation. For conflicting inputs, the output influence between contextual information and model memory is dynamically balanced, thereby improving the accuracy and robustness of generation. Furthermore, without requiring additional fine-tuning of the language model, the decoding strategy can be directly integrated into a variety of existing large open-source models (such as Llama2, Llama3, and Mistral), ensuring excellent cross-model compatibility and ease of engineering deployment. By introducing a conflict-aware mechanism and dynamic decoding path routing into the inference process of large language models, the model's generation accuracy and contextual consistency in knowledge conflict scenarios are significantly improved. In summary, this invention, by introducing a lightweight inference control strategy, achieves efficient coordination between conflict awareness, dynamic adjustment, and context enhancement without modifying the model structure. This provides a universal and effective technical approach for trusted inference and stable generation of large language models, with significant practical application value and widespread application prospects.
[0092] Figure 3 Schematic diagram of a large model context conflict resolution device based on dynamic coordinated decoding provided by an embodiment of the present invention. Figure 3 As shown, the large model context conflict resolution device based on dynamic coordinated decoding may include the above Figure 2 The large model context conflict resolution device based on dynamic coordinated decoding is shown. Optionally, the large model context conflict resolution device 310 based on dynamic coordinated decoding may include a first processor 2001 .
[0093] Optionally, the large model context conflict resolution device 310 based on dynamic coordinated decoding may further include a memory 2002 and a transceiver 2003 .
[0094] The first processor 2001, the memory 2002 and the transceiver 2003 may be connected via a communication bus.
[0095] The following combination Figure 3 The components of the large model context conflict resolution device 310 based on dynamic coordinated decoding are described in detail:
[0096] The first processor 2001 is the control center of the large-model context conflict resolution device 310 based on dynamic coordinated decoding, and can be a single processor or a collective term for multiple processing elements. For example, the first processor 2001 can be one or more central processing units (CPUs), or application-specific integrated circuits (ASICs), or one or more integrated circuits configured to implement embodiments of the present invention, such as one or more digital signal processors (DSPs) or one or more field programmable gate arrays (FPGAs).
[0097] Optionally, the first processor 2001 may execute various functions of the large model context conflict resolution device 310 based on dynamic coordinated decoding by running or executing a software program stored in the memory 2002 and calling data stored in the memory 2002 .
[0098] In a specific implementation, as an embodiment, the first processor 2001 may include one or more CPUs, such as Figure 3 CPU0 and CPU1 are shown in FIG.
[0099] In a specific implementation, as an embodiment, the large model context conflict resolution device 310 based on dynamic coordinated decoding may also include multiple processors, such as Figure 3 1 and 2. The first processor 2001 and the second processor 2004 are shown in FIG. Each of these processors can be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). A processor herein can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0100] The memory 2002 is used to store the software program for executing the solution of the present invention, and is controlled by the first processor 2001 for execution. The specific implementation method can refer to the above method embodiment and will not be repeated here.
[0101] Optionally, the memory 2002 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 2002 may be integrated with the first processor 2001 or exist independently and access the memory 2002 through the interface circuit ( Figure 3 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0102] The transceiver 2003 is used to communicate with a network device or a terminal device.
[0103] Optionally, the transceiver 2003 may include a receiver and a transmitter ( Figure 3 The receiver is used to implement a receiving function, and the transmitter is used to implement a sending function.
[0104] Optionally, the transceiver 2003 may be integrated with the first processor 2001 or may exist independently and be implemented through the interface circuit ( Figure 3 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0105] It should be noted that Figure 3 The structure of the large model context conflict resolution device 310 based on dynamic coordinated decoding shown in the figure does not constitute a limitation on the router. The actual knowledge structure recognition device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0106] In addition, the technical effects of the large model context conflict resolution device 310 based on dynamic coordinated decoding can refer to the technical effects of the large model context conflict resolution method based on dynamic coordinated decoding described in the above method embodiment, and will not be repeated here.
[0107] It should be understood that the first processor 2001 in the embodiment of the present invention may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc.
[0108] It should also be understood that the memory in the embodiments of the present invention may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0109] The above embodiments can be implemented in whole or in part via software, hardware (e.g., circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product comprises one or more computer instructions or computer programs. When loaded or executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are fully or partially performed. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server or data center that contains a collection of one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media. The semiconductor media can be a solid-state drive.
[0110] It should be understood that the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. A and B can be singular or plural. Furthermore, the character " / " as used herein generally indicates an "or" relationship between the associated objects, but it may also indicate an "and / or" relationship. For specific understanding, please refer to the context.
[0111] In this disclosure, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, "at least one of a, b, or c" can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or plural.
[0112] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0113] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0114] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0115] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of the device or unit, which can be electrical, mechanical or other forms.
[0116] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0117] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0118] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the present application that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0119] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A large model context conflict resolution method based on dynamic coordinated decoding, characterized in that: The method comprises: S1, Transformer model that obtains question text, target context, and answers the question; S2, based on the question text token, target context token, generated token and multiple parallel attention heads of the Transformer model, determines the context fidelity and determines the conflict prediction result according to the context fidelity; S3. When the conflict prediction result is true, based on the dynamic adjustment mechanism, the balance weight in the decoding is adjusted, and according to the adjusted balance weight, the dynamic comparative decoding distribution is determined, and according to the dynamic comparative decoding distribution, the answer text corresponding to the question text is output; S3 includes: S31, obtaining an adjusted balance weight based on the normalized context fidelity, the hyperparameter controlling the context sensitivity, and the original decoding weight; Among them, for each generated token, the balance weight in decoding is adaptively adjusted, and the specific form is as follows (5): (5) in, represents the balance weight, represents the original weight, represents the normalized context fidelity, A hyperparameter to control context sensitivity; S32, determining a dynamic contrast decoding distribution based on the adjusted balance weight, the model's prediction results, the target context, and the input sequence; The final dynamic contrast decoding distribution is defined as follows (6): (6) in, Representation parameters The conditional probability distribution of the model defined, Indicates the current The prediction results of the moment model, Indicates context, represents the input sequence, express The sequence of moments that have been generated; S33. Adjust the decoding distribution of the Transformer model according to the dynamic contrast decoding distribution, input the question text and the target context into the adjusted Transformer model, and output the answer text corresponding to the question text.
2. The large model context conflict resolution method based on dynamic coordinated decoding according to claim 1 is characterized in that: S2 determines contextual fidelity based on question text tokens, context tokens, generated tokens, and multiple parallel attention heads of the Transformer model, including: S21. Based on the question text token and the context token, determine the average attention weight of the h-th attention head on the context part; S22. Based on the question text token and the generated token, determine the average attention weight of the h-th attention head on the output part; S23. Determine the ratio of the average attention weight of the output part to the average attention weight of the context part as the context fidelity.
3. The large model context conflict resolution method based on dynamic coordinated decoding according to claim 1, characterized in that: The step S2 of determining the conflict prediction result according to the context fidelity includes: S24, aggregating multiple context fidelity measures to obtain a context fidelity aggregation result; S25. Input the context fidelity aggregation result into a single-layer multi-layer perceptron classifier, and determine the conflict prediction result through binary classification.
4. The large model context conflict resolution method based on dynamic coordinated decoding according to claim 1, characterized in that: The method further comprises: When the conflict prediction result is false, the question text and target context are input into the Transformer model based on greedy decoding, and the answer text corresponding to the question text is output.
5. A large model context conflict resolution device based on dynamic coordinated decoding, wherein the large model context conflict resolution device based on dynamic coordinated decoding is used to implement the large model context conflict resolution method based on dynamic coordinated decoding according to any one of claims 1 to 4, characterized in that: The device comprises: The acquisition unit is used to obtain the question text, target context, and the Transformer model for answering the question; The determination unit is used to determine the context fidelity based on the question text token, target context token, generated token, and multiple parallel attention heads of the Transformer model, and determine the conflict prediction result based on the context fidelity; an adjustment unit, configured to adjust a balance weight in decoding based on a dynamic adjustment mechanism when a conflict prediction result is true, determine a dynamic comparative decoding distribution based on the adjusted balance weight, and output an answer text corresponding to the question text based on the dynamic comparative decoding distribution; Adjustment unit for: S31, obtaining an adjusted balance weight based on the normalized context fidelity, the hyperparameter controlling the context sensitivity, and the original decoding weight; Among them, for each generated token, the balance weight in decoding is adaptively adjusted, and the specific form is as follows (5): (5) in, represents the balance weight, represents the original weight, represents the normalized context fidelity, A hyperparameter to control context sensitivity; S32, determining a dynamic contrast decoding distribution based on the adjusted balance weight, the model's prediction results, the target context, and the input sequence; The final dynamic contrast decoding distribution is defined as follows (6): (6) in, Representation parameters The conditional probability distribution of the model defined, Indicates the current The prediction results of the moment model, Indicates context, represents the input sequence, express The sequence of moments that have been generated; S33. Adjust the decoding distribution of the Transformer model according to the dynamic contrast decoding distribution, input the question text and the target context into the adjusted Transformer model, and output the answer text corresponding to the question text.
6. The large model context conflict resolution device based on dynamic coordinated decoding according to claim 5, characterized in that: The determining unit is configured to: S21. Based on the question text token and the context token, determine the average attention weight of the h-th attention head on the context part; S22. Based on the question text token and the generated token, determine the average attention weight of the h-th attention head on the output part; S23. Determine the ratio of the average attention weight of the output part to the average attention weight of the context part as the context fidelity.
7. A large model context conflict resolution device based on dynamic coordinated decoding, characterized in that: The large model context conflict resolution device based on dynamic coordinated decoding includes: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 4 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Dynamic comparison decoding method and device based on conflict perception, equipment and medium
CN119293172A