A knowledge conflict identification method, device and electronic device based on information entropy
By calculating the information entropy of the output distribution of problems and contextual knowledge in large language models, identifying the knowledge conflict between parameterized knowledge and contextual knowledge, the problem of insufficient recognition of knowledge conflicts in the existing technology is solved, and the prediction performance of large language models is improved .
Patent Information
- Application Number
- CN202411554204.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-04
AI Technical Summary
During the inference process, the existing large language models have inconsistent external context knowledge and model parameterized knowledge, resulting in knowledge conflicts. The existing decoding strategy cannot meet the requirements of real scenarios, resulting in a degradation of prediction performance.
By inputting the problem and related context knowledge into the large language model, calculating the information entropy of the two output distributions, and judging whether the information entropy meets the constraints, we can identify the knowledge conflict between parameterized knowledge and contextual knowledge.
It realizes the precise identification of knowledge conflicts by large language models before decoding, and targeted mitigation of knowledge conflicts, avoiding performance degradation caused by conflict mitigation in the absence of knowledge conflicts.
Smart Images

Figure CN119067212B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a knowledge conflict identification method, device and electronic equipment based on information entropy. Background Art
[0002] Large language models can be widely used in many tasks such as natural language understanding, generation, reasoning, question answering, etc., and have shown great potential in multiple application scenarios. However, as the size of data and parameters grows, the limitations of the model's parameterized knowledge become more and more obvious. Therefore, large language models will integrate external contextual knowledge during the reasoning process. However, when the external contextual knowledge accurately contains factual knowledge related to the problem, but is inconsistent (conflicting) with the model's parameterized knowledge, a knowledge conflict occurs.
[0003] At present, the decoding strategies of large language models for the problem of knowledge conflict all rely on a basic assumption: the data in the current experimental setting have knowledge conflicts. However, in reality, not all scenarios have knowledge conflicts, so the assumption of knowledge conflicts cannot meet the requirements of real scenarios, resulting in a decrease in the prediction performance of large language models. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides the following technical solutions.
[0005] A first aspect of the present invention provides a knowledge conflict identification method based on information entropy, comprising:
[0006] Inputting a question into a large language model, outputting a first answer and obtaining a first output distribution, wherein the first output distribution is an output distribution that only includes parameterized knowledge;
[0007] Inputting the question and contextual knowledge related to the question into the large language model, outputting a second answer and obtaining a second output distribution, wherein the second output distribution is an output distribution including parameterized knowledge and contextual knowledge;
[0008] Calculate a first information entropy of a first answer using the first output distribution; calculate a second information entropy of a second answer using the second output distribution;
[0009] It is determined whether the first information entropy and the second information entropy satisfy the constraint condition. If the constraint condition is satisfied, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge; otherwise, there is a knowledge conflict between the parameterized knowledge and the contextual knowledge.
[0010] Preferably, the constraints are:
[0011] ;
[0012] ;
[0013] ;
[0014] in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution.
[0015] Preferably, the first answer and the second answer are both at token level.
[0016] Preferably, the information entropy-based knowledge conflict identification method provided by the present invention further includes the step of marking the contextual knowledge to distinguish whether there is a knowledge conflict between the contextual knowledge and the parameterized knowledge.
[0017] A second aspect of the present invention provides a decoding method based on the knowledge conflict identification method of the first aspect, comprising:
[0018] Using the knowledge conflict identification method described in the first aspect to determine whether there is a knowledge conflict between parameterized knowledge and contextual knowledge,
[0019] If there is knowledge conflict, the model decodes by reinforcing contextual knowledge;
[0020] If there is no knowledge conflict, the model relies on parameterized knowledge for decoding.
[0021] A third aspect of the present invention provides a knowledge conflict identification device based on information entropy, comprising:
[0022] A first reasoning module, configured to input a question into the large language model, output a first answer and obtain a first output distribution, wherein the first output distribution is an output distribution that only includes parameterized knowledge;
[0023] A second reasoning module is used to input the question and the contextual knowledge related to the question into the large language model, output a second answer and obtain a second output distribution, where the second output distribution is an output distribution including parameterized knowledge and contextual knowledge;
[0024] An information entropy calculation module, used to calculate a first information entropy of a first answer using the first output distribution; and calculate a second information entropy of a second answer using the second output distribution;
[0025] The knowledge conflict judgment module is used to judge whether the first information entropy and the second information entropy meet the constraint conditions. If the constraint conditions are met, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge; otherwise, there is a knowledge conflict between the parameterized knowledge and the contextual knowledge.
[0026] Preferably, in the knowledge conflict identification device based on information entropy, the constraint condition is:
[0027] ;
[0028] ;
[0029] ;
[0030] in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution.
[0031] Preferably, in the knowledge conflict identification device based on information entropy, the first answer and the second answer are both at token level.
[0032] A fourth aspect of the present invention provides a memory storing a plurality of instructions, wherein the instructions are used to implement the knowledge conflict identification method based on information entropy as described in the first aspect, and the decoding method as described in the second aspect.
[0033] The fifth aspect of the present invention provides an electronic device, comprising a processor and a memory connected to the processor, the memory storing a plurality of instructions, the instructions being loaded and executed by the processor so that the processor can execute the knowledge conflict identification method based on information entropy as described in the first aspect, and the decoding method as described in the second aspect.
[0034] The beneficial effects of the present invention are as follows: the present invention provides a method, device and electronic device for identifying knowledge conflicts based on information entropy, which calculates the first information entropy of the first answer by using the first output distribution, and calculates the second information entropy of the second answer by using the second output distribution; and determines whether the first information entropy and the second information entropy meet the constraint conditions to determine whether there is a knowledge conflict between parameterized knowledge and contextual knowledge, so that the large language model can accurately identify the knowledge conflict before decoding, and then alleviate the situation where the knowledge conflict exists in a targeted manner, avoiding the problem in the prior art that knowledge conflicts are alleviated in all situations, resulting in performance degradation in the absence of knowledge conflicts. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a flow chart of the knowledge conflict identification method based on information entropy according to the present invention;
[0036] Figure 2 Schematic diagram of the functional structure of the knowledge conflict identification device based on information entropy according to the present invention. DETAILED DESCRIPTION
[0037] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0038] The method provided by the present invention can be implemented in the following terminal environment, and the terminal may include one or more of the following components: a processor, a memory, and a display screen. The memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the method described in the following embodiment.
[0039] The processor may include one or more processing cores. The processor uses various interfaces and lines to connect various parts of the entire terminal, and executes various functions of the terminal and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory, and calling data stored in the memory.
[0040] The memory may include random access memory (RAM) or read-only memory (ROM). The memory may be used to store instructions, programs, codes, code sets or instructions.
[0041] The display screen is used to display the user interface of each application.
[0042] In addition, those skilled in the art can understand that the structure of the above terminal does not constitute a limitation on the terminal, and the terminal may include more or fewer components, or combine certain components, or arrange the components differently. For example, the terminal also includes components such as a radio frequency circuit, an input unit, a sensor, an audio circuit, and a power supply, which will not be described in detail here.
[0043] Embodiment 1
[0044] like Figure 1 As shown, an embodiment of the present invention provides a knowledge conflict identification method based on information entropy, including:
[0045] S101, inputting a question into a large language model, outputting a first answer and obtaining a first output distribution, wherein the first output distribution is an output distribution that only contains parameterized knowledge;
[0046] S102, inputting the question and contextual knowledge related to the question into the large language model, outputting a second answer and obtaining a second output distribution, wherein the second output distribution is an output distribution including parameterized knowledge and contextual knowledge;
[0047] S103, calculating a first information entropy of the first answer using the first output distribution; calculating a second information entropy of the second answer using the second output distribution;
[0048] S104, judging whether the first information entropy and the second information entropy satisfy the constraint condition. If the constraint condition is satisfied, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge; otherwise, there is a knowledge conflict between the parameterized knowledge and the contextual knowledge.
[0049] In a preferred embodiment of the present invention, the constraint condition is:
[0050] ;
[0051] ;
[0052] ;
[0053] in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution.
[0054] In the embodiment of the present invention, the first answer and the second answer are both at the token level.
[0055] The method for identifying knowledge conflicts based on information entropy provided in the embodiment of the present invention may further include the step of marking the context knowledge to distinguish whether there is a knowledge conflict between the context knowledge and the parameterized knowledge.
[0056] In the research process of the knowledge conflict identification method based on information entropy provided by the present invention, it is first assumed that the context knowledge is consistent with the parameterized knowledge of the model, so the context knowledge can be regarded as a text generation of the model under certain conditions. Based on this assumption, the research uses the stable entropy hypothesis and local typical theory to derive the context information entropy constraint for identifying knowledge conflicts at the token level.
[0057] The stable entropy hypothesis holds that the generation of natural language usually falls within a narrow and flat entropy band, so the generation without conflicting contextual knowledge is regarded as the natural generation of the model. If the generation of the model deviates from the specified entropy band, it indicates that there is a potential conflict in the contextual knowledge. In this case, it is necessary to accurately identify specific tokens (which can be understood as words in this invention) that reflect the conflict. These tokens may cause the model to exceed the boundaries of the specified entropy band during the generation process. In order to solve this problem, local typical sets can be used to limit the change in the information entropy of tokens, that is, to introduce constraints:
[0058] ;
[0059] ;
[0060] ;
[0061] In other words, the change in information entropy can be constrained by a constant γ. This means that if the change in information entropy of a token complies with this constraint, the token can be considered as a possible non-conflicting context generation. On the contrary, any token that exceeds this constraint represents a probabilistic conflict.
[0062] Therefore, in the decoding process of the large language model, words whose information entropy changes comply with the constraints (within the constraints) represent the consistency between contextual knowledge and parameterized knowledge, and there is no conflict. These words are defined as non-conflicting words. On the contrary, words whose information entropy changes do not comply with the constraints (fall into the out-of-bounds area) are associated with conflicts in contextual knowledge, and these words are defined as conflicting words.
[0063] Embodiment 2
[0064] The embodiment of the present invention provides a decoding method based on the knowledge conflict identification method described in Embodiment 1, comprising:
[0065] Using the knowledge conflict identification method described in the first embodiment to determine whether there is a knowledge conflict between parameterized knowledge and contextual knowledge,
[0066] If there is knowledge conflict, the model decodes by reinforcing contextual knowledge;
[0067] If there is no knowledge conflict, the model relies on parameterized knowledge for decoding.
[0068] In this method, knowledge conflicts are first accurately identified, and then situations where knowledge conflicts exist are alleviated in a targeted manner, thereby avoiding the problem of reduced performance of large language models caused by conflict alleviation in the absence of knowledge conflicts in the prior art.
[0069] Moreover, in the case of knowledge conflicts, the model can give priority to contextual knowledge when decoding, that is, decoding by strengthening contextual knowledge. In the case of no knowledge conflicts, the model can encourage more reliance on parameterized knowledge rather than relying entirely on contextual knowledge when decoding, because contextual knowledge may not be able to fully solve the query problem and has cognitive limitations.
[0070] By adopting this method, the large language model can have the ability to alleviate conflicts while also having the ability to process non-conflicting external knowledge, both of which show good performance.
[0071] Embodiment 3
[0072] like Figure 2 As shown, another aspect of the present invention also includes a functional module architecture that is completely consistent with the aforementioned method flow, that is, the embodiment of the present invention also provides a knowledge conflict identification device based on information entropy, including:
[0073] A first reasoning module 201 is used to input a question into a large language model, output a first answer and obtain a first output distribution, where the first output distribution is an output distribution that only contains parameterized knowledge;
[0074] A second reasoning module 202, configured to input the question and contextual knowledge related to the question into the large language model, output a second answer and obtain a second output distribution, wherein the second output distribution is an output distribution including parameterized knowledge and contextual knowledge;
[0075] An information entropy calculation module 203 is used to calculate a first information entropy of a first answer using the first output distribution; and calculate a second information entropy of a second answer using the second output distribution;
[0076] The knowledge conflict judgment module 204 is used to judge whether the first information entropy and the second information entropy meet the constraint conditions. If the constraint conditions are met, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge; otherwise, there is a knowledge conflict between the parameterized knowledge and the contextual knowledge.
[0077] The constraints are:
[0078] ;
[0079] ;
[0080] ;
[0081] in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution.
[0082] The first answer and the second answer are both at the token level.
[0083] The information entropy-based knowledge conflict identification device provided in the embodiment of the present invention may further include a marking module for marking contextual knowledge to distinguish whether there is a knowledge conflict between the contextual knowledge and the parameterized knowledge.
[0084] The device can be implemented by the knowledge conflict identification method based on information entropy provided in the above-mentioned embodiment 1. The specific implementation method can be found in the description of embodiment 1 and will not be repeated here.
[0085] The present invention also provides a memory storing a plurality of instructions, wherein the instructions are used to implement the knowledge conflict identification method based on information entropy as described in the first embodiment, and the decoding method as described in the second embodiment.
[0086] The present invention also provides an electronic device, comprising a processor and a memory connected to the processor, wherein the memory stores a plurality of instructions, and the instructions can be loaded and executed by the processor so that the processor can execute the knowledge conflict identification method based on information entropy as described in Example 1, and the decoding method as described in Example 2.
[0087] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A knowledge conflict identification method based on information entropy, characterized in that: include: Inputting a question into a large language model, outputting a first answer and obtaining a first output distribution, wherein the first output distribution is an output distribution that only includes parameterized knowledge; Inputting the question and contextual knowledge related to the question into the large language model, outputting a second answer and obtaining a second output distribution, wherein the second output distribution is an output distribution including parameterized knowledge and contextual knowledge; Calculating a first information entropy of a first answer using the first output distribution; Calculating a second information entropy of a second answer using the second output distribution; Determine whether the first information entropy and the second information entropy satisfy the constraint condition. If the constraint condition is satisfied, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge. Otherwise, there is a knowledge conflict between parameterized knowledge and contextual knowledge; Assuming that the contextual knowledge is consistent with the parameterized knowledge of the model, the contextual knowledge is regarded as a text generation of the model under certain conditions; Based on this assumption, using the stable entropy hypothesis and local representative theory, the context information entropy constraint is derived to identify knowledge conflicts at the token level. The constraint condition is: ; ; ; in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution; The first answer and the second answer are both at the token level.
2. The method for identifying knowledge conflicts based on information entropy according to claim 1, characterized in that: The method also includes the step of marking the context knowledge to distinguish whether there is a knowledge conflict between the context knowledge and the parameterized knowledge.
3. A decoding method based on the knowledge conflict identification method according to any one of claims 1 to 2, characterized in that: include: Using the knowledge conflict identification method according to any one of claims 1 to 2, determining whether there is a knowledge conflict between parameterized knowledge and contextual knowledge, If there is knowledge conflict, the model decodes it by strengthening the contextual knowledge; If there is no knowledge conflict, the model relies on parameterized knowledge for decoding.
4. A knowledge conflict identification device based on information entropy, characterized in that: include: A first reasoning module, configured to input a question into the large language model, output a first answer and obtain a first output distribution, wherein the first output distribution is an output distribution that only includes parameterized knowledge; A second reasoning module is used to input the question and the contextual knowledge related to the question into the large language model, output a second answer and obtain a second output distribution, where the second output distribution is an output distribution including parameterized knowledge and contextual knowledge; An information entropy calculation module, used to calculate a first information entropy of a first answer using the first output distribution; Calculating a second information entropy of a second answer using the second output distribution; A knowledge conflict judgment module is used to judge whether the first information entropy and the second information entropy meet the constraint condition. If the constraint condition is met, there is no knowledge conflict between the parameterized knowledge and the contextual knowledge. Otherwise, there is a knowledge conflict between parameterized knowledge and contextual knowledge; Assuming that the contextual knowledge is consistent with the parameterized knowledge of the model, the contextual knowledge is regarded as a text generation of the model under certain conditions; Based on this assumption, using the stable entropy hypothesis and local representative theory, the contextual information entropy constraint is derived to identify knowledge conflicts at the token level. The constraints are: ; ; ; in, is the second information entropy, For the second answer, is the first information entropy, For the first answer, is a constant, For the problem, is the contextual knowledge related to the question, is the first output distribution, is the second output distribution; The first answer and the second answer are both at the token level.
5. A memory, characterized in that: Multiple instructions are stored, and the instructions are used to implement the knowledge conflict identification method based on information entropy as described in any one of claims 1-2, and the decoding method as described in claim 3.
6. An electronic device, characterized in that: It includes a processor and a memory connected to the processor, the memory stores multiple instructions, and the instructions can be loaded and executed by the processor to enable the processor to execute the knowledge conflict identification method based on information entropy as described in any one of claims 1-2, and the decoding method as described in claim 3.
Citation Information
Patent Citations
Knowledge question and answer method, system and device and storage medium
CN117370890A
Data analysis method and device based on entropy, electronic equipment and storage medium
CN117874408A