Large language model reasoning enhancement method and system based on multilayer reasoning chain verification
By constructing a multi-layered parallel inference architecture and a cross-validation mechanism, the accuracy and reliability issues of large language models in complex inference tasks are solved, adaptive inference depth adjustment and error correction are achieved, and the interpretability and efficiency of the inference process are improved.
Patent Information
- Application Number
- CN202510979459.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-11-25
AI Technical Summary
Existing large language models suffer from problems such as insufficient reasoning accuracy, error accumulation, weak self-verification ability, and inability to dynamically adjust reasoning depth in complex reasoning tasks.
A multi-layered parallel inference architecture is constructed, which combines a cross-validation mechanism for inference chains and an adaptive inference depth adjustment strategy. Through cross-validation and consistency checks of multiple parallel inference paths, the inference depth is dynamically adjusted to improve the reliability and accuracy of inference results.
It effectively reduced the reasoning error rate, improved the reliability and interpretability of the reasoning results, enhanced the system's adaptability and credibility, and optimized computational efficiency.
Smart Images

Figure CN121009999A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence and natural language processing, in particular to a large language model reasoning enhancement method and system based on multi-layer reasoning chain verification. BACKGROUND
[0002] With the rapid development of large language models (LLMs), they have shown excellent performance in text understanding and generation, but still have significant deficiencies in complex reasoning tasks. Existing reasoning enhancement methods mainly include Chain-of-Thought, tool invocation, and external knowledge retrieval. However, these methods have obvious limitations: first, a single reasoning path is prone to error accumulation, and once a reasoning step deviates, all subsequent steps will be affected; second, the reasoning process lacks effective self-verification mechanisms, making it difficult for the model to identify and correct logical errors in reasoning; third, existing methods cannot dynamically adjust the reasoning depth and strategy when facing reasoning tasks of different complexities. How to improve the accuracy, reliability, and explainability of large language models in complex reasoning tasks is a key problem that needs to be solved in current technology. SUMMARY
[0003] To address the problems of existing reasoning models in reasoning accuracy, error accumulation, and lack of self-verification ability, the present application provides a large language model reasoning enhancement method and system based on multi-layer reasoning chain verification, which constructs a multi-layer parallel reasoning architecture, combines reasoning chain cross-verification mechanisms and adaptive reasoning depth adjustment strategies, and realizes accurate processing of complex reasoning tasks. The present application can generate multiple independent reasoning paths, improve the reliability of reasoning results through mutual verification and consistency checking, dynamically adjust the reasoning depth according to the complexity of the task, effectively reduce the reasoning error rate, and improve the explainability of the reasoning process and the stability of the results.
[0004] The present application provides a large language model reasoning enhancement method based on multi-layer reasoning chain verification, comprising:
[0005] S1, constructing a multi-layer reasoning architecture based on a pre-trained large language model, and establishing a reasoning state space and a reasoning step transition function;
[0006] S2, receiving an input question, generating parallel reasoning chains according to the multi-layer reasoning architecture, and determining the reasoning step sequence and confidence score of the parallel reasoning chains;
[0007] S3, performing consistency score calculation and logical consistency checking according to the parallel reasoning chains, and determining the final answer according to the consistency score and confidence score;
[0008] S4. Calculate the complexity of the input question to adaptively adjust the inference depth, determine the inference process according to the inference depth, and output the complete inference result.
[0009] Further, the step S1 specifically comprises:
[0010] S1.1. Constructing a multi-layer inference architecture based on a pre-trained large language model M, defining an inference depth level L = {L1, L2, …, Lm}, wherein m is the maximum number of inference layers; m}, wherein m is the maximum number of inference layers;
[0011] S1.2. For each inference level L i Design an independent inference path generator G i , each generator can generate k parallel inference chains:
[0012] R i = {r i1 , r i2 , …, r ij , …, r ik}
[0013] Wherein, R i represents the inference chain set of the i-th layer, r ij represents the j-th inference chain of the i-th layer, and k represents the number of parallel inference chains per layer;
[0014] S1.3. Define the inference state space S = {s0, s1, …, s i , …, s n}, wherein s0 is the initial question state, s n is the target answer state, and the intermediate states s i to s n-1 represent the various intermediate step states in the inference process;
[0015] S1.4. Establish the inference step transition function T (s i , a j ) → s i+1 , wherein s i represents the current inference state, a j represents the j-th inference action, and s i+1 represents the next inference state after executing the inference action.
[0016] Further, the step S2 specifically comprises:
[0017] S2.1. Receive the input question Q, initialize the inference state s0 = encode (Q) ; wherein the encode function converts the natural language question into an internal representation that can be processed by the large language model M;
[0018] S2.2, at each reasoning level L i , use the generator G i to generate k reasoning chains in parallel:
[0019] R i = G i (s0, context i )
[0020] where i represents the reasoning level sequence number, context i is the context information of the i-th layer, containing the reasoning result of the previous layer and the reasoning guidance information of the current layer;
[0021] S2.3, for each reasoning chain r ij , calculate the reasoning step sequence:
[0022]
[0023] where i represents the reasoning level sequence number, j represents the sequence number of the reasoning chain in the layer, j∈{1,2,…,k}, represents the t-th reasoning step in the j-th reasoning chain, represents the total number of steps of the j-th reasoning chain;
[0024] S2.4, for each reasoning step , assign a confidence score:
[0025]
[0026] where represents the confidence score of the t-th step in the j-th reasoning chain, confidence scorer represents the confidence evaluation function, context represents the context of the step, and the confidence score ranges from 0 to 1, with a higher value indicating a more reliable reasoning step.
[0027] Further, the step S3 specifically includes:
[0028] S3.1, set the reasoning chain cross-validation function consistency(r x ,r y ), calculate the consistency score between different reasoning chains:
[0029]
[0030] where r x and r y represent two reasoning chains to be compared, and Let represent the reasoning content at step t in the two reasoning chains respectively. The similarity function calculates the semantic similarity between the two reasoning steps. weight(t) represents the importance weight of step t. The higher the consistency score, the more similar the reasoning logic of the two reasoning chains is, and the higher the credibility.
[0031] S3.2 Verify the reasoning results to check the logical consistency of the final result of each reasoning chain and filter out unreasonable reasoning chains:
[0032] valid(r x ) = logical_checker(result(r x ),premises(Q))
[0033] Where, valid(r) x ) represents the inference chain r x The return value is a boolean, result(r) x ) represents the inference chain r x The final reasoning result, premises(Q) represents the premises extracted from the original question Q, and the logical_checker function checks whether the reasoning result conforms to the logical rules and premise constraints;
[0034] S3.3, Set up an inference result fusion algorithm to calculate the final answer based on the confidence score and consistency score:
[0035] final_answer=fusion_algorithm({result(r k )},{conf(r x )},{consistency score})
[0036] Among them, {result(r x )} represents the result set of all inference chains, {conf(r x )} represents the set of confidence scores for each inference chain, {consistency score} represents the set of consistency scores between inference chains, and fusion_algorithm is a weighted fusion algorithm that determines the most reliable answer as the final output by comprehensively considering confidence and consistency;
[0037] Furthermore, after step S3.3, the method further includes:
[0038] S3.4 Establish a reasoning quality assessment mechanism:
[0039] quality score= a x confidence + b x consistency + g x validity
[0040] where quality = a x confidence + b x consistency + g x validity score is the comprehensive quality score, ranging from [0, 1], confidence is the average confidence of all inference chains, consistency is the maximum consistency score among inference chains, validity is the proportion of inference chains that pass the logical check, a, b, g are weight parameters and a + b + g = 1, when quality score ≥ 0.7, the inference result is considered reliable, otherwise the inference depth needs to be increased or the inference chain needs to be regenerated.
[0041] Further, the step S4 specifically comprises:
[0042] S4.1, analyze the complexity of the input question Q, and calculate the task difficulty index:
[0043] difficulty = complexity_analyzer(Q)
[0044] where difficulty represents the question complexity score, ranging from [0, 1], complexity_analyzer is a complexity analysis function that calculates the comprehensive difficulty according to the language complexity, concept abstraction level, logical level, etc. of the question;
[0045] S4.2, adaptively determine the inference depth according to the complexity of the input question Q:
[0046] optimal_depth = depth_selector(difficulty, resource_constraints)
[0047] where optimal_depth is the optimal inference depth, depth_selector is a depth selection function, resource_constraints represents system resource constraints, and this function dynamically determines the inference depth according to the difficulty and resource conditions;
[0048] S4.3, determine the dynamic inference process control flow according to the inference depth, and output the complete inference result; where the complete inference result includes the final answer, complete inference process, confidence evaluation score, and step-by-step explanation.
[0049] Further, in the step S4.3, the dynamic inference process control flow specifically comprises:
[0050] Initialize the inference level counter i = 1, and perform the following steps in a loop: generate k parallel inference chains at the i-th layer, perform the verification and fusion of the generated inference chains in step S3 to obtain the current layer result, and check whether the convergence condition is met, wherein the convergence condition is that the inference result is stable and the quality score meets the standard, if the convergence condition is met or the optimal depth is reached, stop the inference, otherwise, increase i by 1 and continue the inference of the next layer until a satisfactory inference result is obtained.
[0051] In the complete inference result, the final answer is the most reliable result after multi-layer inference and verification fusion, the complete inference process includes the detailed step sequence of all inference chains, the confidence evaluation score is a quantitative score for providing the reliability of the final answer, and the step-by-step explanation is provided to the user to provide clear inference logic explanation and verification process explanation.
[0052] The application also provides a large language model inference enhancement system based on multi-layer inference chain verification, comprising:
[0053] The construction module is configured to construct a multi-layer inference architecture based on a pre-trained large language model, and establish an inference state space and an inference step transition function;
[0054] The input module is configured to receive an input question, generate parallel inference chains according to the multi-layer inference architecture, and determine the inference step sequence and confidence score of the parallel inference chains;
[0055] The calculation module is configured to perform consistency score calculation and logical consistency check according to the parallel inference chains, and determine a final answer according to the consistency score and the confidence score;
[0056] The output module is configured to adjust the inference depth adaptively according to the complexity of the input question, determine the inference process according to the inference depth, and output a complete inference result.
[0057] The application also provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0058] The application also provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the steps of the above method.
[0059] The application has the following beneficial effects:
[0060] 1. High inference accuracy: the inference error rate is effectively reduced through cross-verification of multiple parallel inference chains.
[0061] 2. Strong error correction capability: the reasoning chain verification mechanism can automatically identify and correct logical errors in the reasoning process, reducing error accumulation and improving the reliability of the reasoning results.
[0062] 3. Strong interpretability: multiple reasoning paths and verification processes are fully preserved, allowing users to clearly understand the reasoning logic of the model and enhancing the credibility and auditability of the system.
[0063] 4. Strong adaptability: dynamically adjust the reasoning depth and resource allocation according to the complexity of the problem, ensuring reasoning quality and optimizing computational efficiency.
[0064] 5. Good scalability: modular architecture design facilitates the integration of new reasoning strategies and verification mechanisms, supporting customization and optimization of reasoning capabilities for specific domains. BRIEF DESCRIPTION OF DRAWINGS
[0065] Figure 1 The method flowchart of an embodiment of the present application.
[0066] Figure 2 The device structure diagram of an embodiment of the present application.
[0067] Figure 3 The internal structure diagram of a computer device of an embodiment of the present application.
[0068] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0069] It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0070] The present application realizes reasoning capability enhancement based on multi-layer reasoning chain verification. The entire method is divided into four main steps: the first step is to build a multi-layer reasoning architecture; the second step is to realize parallel reasoning chain generation; the third step is to design reasoning verification and fusion mechanism; the fourth step is to realize adaptive reasoning depth adjustment. Specifically as follows:
[0071] As shown in Figure 1 The present application provides a large language model reasoning enhancement method based on multi-layer reasoning chain verification, which includes:
[0072] S1, a multi-layer reasoning architecture based on a pre-trained large language model is constructed, and a reasoning state space and a reasoning step transition function are established. Specifically, it includes:
[0073] S1.1, a multi-layer reasoning architecture is constructed based on a pre-trained large language model M, and a reasoning depth level L={L1, L2, …, L m} is defined, where m is the maximum number of reasoning layers;
[0074] S1.2, for each reasoning level L i Design independent reasoning path generator G i Each generator can generate k parallel reasoning chains:
[0075] R i = {r i1 , r i2 , …, r ij , …, r ik}
[0076] where R i represents the reasoning chain set of the i-th layer, r ij represents the j-th reasoning chain of the i-th layer, and k represents the number of parallel reasoning chains per layer;
[0077] S1.3, define the reasoning state space S = {s0, s1, …, s i , …, s n}, where s0 is the initial problem state, s n is the target answer state, and the intermediate state s i to s n-1 represents the state of each intermediate step in the reasoning process;
[0078] S1.4, establish the reasoning step transition function T(s i , a j ) → s i+1 , where s i represents the current reasoning state, a j represents the j-th reasoning action, and s i+1 represents the next reasoning state after executing the reasoning action, which describes the transition relationship between states in the reasoning process.
[0079] S2, receive the input question, generate parallel reasoning chains according to the multi-layer reasoning architecture, and determine the reasoning step sequence and confidence score of the parallel reasoning chains. Specifically, it includes:
[0080] S2.1, receive the input question Q, initialize the reasoning state s0 = encode(Q); where the encode function converts the natural language question into an internal representation that can be processed by the large language model M;
[0081] S2.2, in each reasoning level L i , use the generator G i to generate k parallel reasoning chains:
[0082] R i = G i (s0, context i )
[0083] where i represents the inference level sequence number (corresponding to L i in the context i of the i-th layer, which contains the inference results of the previous layer and the inference guidance information of the current layer;
[0084] S2.3, for each inference chain r ij , calculate the inference step sequence:
[0085]
[0086] where i represents the inference level sequence number, j represents the sequence number of the inference chain in the layer, j∈{1,2,…,k}, represents the t-th inference step in the j-th inference chain, represents the total number of steps of the j-th inference chain;
[0087] S2.4, for each inference step assign a confidence score:
[0088]
[0089] where, represents the confidence score of the t-th step in the j-th inference chain, confidence scorer represents the confidence evaluation function, context represents the context of the step, and the confidence score ranges from 0 to 1, with a higher value indicating that the inference step is more reliable.
[0090] S3, according to the parallel inference chains, perform consistency score calculation, logical consistency check, and determine the final answer according to the consistency score and confidence score. Specifically, it includes:
[0091] S3.1, set the inference chain cross-validation function consistency(r x ,r y ), calculate the consistency score between different inference chains:
[0092]
[0093] where r x and r y represent two inference chains to be compared, and represent the inference content of the t-th step in the two inference chains, respectively, the similarity function calculates the semantic similarity of the two inference steps, and weight(t) represents the importance weight of the t-th step. The higher the consistency score indicates that the inference logic of the two inference chains is more similar and the credibility is higher;
[0094] S3.2, perform reasoning result verification to check the logical consistency of the final result of each reasoning chain, and filter unreasonable reasoning chains:
[0095] valid(r x )=logical_checker(result(r x ),premises(Q))
[0096] Wherein, valid(r x ) represents the logical validity of the reasoning chain r x (returning a boolean value), result(r x ) represents the final reasoning result of the reasoning chain r x , premises(Q) represents the premise condition extracted from the original question Q, the logical_checker function checks whether the reasoning result conforms to the logical rules and premise constraints, and the verification result is used to filter unreasonable reasoning chains.
[0097] S3.3, set the reasoning result fusion algorithm to calculate the final answer based on the confidence score and the consistency score:
[0098] final_answer=fusion_algorithem({result(r k )},{conf(r x )},{consistency score})
[0099] Wherein, {result(r x )} represents the result set of all reasoning chains, {conf(r x )} represents the confidence score set of each reasoning chain, {consistency score} represents the consistency score set between reasoning chains, fusion_algorithm is a weighted fusion algorithm, and the most reliable answer is determined as the final output by comprehensively considering the confidence and consistency.
[0100] S3.4, establish a reasoning quality evaluation mechanism:
[0101] quality score =α×confidence+β×consistency+γ×validity
[0102] Wherein, quality scoreTo comprehensive quality score, range [0, 1], confidence is the average confidence of all inference chains, consistency is the maximum consistency score between inference chains, validity is the proportion of inference chains that pass logical checks, and a, b, and g are weight parameters and a + b + g = 1. When quality score ≥ 0.7, the inference result is considered reliable, otherwise the inference depth needs to be increased or the inference chain needs to be regenerated.
[0103] S4, calculate the complexity of the input question to adaptively adjust the inference depth, determine the inference process according to the inference depth, and output the complete inference result. Specifically, it includes:
[0104] S4.1, analyze the complexity of the input question Q, and calculate the task difficulty index:
[0105] difficulty = complexity_analyzer(Q)
[0106] Where difficulty represents the question complexity score, range [0, 1], and complexity_analyzer is a complexity analysis function that calculates the comprehensive difficulty according to the language complexity, concept abstraction level, logical level, and other factors of the question;
[0107] S4.2, adaptively determine the inference depth according to the complexity of the input question Q:
[0108] optimal_depth = depth_selector(difficulty, resource_constraints
[0109] Where optimal_depth is the optimal inference depth, depth_selector is a depth selection function, and resource_constraints represents system resource constraints. This function dynamically determines the number of inference layers according to the difficulty and resource conditions;
[0110] S4.3, determine the dynamic inference process control flow according to the inference depth. Specifically, it includes:
[0111] First, initialize the inference level counter i = 1, then loop the following steps: generate k parallel inference chains at the i-th layer, perform verification and fusion on the generated inference chains to obtain the current layer result, and check whether the convergence condition is met (i.e. the inference result is stable and the quality score meets the standard), if the convergence condition is met or the optimal depth is reached, stop the inference, otherwise increase i by 1 and continue the next layer inference until a satisfactory inference result is obtained.
[0112] S4.4, output the complete reasoning result, including the following four components:
[0113] First, the final answer, which is the most reliable result after multiple layers of reasoning and verification fusion;
[0114] Second, the complete reasoning process, containing the detailed step sequence of all reasoning chains;
[0115] Third, the confidence assessment, providing a quantitative score of the reliability of the final answer;
[0116] Fourth, step-by-step explanation, providing clear reasoning logic explanation and verification process explanation for users.
[0117] The application adopts the above scheme, and effectively solves the key problems in large language model reasoning by designing a multi-layer parallel reasoning architecture and a cross-validation mechanism. First, the generation of multiple parallel reasoning chains avoids the problem of error accumulation in single-path reasoning, and improves the robustness of the results through diversified reasoning paths; second, the reasoning chain cross-validation mechanism can automatically identify and correct logical errors in the reasoning process, improving the accuracy of reasoning; third, the fusion algorithm based on confidence and consistency ensures the reliability of the final result; fourth, the adaptive reasoning depth adjustment mechanism dynamically allocates computing resources according to the complexity of the problem, ensuring the quality of reasoning and improving efficiency. This architecture not only significantly improves the accuracy of complex reasoning tasks (compared to single-chain reasoning methods), but also enhances the explainability of the reasoning process (compared to black-box reasoning methods), while optimizing the allocation of reasoning resources.
[0118] As shown in Figure 2 The application also provides a large language model reasoning enhancement system based on multi-layer reasoning chain verification, comprising:
[0119] The construction module 1 is used to construct a multi-layer reasoning architecture based on a pre-trained large language model, and to establish a reasoning state space and a reasoning step transition function;
[0120] The input module 2 is used to receive an input question, generate parallel reasoning chains according to the multi-layer reasoning architecture, and determine the reasoning step sequence and confidence score of the parallel reasoning chains;
[0121] The calculation module 3 is used to perform consistency score calculation and logical consistency check according to the parallel reasoning chains, and to determine the final answer according to the consistency score and confidence score;
[0122] The output module 4 is used to adjust the reasoning depth adaptively according to the complexity of the input question, determine the reasoning process according to the reasoning depth, and output the complete reasoning result.
[0123] In one embodiment, the construction module 1 specifically comprises:
[0124] a reasoning architecture construction unit for constructing a multi-layer reasoning architecture based on a pre-trained large language model M, defining a reasoning depth level L = {L1, L2, …, Lm}, where m is the maximum number of reasoning layers; m}, where m is the maximum number of reasoning layers;
[0125] a generator design unit for designing a generator G for each reasoning level L i independently; i Each generator can generate k parallel reasoning chains:
[0126] R i = {r i1 , r i2 , …, r ij , …, r ik}
[0127] where R i represents the set of reasoning chains of the i-th layer, r ij represents the j-th reasoning chain of the i-th layer, and k represents the number of parallel reasoning chains per layer;
[0128] a state space definition unit for defining a reasoning state space S = {s0, s1, …, s i , …, s n}, where s0 is the initial problem state, s n is the target solution state, and the intermediate states s i to s n-1 represent the various intermediate step states in the reasoning process;
[0129] a reasoning step establishment unit for establishing a reasoning step transition function T (s i , a j ) → s i+1 , where s i represents the current reasoning state, a j represents the j-th reasoning action, and s i+1 represents the next reasoning state after executing the reasoning action.
[0130] In one embodiment, the input module 2 specifically includes:
[0131] an input question receiving unit for receiving an input question Q and initializing the reasoning state s0 = encode (Q) ; wherein the encode function converts the natural language question into an internal representation that can be processed by the large language model M;
[0132] a reasoning chain generation unit for generating k reasoning chains in parallel in each reasoning level L i using the generator G i .
[0133] R i =G i (s0,context i )
[0134] where i represents the reasoning level sequence number, context i is the context information of the i-th layer, containing the reasoning result of the previous layer and the reasoning guidance information of the current layer;
[0135] a reasoning step calculation unit, configured to calculate a reasoning step sequence for each reasoning chain r ij .
[0136]
[0137] where i represents the reasoning level sequence number, j represents the sequence number of the reasoning chain in the layer, j∈{1,2,…,k}, represents the t-th reasoning step in the j-th reasoning chain, represents the total number of steps of the j-th reasoning chain;
[0138] a confidence score calculation unit, configured to assign a confidence score to each reasoning step .
[0139]
[0140] where, represents the confidence score of the t-th step in the j-th reasoning chain, confidence scorer represents a confidence evaluation function, context represents the context of the step, and the confidence score ranges from 0 to 1, with a higher value indicating that the reasoning step is more reliable.
[0141] In one embodiment, the calculation module 3 specifically comprises:
[0142] a consistency score calculation unit, configured to set a reasoning chain cross-validation function consistency(r x ,r y ), and calculate the consistency score between different reasoning chains:
[0143]
[0144] where r x and r y represent two reasoning chains to be compared, and Let represent the reasoning content at step t in the two reasoning chains respectively. The similarity function calculates the semantic similarity between the two reasoning steps. weight(t) represents the importance weight of step t. The higher the consistency score, the more similar the reasoning logic of the two reasoning chains is, and the higher the credibility.
[0145] The consistency check unit is used to verify the inference results, performing a logical consistency check on the final result of each inference chain and filtering out unreasonable inference chains.
[0146] valid(r x ) = logical_checker(result(r x ),premises(Q))
[0147] Where, valid(r) x ) represents the inference chain r x The return value is a boolean, result(r) x ) represents the inference chain r x The final reasoning result, premises(Q) represents the premises extracted from the original question Q, and the logical_checker function checks whether the reasoning result conforms to the logical rules and premise constraints;
[0148] The final answer calculation unit is used to set up an inference result fusion algorithm to calculate the final answer based on the confidence score and consistency score.
[0149] final_answer=fusion_algorithm({result(r k )},{conf(r x )},{consistency score})
[0150] Among them, {result(r x )} represents the set of results for all inference chains, (conf(r x )} represents the set of confidence scores for each inference chain, {consistency score} represents the set of consistency scores between inference chains, and fusion_algorithm is a weighted fusion algorithm that determines the most reliable answer as the final output by comprehensively considering confidence and consistency;
[0151] In one embodiment, the computing module 3 further includes:
[0152] A quality assessment unit is used to establish a reasoning quality assessment mechanism.
[0153] quality score= a x confidence + b x consistency + g x validity
[0154] where quality = a x confidence + b x consistency + g x validity score is the overall quality score, ranging from [0, 1], confidence is the average confidence of all inference chains, consistency is the maximum consistency score among inference chains, validity is the proportion of inference chains that pass logical checks, a, b, g are weight parameters and a + b + g = 1, when quality score ≥ 0.7, the inference result is considered reliable, otherwise the inference depth needs to be increased or the inference chains need to be regenerated.
[0155] In one embodiment, the output module 4 specifically includes:
[0156] a complexity calculation unit for analyzing the complexity of the input question Q and calculating a task difficulty indicator:
[0157] difficulty = complexity_analyzer(Q)
[0158] where difficulty represents the question complexity score, ranging from [0, 1], and complexity_analyzer is a complexity analysis function that calculates the overall difficulty based on factors such as language complexity, concept abstraction level, and logical hierarchy;
[0159] an inference depth determination unit for adaptively determining the inference depth based on the complexity of the input question Q:
[0160] optimal_depth = depth_selector(difficulty, resource_constraints)
[0161] where optimal_depth is the optimal inference depth, depth_selector is a depth selection function, and resource_constraints represents system resource constraints. This function dynamically determines the number of inference layers based on difficulty and resource conditions;
[0162] an inference result output unit for dynamically controlling the inference process flow based on the determined inference depth and outputting the complete inference result; where the complete inference result includes the final answer, complete inference process, confidence evaluation score, and step-by-step explanation.
[0163] In one embodiment, the inference result output unit, the dynamic inference process control flow specifically includes:
[0164] Initialize the inference level counter i = 1, and perform the following steps in a loop: generate k parallel inference chains at the i-th layer, perform the verification and fusion of the generated inference chains in step S3 to obtain the current layer result, and check whether the convergence condition is met, the convergence condition being that the inference result is stable and the quality score meets the standard, if the convergence condition is met or the optimal depth is reached, stop the inference, otherwise, increase i by 1 and continue the inference of the next layer until a satisfactory inference result is obtained.
[0165] In the complete inference result, the final answer is the most reliable result after multi-layer inference and verification fusion, the complete inference process includes the detailed step sequence of all inference chains, the confidence evaluation score is a quantitative score for providing the reliability of the final answer, and the step-by-step explanation is to provide clear inference logic explanation and verification process explanation for the user.
[0166] The above modules and units are used to correspondingly perform each step in the above large language model inference enhancement method based on multi-layer inference chain verification, and the specific implementation manner is described with reference to the above method embodiments, which will not be described here.
[0167] As shown in Figure 3 The present application also provides a computer device, which can be a server, and the internal structure thereof can be as shown in Figure 3 The computer device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store all data required by the process of the large language model inference enhancement method based on multi-layer inference chain verification. The network interface of the computer device is used to communicate with the external terminal through the network connection. The computer program is executed by the processor to implement the large language model inference enhancement method based on multi-layer inference chain verification.
[0168] Those skilled in the art can understand, Figure 3 The structure shown in
[0169] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by the processor to implement any one of the above large language model inference enhancement methods based on multi-layer inference chain verification.
[0170] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, databases, or other media in this application and in examples used herein, unless specifically stated otherwise, can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0171] It should be noted that in this document, the terms "comprising", "including", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, device, article, or method that comprises a list of elements does not only include those elements, but can also include other elements not expressly listed or inherent to such process, device, article, or method. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, device, article, or method that includes the element.
[0172] The above description is only the preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields, based on the content of the present application specification and drawings, is also included in the patent protection scope of the present application.
Claims
1. A method for enhancing reasoning in large language models based on multi-layer reasoning chain verification, characterized in that, include: S1. Construct a multi-layered reasoning architecture based on a pre-trained large-scale language model, and establish the reasoning state space and reasoning step transition function; S2. Receive the input question, generate a parallel inference chain based on the multi-layer inference architecture, and determine the inference step sequence and confidence score of the parallel inference chain; S3. Calculate the consistency score and perform a logical consistency check based on the parallel inference chain, and determine the final answer based on the consistency score and confidence score; S4. Calculate the complexity based on the input problem to adaptively adjust the reasoning depth, determine the reasoning process based on the reasoning depth, and output the complete reasoning result.
2. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 1, characterized in that, Step S1 specifically includes: S1.1 Construct a multi-layered inference architecture based on a pre-trained large-scale language model M, defining the inference depth hierarchy L = {L1, L2, ..., L...} m }, where m is the maximum number of inference layers; S1.2, for each reasoning level L i Design an independent reasoning path generator G i Each generator can produce k parallel inference chains: R i ={r i1 ,r i2 ,…,r ij ,…,r ik} Among them, R i Let r represent the set of reasoning chains at level i. ij Let j represent the j-th inference chain in the i-th layer, and k represent the number of parallel inference chains in each layer; S1.3, Define the inference state space S = {s0, s1, ..., s} i ,…,s n }, where s0 is the initial problem state, s n The target solution state, intermediate state s i to s n-1 Represents the states of each intermediate step in the reasoning process; S1.4, Establish the reasoning step transfer function T(s) i ,a j )→s i+1 , where s i Indicates the current reasoning state, a j Let s represent the j-th reasoning action. i+1 This indicates the next reasoning state after performing a reasoning action.
3. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 2, characterized in that, Step S2 specifically includes: S2.1 Receive the input question Q and initialize the inference state s0 = encode(Q); where the encode function converts the natural language question into an internal representation that can be processed by a large language model M; S2.2, at each reasoning level L i In the middle, using generator G i Generate k inference chains in parallel: R i =G i (s0,context i ) Where i represents the inference level number, context i This is the context information for the i-th layer, which includes the reasoning results from the previous layer and the reasoning guidance information for the current layer. S2.3, For each inference chain r ij Calculate the sequence of reasoning steps: Where i represents the inference level number, j represents the inference chain number in that level, and j∈{1,2,…,k}. This represents the t-th reasoning step in the j-th reasoning chain. This represents the total number of steps in the j-th inference chain; S2.4, for each reasoning step Partial configuration reliability score: in, The confidence score represents the confidence level at step t in the j-th inference chain. scorer represents the confidence evaluation function, context represents the context of this step, and the confidence score ranges from [0,1]. The higher the value, the more reliable the inference step is.
4. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 3, characterized in that, Step S3 specifically includes: S3.1, Set the cross-validation function consistency(r) for the inference chain. x ,r y ), calculate the consistency score between different inference chains: Where, r x and r y This represents two chains of reasoning to be compared. and Let represent the reasoning content at step t in the two reasoning chains respectively. The similarity function calculates the semantic similarity between the two reasoning steps. weight(t) represents the importance weight of step t. The higher the consistency score, the more similar the reasoning logic of the two reasoning chains is, and the higher the credibility. S3.2 Verify the reasoning results to check the logical consistency of the final result of each reasoning chain and filter out unreasonable reasoning chains: valid(r x )=logical_checker(result(r x ),premises(Q)) Where, valid(r) x ) represents the inference chain r x The return value is a boolean, result(r) x ) represents the inference chain r x The final reasoning result, premises(Q) represents the premises extracted from the original question Q, and the logical_checker function checks whether the reasoning result conforms to the logical rules and premise constraints; S3.3, Set up an inference result fusion algorithm to calculate the final answer based on the confidence score and consistency score: final_answer=fusion_algorithm({result(r k )},{conf(r x )},{consistency score }) Among them, {result(r x )} represents the result set of all inference chains, {conf(r x )} represents the set of confidence scores for each inference chain, {consistency score } represents the set of consistency scores between inference chains, and fusion_algorithm is a weighted fusion algorithm that determines the most reliable answer as the final output by comprehensively considering confidence and consistency.
5. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 4, characterized in that, Following step S3.3, the method further includes: S3.4 Establish a reasoning quality assessment mechanism: quality score =α×confidence+β×consistency+γ×validity Among them, quality score The overall quality score ranges from [0,1]. Confidence is the average confidence score across all inference chains, consistency is the maximum consistency score among inference chains, wvlidity is the percentage of inference chains that pass the logic check, and α, β, and γ are weighting parameters where α + β + γ = 1. score A result of ≥0.7 is considered reliable; otherwise, the reasoning depth needs to be increased or the reasoning chain needs to be regenerated.
6. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 4, characterized in that, Step S4 specifically includes: S4.1 Analyze the complexity of the input problem Q and calculate the task difficulty index: difficulty=complexity_analyzer(Q) Where, difficulty represents the problem complexity score, ranging from [0,1], and complexity_analyzer is the complexity analysis function, which calculates the overall difficulty based on factors such as the language complexity, the degree of conceptual abstraction, and the logical level of the problem. S4.2 Adaptively determine the inference depth based on the complexity of the input question Q: optimal_depth=depth_selector(difficulty,resource_constraints) Where, optimal_depth is the optimal inference depth, depth_selector is the depth selection function, and resource_constraints represents the system resource constraints. This function dynamically determines the number of inference layers based on the difficulty and resource situation. S4.3 Determine the dynamic reasoning process control flow based on the reasoning depth, and output the complete reasoning result; wherein, the complete reasoning result includes the final answer, the complete reasoning process, the confidence assessment score, and the step-by-step explanation.
7. The large language model reasoning enhancement method based on multi-layer reasoning chain verification according to claim 6, characterized in that, In step S4.3, the dynamic reasoning process control flow specifically includes: Initialize the inference level counter i = 1, and execute the following steps in a loop: generate k parallel inference chains at the i-th level, verify and merge the generated inference chains in step S3 to obtain the result of the current level, and check whether the convergence condition is met. The convergence condition is that the inference result is stable and the quality score meets the standard. If the convergence condition is met or the optimal depth is reached, stop the inference; otherwise, increment i by 1 and continue the inference of the next level until a satisfactory inference result is obtained. In the complete reasoning result, the final answer is the most reliable result after multi-layer reasoning and verification integration. The complete reasoning process includes a detailed sequence of steps for all reasoning chains. The confidence assessment score provides a quantitative score for the reliability of the final answer. The step-by-step explanation provides users with a clear explanation of the reasoning logic and the verification process.
8. A large language model reasoning enhancement system based on multi-layer reasoning chain verification, characterized in that, include: The building module is used to construct a multi-layered inference architecture based on a pre-trained large-scale language model, and to establish the inference state space and inference step transition function; The input module is used to receive input questions, generate parallel inference chains according to the multi-layer inference architecture, and determine the inference step sequence and confidence score of the parallel inference chains. The calculation module is used to calculate the consistency score and check the logical consistency based on the parallel inference chain, and determine the final answer based on the consistency score and the confidence score. The output module is used to calculate the complexity based on the input problem to adaptively adjust the inference depth, determine the inference process based on the inference depth, and output the complete inference result.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Cited By
Video safety monitoring method and device based on evidence reasoning, and storage medium
CN122454515A