A reasoning method based on counterfactual termination of judgment and related products

By constructing a counterfactual reasoning trajectory and comparing it with the original trajectory, the sufficiency of information in the large language model is determined, which solves the problem of insufficient information evaluation in the existing technology and realizes an efficient and accurate reasoning process.

CN122133815APending Publication Date: 2026-06-02太保科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
太保科技有限公司
Filing Date
2026-04-29
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Large language models cannot accurately assess whether the information they have can support reliable conclusions, leading to redundant reasoning in simple problems and hasty termination in complex problems, wasting computing power and outputting incorrect answers.

Method used

By generating counterfactual reasoning trajectories, deleting key information, and re-reasoning, the differential results are constructed to determine the termination condition of the reasoning, and the model parameters are dynamically adjusted to adapt to information sufficiency.

Benefits of technology

It improves the accuracy and computational resource utilization efficiency of large language models in reasoning tasks, avoids wasted computing power and incorrect answers, and enhances the adaptability to out-of-distribution problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122133815A_ABST
    Figure CN122133815A_ABST
Patent Text Reader

Abstract

This application discloses a reasoning method and related products based on counterfactual termination judgment. The method includes: acquiring the reasoning trajectory of a user's question; generating a counterfactual reasoning trajectory based on the reasoning trajectory, wherein the counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set on which the reasoning trajectory is based; comparing the reasoning trajectory with the counterfactual reasoning trajectory to obtain a difference result; and determining whether the reasoning trajectory meets the reasoning termination condition based on the difference result. In this way, by deleting at least one key piece of information from the key information set on which the reasoning trajectory is based and re-reasoning, a counterfactual reasoning trajectory is obtained. Comparing this counterfactual reasoning trajectory with the original reasoning trajectory and accurately determining whether the information currently held by the large language model is sufficient to support a reliable conclusion based on the obtained difference result, the method determines whether the reasoning trajectory meets the reasoning termination condition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a reasoning method and related products based on counterfactual termination judgment. Background Technology

[0002] Large Language Model (LLM) refers to a deep learning model trained on a large amount of text data. This model can generate natural language text or understand the meaning of language text, and to some extent simulates the human language cognition and generation process.

[0003] However, in practical applications, large language models cannot accurately assess whether the information they possess can support a reliable conclusion. This leads to redundant, long-chain reasoning for simple problems, wasting computational resources. For complex problems, large language models often prematurely terminate before acquiring crucial information, outputting incorrect answers. Summary of the Invention

[0004] This application provides a reasoning method and related products based on counterfactual termination judgment. It can obtain a counterfactual reasoning trajectory by deleting at least one key piece of information from the key information set on which the reasoning trajectory is based and then re-reasoning. The counterfactual reasoning trajectory is then compared with the original reasoning trajectory. Based on the difference obtained, it can accurately determine whether the information currently held by the large language model is sufficient to support a reliable conclusion, thereby determining whether the reasoning trajectory meets the reasoning termination condition.

[0005] In a first aspect, embodiments of this application provide a reasoning method based on counterfactual termination judgment, applied to a large language model, the method comprising: Obtain the reasoning trajectory of the user's question; Based on the reasoning trajectory, a counterfactual reasoning trajectory is generated, wherein the counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set on which the reasoning trajectory is based; The inference trajectory is compared with the counterfactual inference trajectory to obtain the difference results; Based on the difference results, determine whether the reasoning trajectory satisfies the reasoning termination condition.

[0006] One feasible implementation, wherein determining whether the inference trajectory satisfies the inference termination condition based on the difference result, includes: If the difference result is greater than or equal to a preset threshold, the inference trajectory is determined to satisfy the inference termination condition; If the difference result is less than the preset threshold, it is determined that the inference trajectory does not meet the inference termination condition.

[0007] One feasible implementation, after determining that the inference trajectory satisfies the inference termination condition, further includes: Output the results corresponding to the inference trajectory.

[0008] In one feasible implementation, after determining that the inference trajectory does not satisfy the inference termination condition, the method further includes: Based on the user's question, generate derivative questions; Based on the aforementioned derivative problem, the large language model is temporarily updated to obtain the updated large language model. The user question is re-reasoned based on the updated large language model to obtain the target reasoning trajectory.

[0009] One feasible implementation of the method further includes: Based on the target reasoning trajectory, a target counterfactual reasoning trajectory is generated, wherein the target counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of target information from the target key information set on which the target reasoning trajectory is based; Based on the target reasoning trajectory and the target counterfactual reasoning trajectory, determine whether the target reasoning trajectory satisfies the reasoning termination condition.

[0010] One feasible implementation, wherein determining whether the target inference trajectory satisfies the inference termination condition based on the target inference trajectory and the target counterfactual inference trajectory, includes: The target reasoning trajectory is compared with the target counterfactual reasoning trajectory to obtain the target difference result; Based on the target difference results, determine whether the target reasoning trajectory satisfies the reasoning termination condition.

[0011] Secondly, embodiments of this application provide a reasoning apparatus based on a counterfactual termination judgment, comprising: The trajectory acquisition module is used to acquire the reasoning trajectory of the user's question; The counterfactual trajectory generation module is used to generate a counterfactual inference trajectory based on the inference trajectory, wherein the counterfactual inference trajectory is a trajectory obtained by re-inferring after deleting at least one key piece of information from the key information set on which the inference trajectory is based; The trajectory comparison module is used to compare the reasoning trajectory with the counterfactual reasoning trajectory to obtain the difference results; The inference termination determination module is used to determine whether the inference trajectory meets the inference termination condition based on the difference results.

[0012] In one feasible implementation, the inference termination determination module is specifically used for: If the difference result is greater than or equal to a preset threshold, the inference trajectory is determined to satisfy the inference termination condition; If the difference result is less than the preset threshold, it is determined that the inference trajectory does not meet the inference termination condition.

[0013] Thirdly, embodiments of this application provide an electronic device, the device including: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store a program, the program including instructions that, when executed by the processor, cause the processor to perform any of the implementation steps of the above-described reasoning method based on counterfactual termination judgment.

[0014] Fourthly, embodiments of this application provide a computer-readable storage medium for storing a computer program, which, when executed by a terminal device, implements any of the implementation steps of the above-described reasoning method based on counterfactual termination judgment.

[0015] As can be seen from the above technical solutions, the embodiments of this application have the following advantages: As can be seen from the above technical solution, the reasoning method and related products based on counterfactual termination judgment provided in this application are applied to large language models. First, the reasoning trajectory of the user's question is obtained, and based on this reasoning trajectory, a counterfactual reasoning trajectory is generated. The counterfactual reasoning trajectory is obtained by re-reasoning after deleting at least one key piece of information from the key information set upon which the reasoning trajectory is based. Then, the reasoning trajectory and the counterfactual reasoning trajectory are compared to obtain the difference results. Finally, based on the difference results, it is determined whether the reasoning trajectory meets the reasoning termination condition.

[0016] As can be seen, this scheme constructs a counterfactual reasoning trajectory and compares it with the original reasoning trajectory, using the difference as a quantitative basis for information sufficiency. Specifically, by removing at least one key piece of information from the key information set upon which the reasoning trajectory is based and then re-reasoning, a counterfactual reasoning trajectory is obtained. This counterfactual reasoning trajectory is then compared with the original reasoning trajectory. Based on the difference obtained, it accurately determines whether the information currently held by the large language model is sufficient to support a reliable conclusion, thereby determining whether the reasoning trajectory meets the reasoning termination condition. This effectively avoids the problems of wasted computational power due to the inability to determine information sufficiency and the premature termination of the inference due to insufficient key information, as seen in existing technologies. This improves the accuracy and computational resource utilization efficiency of the large language model in reasoning tasks. Attached Figure Description

[0017] Figure 1A flowchart illustrating a reasoning method based on a counterfactual termination judgment provided in an embodiment of this application; Figure 2 A flowchart illustrating the overall framework of a reasoning method based on a counterfactual termination judgment, provided for embodiments of this application; Figure 3 This is a schematic diagram of the structure of a reasoning device based on a counterfactual termination judgment, provided in an embodiment of this application. Detailed Implementation

[0018] As mentioned earlier, current large language models mainly employ fixed computational processes, dynamic termination based on confidence thresholds, or retrieval-enhanced generation when handling complex reasoning tasks. However, fixed computational processes use the same number of reasoning steps regardless of the problem's difficulty, dynamic termination based on confidence thresholds depends on the confidence score to determine whether to stop, and retrieval enhancement invokes external knowledge bases when information is insufficient.

[0019] Therefore, in practical applications, large language models cannot accurately assess whether the information they have already acquired can support a reliable conclusion. This leads to redundant long-chain reasoning for simple problems, wasting computing power. For complex problems, large language models often terminate hastily before acquiring key information, outputting incorrect answers.

[0020] To address the aforementioned issues, this application provides a reasoning method and related products based on counterfactual termination judgments, applied to large language models. First, the reasoning trajectory of the user's question is obtained, and based on this trajectory, a counterfactual reasoning trajectory is generated. This counterfactual reasoning trajectory is obtained by re-reasoning after deleting at least one key piece of information from the key information set upon which the original reasoning trajectory is based. Then, the original reasoning trajectory and the counterfactual reasoning trajectory are compared to obtain the difference results. Finally, based on the difference results, it is determined whether the reasoning trajectory meets the reasoning termination condition.

[0021] As can be seen, this scheme constructs a counterfactual reasoning trajectory and compares it with the original reasoning trajectory, using the difference as a quantitative basis for information sufficiency. Specifically, by removing at least one key piece of information from the key information set upon which the reasoning trajectory is based and then re-reasoning, a counterfactual reasoning trajectory is obtained. This counterfactual reasoning trajectory is then compared with the original reasoning trajectory. Based on the difference obtained, it accurately determines whether the information currently held by the large language model is sufficient to support a reliable conclusion, thereby determining whether the reasoning trajectory meets the reasoning termination condition. This effectively avoids the problems of wasted computational power due to the inability to determine information sufficiency and the premature termination of the inference due to insufficient key information, as seen in existing technologies. This improves the accuracy and computational resource utilization efficiency of the large language model in reasoning tasks.

[0022] It should be noted that the embodiments of this application are not limited to the executing entity of the reasoning method based on the counterfactual termination judgment. For example, the reasoning method based on the counterfactual termination judgment of this application can be applied to information processing devices such as servers or terminal devices, and correspondingly, the large language model can be mounted on the information processing device. The server can be a standalone server, a cluster server, or a cloud server. The terminal device can be an electronic device such as a smartphone, computer, personal digital assistant (PDA), or tablet computer.

[0023] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0024] Figure 1 A flowchart illustrating a reasoning method based on a counterfactual termination judgment, provided as an embodiment of this application. (Combined with...) Figure 1 As shown, the reasoning method based on counterfactual termination judgment provided in this application uses a large language model deployed on the corresponding device as the execution subject to describe the specific implementation of the scheme. This reasoning method based on counterfactual termination judgment may include the following steps S101-S104.

[0025] S101: Obtain the reasoning trajectory of the user's question.

[0026] In this embodiment, in response to a user question, the large language model performs reasoning to generate a reasoning trajectory corresponding to that user question. The reasoning trajectory includes intermediate thought steps, intermediate conclusions, and the output result generated by the large language model during the reasoning process. Specifically, the reasoning trajectory can be represented in natural language text form, such as the complete reasoning path generated by the large language model during the execution of the thought chain. Alternatively, it can be represented in the form of a structured data sequence to record the reasoning nodes traversed from receiving the user question to the output result and the corresponding information states.

[0027] It should be noted that the inference trajectory of the user question obtained in the embodiments of this application can be the inference trajectory generated after calling the large language model to perform real-time inference on the user question, or it can be the trajectory that has been pre-inferred directly from the cache or context. This application does not make any specific limitation on this.

[0028] S102: Based on the reasoning trajectory, generate a counterfactual reasoning trajectory, wherein the counterfactual reasoning trajectory is the trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set on which the reasoning trajectory is based.

[0029] In this embodiment, a counterfactual reasoning trajectory is generated based on the reasoning trajectory. This counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set upon which the reasoning trajectory is based. The key information set includes, but is not limited to, factual information contained in the user input, information retrieved from external knowledge sources, and intermediate conclusions generated during the reasoning process.

[0030] The counterfactual reasoning trajectory in this application simulates a scenario where the reasoning conclusion of a large language model would change if a certain key information were missing. This allows for a quantitative assessment of the difference between the original reasoning trajectory and the counterfactual reasoning trajectory, thus determining the importance of the deleted key information to the original reasoning trajectory.

[0031] It should be noted that removing at least one key piece of information from the key information set can be done randomly or based on preset rules. Furthermore, when reasoning is performed again after removing at least one key piece of information, the other parameters and configurations of the large language model remain unchanged, so that the differences obtained by subsequent comparisons are solely due to the lack of key information.

[0032] S103: Compare the reasoning trajectory with the counterfactual reasoning trajectory to obtain the difference results.

[0033] In this embodiment of the application, the reasoning trajectory is compared with the counterfactual reasoning trajectory. Specifically, the logical consistency of the intermediate reasoning steps and the final output conclusion of each trajectory can be compared to obtain the difference results.

[0034] The difference result in this application embodiment can be a quantifiable index used to characterize the degree of influence of the deleted key information on the original inference trajectory. Specifically, the larger the value of the difference result, the more important the deleted key information is, that is, the higher the dependence of the original inference trajectory on the key information; conversely, the smaller the value of the difference result, the weaker the contribution of the deleted key information to the original inference trajectory, or even the redundant information.

[0035] In the embodiments of this application, the difference results can be represented in the form of binary values ​​and rank values. For example, the binary values ​​can be "consistent" or "inconsistent", and the rank values ​​can be "no difference", "slight difference" or "significant difference". This application does not limit this.

[0036] S104: Based on the difference results, determine whether the reasoning trajectory meets the reasoning termination condition.

[0037] In this embodiment, based on the difference results, it is determined whether the inference trajectory meets the inference termination condition. If the difference result is greater than or equal to a preset threshold, it indicates that the key information deleted from the inference trajectory has a significant impact on the final output, meaning that the key information is indispensable in the current inference. At this point, it can be concluded that the large language model has acquired sufficient key information to support the current output, and the information sufficiency requirement is met. Therefore, the inference trajectory is determined to meet the inference termination condition. In this case, the output corresponding to the inference trajectory is output as the final answer to the user's question, and the inference process ends.

[0038] Conversely, if the difference is less than a preset threshold, it indicates that deleting key information has a negligible contribution to the final output, or even constitutes redundant information. In this case, it can be determined that the set of key information relied upon by the current inference does not contain sufficient key information, or that there is a high degree of repetition among the information, making it impossible to ensure the reliability of the output. Therefore, it is determined that the inference trajectory does not meet the inference termination condition. In this situation, the embodiments of this application will not directly output the output result corresponding to the inference trajectory, but will trigger a subsequent dynamic adjustment mechanism.

[0039] Specifically, firstly, derivative questions are generated based on the user's question, and then the parameters of the large language model are temporarily updated based on these derivative questions. The updated large language model is then used to re-infer the user's question to obtain the target inference trajectory. Thus, by updating the parameters of the large language model through derivative questions, it is equivalent to performing on-the-spot learning in response to the user's question, thereby overcoming the limitations of traditional models with fixed parameters and their inability to adapt to out-of-distribution difficult problems.

[0040] Based on this, in the same manner as step S102 above, a target counterfactual reasoning trajectory is generated based on the target reasoning trajectory. Specifically, the target counterfactual reasoning trajectory is the trajectory obtained by re-reasoning after deleting at least one key piece of target information from the target key information set upon which the target reasoning trajectory is based. Finally, based on the target reasoning trajectory and the target counterfactual reasoning trajectory, a target difference result is obtained, and it is determined whether the target reasoning trajectory meets the reasoning termination condition based on the target difference result. If it does, the output result corresponding to the target reasoning trajectory is output as the final answer; if it does not, the above dynamic adjustment and counterfactual termination judgment process continues iteratively until the reasoning termination condition is met.

[0041] Furthermore, in the embodiments of this application, the large language model is allowed to make multiple trial virtual submissions during the reasoning process, and after each submission, the reasoning trajectory is compared with counterfactual facts, i.e., a counterfactual reasoning trajectory is generated and the difference results are calculated, in order to determine whether the reasoning termination condition is met.

[0042] Based on the relevant content of steps S101-S104 above, the reasoning method and related products based on counterfactual termination judgment provided in this application, applied to large language models, firstly, obtain the reasoning trajectory of the user's question, and based on this reasoning trajectory, generate a counterfactual reasoning trajectory. The counterfactual reasoning trajectory is obtained by re-reasoning after deleting at least one key piece of information from the key information set upon which the reasoning trajectory is based. Subsequently, the reasoning trajectory and the counterfactual reasoning trajectory are compared to obtain the difference result. Finally, based on the difference result, it is determined whether the reasoning trajectory meets the reasoning termination condition. It can be seen that this solution constructs a counterfactual reasoning trajectory and compares it with the original reasoning trajectory, using the difference result as a quantitative basis for information sufficiency. Specifically, by deleting at least one key piece of information from the key information set upon which the reasoning trajectory is based and re-reasoning, a counterfactual reasoning trajectory is obtained. This counterfactual reasoning trajectory is then compared with the original reasoning trajectory. Based on the obtained difference result, it is accurately determined whether the information currently held by the large language model is sufficient to support a reliable conclusion, thereby determining whether the reasoning trajectory meets the reasoning termination condition. This effectively avoids the problems of wasted computing power due to the inability to judge the sufficiency of information and the output of incorrect answers due to hasty termination when key information is insufficient, which are problems found in existing technologies. This improves the accuracy and computing resource utilization efficiency of large language models in reasoning tasks.

[0043] Furthermore, Figure 2 The present application provides an overall framework flowchart of a reasoning method based on counterfactual termination judgment, and illustrates it with a specific example. First, the large language model receives user questions, such as "What disease does the patient have?", and performs initial reasoning analysis based on these questions to obtain a reasoning trajectory, such as a preliminary diagnosis A.

[0044] Subsequently, a termination decision mechanism is triggered. A counterfactual scenario (i.e., the counterfactual reasoning trajectory in the above embodiment) is generated based on the current reasoning trajectory. Specifically, at least one key piece of information is removed from the set of key information on which the current reasoning is based, such as deleting the patient's most recent key blood test result. The reasoning is then re-derived based on the removed key information to obtain the counterfactual reasoning trajectory.

[0045] Next, the original reasoning trajectory is compared with the counterfactual reasoning trajectory. If the initial diagnosis A still holds despite the missing key information, it indicates that the current reasoning may be too hasty or rely on incorrect prior knowledge, i.e., the current information is insufficient. In this case, the judgment is insufficient information, and a termination reason in natural language can be optionally generated, such as "the current diagnosis does not sufficiently rely on core blood test indicators." This further triggers a single-sample real-time fine-tuning mechanism during testing. Using the current user question as a seed, the large language model synthesizes a set of semantically similar derived variant questions and their pseudo-labels, for example, generating five similar synthetic cases and their derivation processes as temporary training samples. Then, a parameter-efficient fine-tuning technique (e.g., LoRA) is used to quickly update the gradient of the large language model's attention layer (taking approximately 0.5 seconds) to obtain an enhanced temporary model (i.e., the updated large language model in the above embodiment). It should be noted that this temporary model is only used to answer the current user question.

[0046] Finally, the temporary model is used to reanalyze and reason about the user's problem. During this re-reasoning process, the temporary model may realize the need to supplement its analysis with the latest medical literature, thus performing a supplementary information retrieval operation to obtain new literature evidence and derive a revised diagnosis B based on this new information. This revised result serves as the target reasoning trajectory.

[0047] Then, the termination decision mechanism is triggered again. A target counterfactual reasoning trajectory is generated based on the target reasoning trajectory, for example, after deleting newly retrieved literature evidence and re-reasoning. Comparing the target reasoning trajectory with the counterfactual reasoning trajectory reveals that diagnosis B cannot be derived without the literature evidence, indicating that the current information is sufficient. The decision result is "sufficient information," and a reason for termination of reasoning is generated, such as "diagnosis B strongly depends on unique literature evidence and excludes other possibilities." At this point, the final answer (diagnosis B) is output, the temporary model is discarded, the initial state of the large language model is restored, and the system awaits the next request.

[0048] Through the above closed-loop process, the embodiments of this application realize a complete adaptive reasoning process from initial reasoning, counterfactual termination judgment, dynamic fine-tuning, and re-reasoning to the final output, effectively solving the problem of the inability to determine the sufficiency of information in the prior art.

[0049] Therefore, this application achieves dynamic allocation of reasoning computing resources through a counterfactual judgment mechanism, terminates reasoning in a timely manner when information is sufficient, and triggers subsequent adjustments when information is insufficient, thus avoiding redundant overhead or premature termination errors caused by fixed processes. Experiments show that while maintaining high accuracy, the average token consumption is reduced by more than 20%.

[0050] Furthermore, by employing a real-time single-sample fine-tuning mechanism during testing, derivative questions are generated based on the user's question, and temporary parameter updates are performed, enhancing the adaptability of the large language model to out-of-distribution difficult problems. Simultaneously, the entire process relies on the large language model's own counterfactual reasoning and generation capabilities, requiring no external supervision signals, thus achieving unsupervised autonomous adaptation during the inference phase.

[0051] Furthermore, Figure 3 This is a schematic diagram of the structure of a reasoning device based on a counterfactual termination judgment, provided as an embodiment of this application. (Combined with...) Figure 3 As shown, the inference device 300 based on counterfactual termination judgment provided in this application embodiment may include: The trajectory acquisition module 301 is used to acquire the reasoning trajectory of the user's question. The counterfactual trajectory generation module 302 is used to generate a counterfactual reasoning trajectory based on the reasoning trajectory, wherein the counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set on which the reasoning trajectory is based; The trajectory comparison module 303 is used to compare the reasoning trajectory with the counterfactual reasoning trajectory to obtain the difference result; The inference termination determination module 304 is used to determine whether the inference trajectory meets the inference termination condition based on the difference result.

[0052] Optionally, the inference termination determination module 304 is specifically used for: If the difference result is greater than or equal to a preset threshold, the inference trajectory is determined to satisfy the inference termination condition; If the difference result is less than the preset threshold, it is determined that the inference trajectory does not meet the inference termination condition.

[0053] Optionally, after determining that the reasoning trajectory satisfies the reasoning termination condition, the reasoning device 300 based on the counterfactual termination decision may include: The result output module is used to output the output results corresponding to the inference trajectory.

[0054] Optionally, after determining that the reasoning trajectory satisfies the reasoning termination condition, the reasoning device 300 based on the counterfactual termination decision may include: A derivative question generation module is used to generate derivative questions based on the user question; The model update module is used to temporarily update the parameters of the large language model based on the derived problem, so as to obtain the updated large language model. The target trajectory generation module is used to re-infer the user question based on the updated large language model to obtain the target inference trajectory.

[0055] Optionally, the reasoning device 300 based on counterfactual termination judgment may include: The target trajectory generation module is used to generate a target counterfactual inference trajectory based on the target inference trajectory, wherein the target counterfactual inference trajectory is a trajectory obtained by re-inferring after deleting at least one key piece of target information from the target key information set on which the target inference trajectory is based; The reasoning condition determination module is used to determine whether the target reasoning trajectory satisfies the reasoning termination condition based on the target reasoning trajectory and the target counterfactual reasoning trajectory.

[0056] Optionally, the inference condition determination module is specifically used for: The target reasoning trajectory is compared with the target counterfactual reasoning trajectory to obtain the target difference result; Based on the target difference results, determine whether the target reasoning trajectory satisfies the reasoning termination condition.

[0057] Furthermore, embodiments of this application also provide an electronic device, including: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store one or more programs, the one or more programs including instructions that, when executed by the processor, cause the processor to perform any of the implementation steps of the above-described reasoning method based on counterfactual termination judgment.

[0058] Furthermore, embodiments of this application also provide a computer-readable storage medium for storing a computer program, which, when executed by a terminal device, implements any of the implementation steps of the above-described reasoning method based on counterfactual termination judgment.

[0059] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a media gateway, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on describing the differences from other embodiments. The same or similar parts between the various embodiments can be referred to mutually.

[0060] Since the system disclosed in the embodiments corresponds to the method disclosed in the embodiments, the description and comparison are simple, and relevant parts can be referred to in the method section.

[0061] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0062] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A reasoning method based on counterfactual termination judgment, characterized in that, Applied to large language models, the method includes: Obtain the reasoning trajectory of the user's question; Based on the reasoning trajectory, a counterfactual reasoning trajectory is generated, wherein the counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of information from the key information set on which the reasoning trajectory is based; The inference trajectory is compared with the counterfactual inference trajectory to obtain the difference results; Based on the difference results, determine whether the reasoning trajectory satisfies the reasoning termination condition.

2. The method according to claim 1, characterized in that, Determining whether the inference trajectory satisfies the inference termination condition based on the difference results includes: If the difference result is greater than or equal to a preset threshold, the inference trajectory is determined to satisfy the inference termination condition; If the difference result is less than the preset threshold, it is determined that the inference trajectory does not meet the inference termination condition.

3. The method according to claim 2, characterized in that, After determining that the inference trajectory satisfies the inference termination condition, the method further includes: Output the results corresponding to the inference trajectory.

4. The method according to claim 2, characterized in that, After determining that the inference trajectory does not satisfy the inference termination condition, the method further includes: Based on the user's question, generate derivative questions; Based on the aforementioned derivative problem, the large language model is temporarily updated to obtain the updated large language model. The user question is re-reasoned based on the updated large language model to obtain the target reasoning trajectory.

5. The method according to claim 4, characterized in that, The method further includes: Based on the target reasoning trajectory, a target counterfactual reasoning trajectory is generated, wherein the target counterfactual reasoning trajectory is a trajectory obtained by re-reasoning after deleting at least one key piece of target information from the target key information set on which the target reasoning trajectory is based; Based on the target reasoning trajectory and the target counterfactual reasoning trajectory, determine whether the target reasoning trajectory satisfies the reasoning termination condition.

6. The method according to claim 5, characterized in that, The step of determining whether the target inference trajectory satisfies the inference termination condition based on the target inference trajectory and the target counterfactual inference trajectory includes: The target reasoning trajectory is compared with the target counterfactual reasoning trajectory to obtain the target difference result; Based on the target difference results, determine whether the target reasoning trajectory satisfies the reasoning termination condition.

7. A reasoning device based on counterfactual termination judgment, characterized in that, include: The trajectory acquisition module is used to acquire the reasoning trajectory of the user's question; The counterfactual trajectory generation module is used to generate a counterfactual inference trajectory based on the inference trajectory, wherein the counterfactual inference trajectory is a trajectory obtained by re-inferring after deleting at least one key piece of information from the key information set on which the inference trajectory is based; The trajectory comparison module is used to compare the reasoning trajectory with the counterfactual reasoning trajectory to obtain the difference results; The inference termination determination module is used to determine whether the inference trajectory meets the inference termination condition based on the difference results.

8. The apparatus according to claim 7, characterized in that, The inference termination determination module is specifically used for: If the difference result is greater than or equal to a preset threshold, the inference trajectory is determined to satisfy the inference termination condition; If the difference result is less than the preset threshold, it is determined that the inference trajectory does not meet the inference termination condition.

9. An electronic device, characterized in that, The device includes: a processor, a memory, and a system bus; The processor and the memory are connected via the system bus; The memory is used to store a program, the program including instructions that, when executed by the processor, cause the processor to perform the steps of the reasoning method based on counterfactual termination judgment as described in any one of claims 1-6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, which, when executed by a terminal device, implements the steps of the reasoning method based on counterfactual termination judgment as described in any one of claims 1-6.