Text reasoning methods, electronic devices and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-26
- Publication Date
- 2026-08-14
AI Technical Summary
[0003]但是,相关技术中忽视了任务的不同复杂程度,在面对简单任务时存在过度思考问题,增加了计算开销;而针对部分复杂场景,存在思考不足的问题,导致推理的准确性下降,难以在推理结果准确性与推理过程简洁性之间实现平衡
Smart Images

Figure CN121581244B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text generation and model reasoning technology, specifically to a text reasoning method, electronic device, and storage medium. Background Technology
[0002] In complex reasoning tasks (such as mathematical problem solving, logical reasoning, and scientific computing), the performance of traditional large language models still has significant limitations. Related technologies mainly use large reasoning models, combined with training strategies such as supervised fine-tuning and reinforcement learning, to enable the models to generate structured reasoning paths, which improves the reasoning ability of complex reasoning tasks to a certain extent.
[0003] However, related technologies neglect the different levels of task complexity. When faced with simple tasks, there is an overthinking problem, which increases computational overhead. For some complex scenarios, there is insufficient thinking, which leads to a decrease in the accuracy of reasoning. It is difficult to achieve a balance between the accuracy of the reasoning result and the simplicity of the reasoning process. Summary of the Invention
[0004] In view of the above problems, the present invention provides a text reasoning method, apparatus, device, medium and program product.
[0005] According to a first aspect of the present invention, a text reasoning method is provided, comprising: in response to receiving a text to be processed, determining a plurality of initial constraint parameters based on a predetermined search strategy, wherein the initial constraint parameters are used to constrain the number of initial steps required for reasoning processing of the text to be processed; inputting the text to be processed into a prompt word template, and outputting a plurality of initial thought chain texts based on the plurality of initial constraint parameters, wherein each initial thought chain text includes a plurality of reasoning paragraphs corresponding to the initial number of steps, and the plurality of reasoning paragraphs included in each initial thought chain text correspond to a set of reasoning results; determining a target thought chain text from the plurality of initial thought chain texts based on the initial number of steps corresponding to each of the plurality of initial thought chain texts and the confidence level of the reasoning results of each of the plurality of initial thought chain texts; and generating a reasoning answer for the text to be processed based on the target thought chain text.
[0006] A second aspect of the present invention provides a text reasoning apparatus, comprising: a parameter determination module, configured to determine a plurality of initial constraint parameters based on a predetermined search strategy in response to receiving a text to be processed, wherein the initial constraint parameters are used to constrain the number of initial steps required for reasoning processing of the text to be processed; an output module, configured to input the text to be processed into a prompt word template and output a plurality of initial thought chain texts based on the plurality of initial constraint parameters, wherein each initial thought chain text includes a plurality of reasoning paragraphs corresponding to the initial number of steps, and the plurality of reasoning paragraphs included in each initial thought chain text correspond to a set of reasoning results; a text determination module, configured to determine a target thought chain text from the plurality of initial thought chain texts based on the initial number of steps corresponding to each of the plurality of initial thought chain texts and the confidence level of the reasoning results of each of the plurality of initial thought chain texts; and a generation module, configured to generate a reasoning answer for the text to be processed based on the target thought chain text.
[0007] A third aspect of the present invention provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0008] A fourth aspect of the present invention also provides a computer-readable storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions, when executed by a processor, implement the steps of the above-described method.
[0009] A fifth aspect of the present invention also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method. Attached Figure Description
[0010] The above-described features, other objects, and advantages of the present invention will become clearer from the following description of embodiments of the invention with reference to the accompanying drawings, in which:
[0011] Figure 1 An application scenario diagram of the text reasoning method and apparatus according to embodiments of the present invention is shown;
[0012] Figure 2 A flowchart of a text reasoning method according to an embodiment of the present invention is shown;
[0013] Figure 3 A flowchart of a target thought chain text update method according to an embodiment of the present invention is shown;
[0014] Figure 4 A structural block diagram of a text reasoning device according to an embodiment of the present invention is shown;
[0015] Figure 5A block diagram of an electronic device suitable for implementing a text reasoning method according to an embodiment of the present invention is shown. Detailed Implementation
[0016] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.
[0017] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0018] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0019] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0020] The following explains the relevant technical terms used in the model inference process.
[0021] Large Language Models (LLMs) refer to deep learning foundational models trained on massive amounts of data and possessing a large number of parameters. They are capable of handling a variety of complex tasks. The core of this approach lies in first performing self-supervised learning on massive amounts of unlabeled text data at the internet level to acquire general language and world knowledge, forming a foundational model. This model can then be fine-tuned based on a small amount of labeled data in a specific domain, or directly adapted to downstream tasks through prompting learning. This significantly reduces the dependence on labeled data and gives it powerful generalization capabilities.
[0022] Chain of Thought (CoT) is a prompting technique that guides large models to break down complex problems into successive intermediate reasoning steps, simulating the human approach to problem-solving step by step. Long Chain-of-Thought (LCoT) is an advanced form of Chain of Thought, supporting the generation of longer and deeper reasoning paths and introducing multi-path exploration and self-correction mechanisms.
[0023] Long thought chain models refer to large-scale language models capable of generating lengthy reasoning processes, simulating the step-by-step thinking process of humans to solve complex problems. While basic thought chain models demonstrate multi-step reasoning processes when answering questions, rather than simply providing the final answer, long thought chain models, compared to basic thought chains, can handle more complex reasoning tasks with more steps, maintaining greater logical coherence. A key characteristic is the use of multi-round self-verification mechanisms.
[0024] In some examples, long thought chain models (i.e., reasoning-oriented large models) are used, combining training strategies such as supervised fine-tuning and reinforcement learning to enable the model to generate structured reasoning paths. The advantage of reasoning-oriented large models lies in improving reasoning accuracy by generating long thought chains, gradually breaking down complex problems, and simulating the human logical thinking process.
[0025] However, this strategy of long thought chains also brings significant technical pain points, namely, overthinking. Specifically, even when faced with simple problems, large reasoning models still generate lengthy reasoning steps, leading to redundant thought chains. Considering that reasoning time and output length have a quadratic function relationship, this significantly increases computational overhead. Furthermore, the lengthy thought chains contain a large number of repetitive or irrelevant statements, making it difficult for users to quickly locate the core reasoning logic. Users need to spend a lot of time filtering key information, severely reducing the interactive experience and the interpretability of the reasoning process, making it difficult for users to quickly grasp the core logic.
[0026] Meanwhile, large reasoning models also face the problem of insufficient deduction. For example, in some scenarios, the model may fail to fully break down the problem due to an overly short thought chain, leading to incorrect results. In other words, large reasoning models struggle to balance accuracy and conciseness: forcibly shortening the reasoning length can easily lead to a decrease in the accuracy of the reasoning results; pursuing high accuracy can lead to overthinking. Clearly, related technologies cannot dynamically adjust the length of the thought chain according to the complexity of the problem. For simple problems, the model may still generate complex thought chains; for complex problems, the preset maximum text length limit may cause reasoning interruptions, further reducing accuracy.
[0027] In view of this, the present invention provides a text reasoning method, an electronic device, and a storage medium. The method includes: in response to receiving a text to be processed, determining a plurality of initial constraint parameters based on a predetermined search strategy, wherein the initial constraint parameters are used to constrain the number of initial steps required for reasoning processing of the text to be processed; inputting the text to be processed into a prompt word template, and outputting a plurality of initial thought chain texts based on the plurality of initial constraint parameters, wherein each initial thought chain text includes a plurality of reasoning paragraphs corresponding to the initial number of steps, and the plurality of reasoning paragraphs included in each initial thought chain text correspond to a set of reasoning results; determining a target thought chain text from the plurality of initial thought chain texts based on the initial number of steps corresponding to each of the plurality of initial thought chain texts and the confidence level of the reasoning results of each of the plurality of initial thought chain texts; and generating a reasoning answer for the text to be processed based on the target thought chain text.
[0028] According to embodiments of the present invention, multiple initial constraint parameters are determined through a predetermined search strategy, and initial thought chain texts corresponding to different numbers of steps are generated. Target thought chains are then selected based on a comprehensive evaluation of the number of steps and confidence level. This overcomes the limitations of existing static constraints, actively optimizing the length of the thought chain (fewer steps) while ensuring reasoning accuracy (high confidence), achieving synergistic optimization of accuracy and conciseness. The selected target thought chain text retains key reasoning logic while eliminating redundant expressions, making the reasoning process clearer and more focused. This improves the traceability of the reasoning answer and user comprehension efficiency, achieving adaptive matching of the most suitable reasoning depth based on the actual complexity of the text to be processed. Simultaneously, it avoids resource waste in simple problems and reasoning interruptions in complex problems, satisfying robustness and application flexibility in different scenarios.
[0029] Figure 1 An application scenario diagram of the text reasoning method and apparatus according to an embodiment of the present invention is shown.
[0030] like Figure 1 As shown, application scenario 100 according to this embodiment may include terminal device 101, server 102, and network 103. Network 103 is used as a medium to provide a communication link between terminal device 101 and server 102. Network 103 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0031] Users can use terminal device 101 to interact with server 102 via network 103 to receive or send messages, etc. Terminal device 101 can be various electronic devices with a display screen and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers, etc.
[0032] Server 102 can be a server that provides text reasoning services and can be used for core computing, data processing and intelligent reasoning tasks.
[0033] Taking a logical reasoning intelligent reasoning system as an example, the terminal device 101 can be the entry point for direct interaction between the user and the intelligent reasoning system. Its main function is to collect user input and display the final result.
[0034] For example, after receiving the information to be processed (such as text, image or video) input by the user through the terminal device 101, it can automatically organize language to generate fluent and accurate reasoning answers based on the understanding and reasoning ability of the reasoning model and the prompt word template, and then organize the generated reasoning answers into a standard format and send them back to the terminal device 101.
[0035] It should be noted that the text reasoning method provided in the embodiments of the present invention can generally be executed by server 102. Correspondingly, the text reasoning device provided in the embodiments of the present invention can generally be located in server 102. The text reasoning method provided in the embodiments of the present invention can also be executed by a server or server cluster that is different from server 102 and capable of communicating with terminal device 101 and / or server 102. Correspondingly, the text reasoning device provided in the embodiments of the present invention can also be located in a server or server cluster that is different from server 102 and capable of communicating with terminal device 101 and / or server 102.
[0036] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0037] Figure 2 A flowchart of a text reasoning method according to an embodiment of the present invention is shown.
[0038] like Figure 2 As shown, the text reasoning method in this embodiment includes operations S210 to S240.
[0039] In operation S210, in response to receiving the text to be processed, multiple initial constraint parameters are determined based on a predetermined search strategy. These initial constraint parameters are used to constrain the number of initial steps required for inference processing of the text to be processed.
[0040] In embodiments of the present invention, the text to be processed can be the original input content input by the user through a terminal device, which requires reasoning analysis by the reasoning model, such as mathematical problems, logical reasoning problems, and complex question-and-answer problems. The predetermined search strategy can be a pre-set parameter search algorithm or strategy used for efficient exploration within the constraint parameter space. For example, within the range of initial constraint parameter values, a patience mechanism can be used to automatically find the optimal constraint parameters and optimal thought chain with the highest accuracy and shortest length. The initial constraint parameters can be hyperparameters controlling the length of the thought chain text, limiting the maximum number of steps in the reasoning process. The initial number of steps can be the number of reasoning steps allowed in the initial reasoning stage of the thought chain text, which can represent the number of steps in the reasoning thought process.
[0041] For example, after receiving a scientific reasoning question from a user, the range of values for the constraint parameters can be determined. The peak value within this range represents the average number of steps required to generate the thought chain text without any constraints during the reasoning process. It can be understood that the peak and trough values within the range can be obtained through prior experimental statistics; the smaller the value of the constraint parameter, the stricter the constraint, and the shorter the resulting thought chain text.
[0042] In operation S220, the text to be processed is input into the prompt word template, and based on multiple initial constraint parameters, multiple initial thought chain texts are output. Each initial thought chain text includes multiple reasoning paragraphs corresponding to the initial step number, and each initial thought chain text includes multiple reasoning paragraphs corresponding to a set of reasoning results.
[0043] In embodiments of the present invention, the prompt word template can be a predefined structured text framework containing placeholders for inserting constraint parameters and text to be processed, guiding the inference model to generate standardized thought chain text. The initial thought chain text can be generated by the inference model based on different initial constraint parameters, resulting in multiple versions of the inference process, each containing inference paragraphs with varying numbers of steps. Each inference paragraph can be a basic logical unit in the thought chain, representing a complete inference step, such as "first identify the problem type, then extract key data, and finally apply the formula to calculate." The inference result can be the final conclusion of each thought chain text, forming a complete causal logical chain with the corresponding inference process.
[0044] For example, after determining multiple initial constraint parameters corresponding to the text to be processed, the text to be processed can be inserted into the "Question Input" module of the prompt word template, and multiple initial constraint parameters can be inserted into the "Constraint Conditions" of the prompt word template respectively to obtain multiple updated prompt word templates. Then, the prompt word templates are input into the inference model to output multiple initial thought chain texts.
[0045] In operation S230, the target thought chain text is determined from the multiple initial thought chain texts based on the number of initial steps corresponding to each of the multiple initial thought chain texts and the confidence level of the reasoning results of each of the multiple initial thought chain texts.
[0046] In operation S240, inference answers are generated for the text to be processed based on the target thought chain text.
[0047] In embodiments of the present invention, the initial number of steps can be the number of reasoning steps contained in each thought chain text, reflecting the level of detail and complexity of the thought chain. The confidence level of the reasoning result can be a probabilistic assessment of the correctness of the thought chain reasoning result, which can be calculated based on indicators such as answer consistency and logical coherence. The target thought chain text can be the optimal thought chain version selected through comprehensive evaluation, achieving the best balance between the simplicity of the reasoning process and the accuracy of the reasoning result. The reasoning answer can be the final output result obtained after multiple rounds of selection and optimization.
[0048] For example, using multiple initial thought chain texts obtained from different rounds of search, the thought chain text with the highest confidence in the reasoning result among the multiple initial thought chain texts is taken as the candidate thought chain text. Based on this, multiple candidate thought chain texts can be obtained for multiple rounds of search in the iterative search process. Then, based on preset conditions, multiple candidate thought chain texts are filtered to obtain the filtered target thought chain text.
[0049] For example, a Pareto front can be found based on the initial number of steps and confidence level. By excluding dominated solutions (i.e., solutions with more steps but lower confidence levels), the initial thought chain text with higher simplicity or accuracy can be selected from the front solutions as the target thought chain text, depending on the application requirements.
[0050] According to embodiments of the present invention, multiple initial constraint parameters are determined through a predetermined search strategy, and initial thought chain texts corresponding to different numbers of steps are generated. Target thought chains are then selected based on a comprehensive evaluation of the number of steps and confidence level. This overcomes the limitations of existing static constraints, actively optimizing the length of the thought chain (fewer steps) while ensuring reasoning accuracy (high confidence), achieving synergistic optimization of accuracy and conciseness. The selected target thought chain text retains key reasoning logic while eliminating redundant expressions, making the reasoning process clearer and more focused. This improves the traceability of the reasoning answer and user comprehension efficiency, achieving adaptive matching of the most suitable reasoning depth based on the actual complexity of the text to be processed. Simultaneously, it avoids resource waste in simple problems and reasoning interruptions in complex problems, satisfying robustness and application flexibility in different scenarios.
[0051] According to an embodiment of the present invention, the above method further includes: constructing a prompt word template containing the initial constraint parameters using preset instructions, the value range of the initial constraint parameters, the text to be processed, and output format information.
[0052] In embodiments of the present invention, the preset instructions may be predefined task descriptions and role setting texts, used to guide the reasoning model into a specific reasoning mode. The output format information may be structured requirements for the generated thought chain text, including format information such as paragraph numbering, step separators, and conclusion markers.
[0053] For example, the design module of the inference model can be used to construct a prompt template with adjustable length constraints, providing clear length guidance for the inference model to generate thought chain text. The prompt template may include preset instructions, the value range of initial constraint parameters (constraint conditions), question input (for inserting the text to be processed), output format information, etc.
[0054] The initial constraint parameter can be denoted as τ, and the value of τ can be in the range of [τ_min, τ_max]. τ_max can be the average number of steps the inference model takes to generate the thought chain text without any constraints. The value of τ_min can be determined according to actual needs or experiments, for example, it can be 2.
[0055] For example, the default instruction is: "You are an efficient reasoning assistant. When solving problems, you need to balance the accuracy and simplicity of reasoning, retain only the core reasoning steps, and avoid redundancy."
[0056] The constraint is: "You can use a maximum of τ reasoning steps to solve the following problem. If you have obtained the correct reasoning result within τ steps, you can stop reasoning early and output the result; if you have not obtained the reasoning result after τ steps, you must output the current reasoning conclusion immediately."
[0057] The input question is: "Question: {q}", where {q} is the text to be processed.
[0058] The output format is: "Please generate the thought process chain according to the format of 'Step X: Reasoning Logic', and mark the final reasoning answer with '\boxed{final_answer}'". final_answer is the content of the final reasoning answer, and boxed is the symbol representing the marked box.
[0059] It is understandable that by introducing a dynamic constraint on the number (length) of reasoning steps through constraint parameters, the reasoning model can clearly define the upper limit of the length when generating the thought chain text, and focus on suppressing overthinking from the beginning stage until the end of the reasoning, avoiding overthinking in each reasoning step; at the same time, the constraints in the prompt word template make the reasoning model terminate immediately after the reasoning is completed, avoiding unnecessary step redundancy.
[0060] According to an embodiment of the present invention, through parameterized prompt word template design, the reasoning model is actively guided to control the length of reasoning steps during the reasoning generation stage. Combined with dynamic search algorithm to dynamically adjust the constraint strength, attention is paid to the suppression of overthinking from the beginning stage, which directly reduces the length of the thought chain, thereby reducing the time cost and memory usage of text generation.
[0061] According to an embodiment of the present invention, the predetermined search strategy includes a strategy for the number of times the thought chain is generated, determined by search parameters; the method further includes: evenly distributing the total number of times the thought chain text is generated in the search parameters to the search rounds, determining the number of times the thought chain text is generated in a single round of search during the iterative search process, so as to perform iterative search based on the number of times generated, wherein the total number of times generated is less than or equal to a preset number threshold.
[0062] In embodiments of the present invention, the search parameters can be a set of adjustable variables controlling the generation process of the thought chain text, including hyperparameters such as the number of generation times and the number of search rounds. The thought chain text can be the text output generated by a large model that includes a multi-step reasoning process, reflecting the model's thinking path. The total number of generation times can be the maximum number of times thought chain text is allowed to be generated during the entire iterative search process. The preset generation threshold can be a pre-set upper limit for the total number of generation times, used to control the consumption of computing resources.
[0063] Search rounds can be phases within an iterative search process, with each round performing partial reasoning generation and evaluation operations. The number of generation rounds can be the number of thought chain texts allowed to be generated in a single search round. Iterative search can be a gradual optimization process conducted over multiple rounds, with the search strategy adjusted based on feedback in each round.
[0064] For example, the reasoning model can be denoted as The model parameters are not adjusted during text inference.
[0065] Search parameters can include the maximum number of iterations T, the total number of generated thought chain texts N, constraint parameters, and a patience value. Initial constraint parameters can be those before optimization; the maximum value of the initial constraint parameter can be denoted as τ_max, and the minimum value as τ_min, for example, τ_min=2. The patience value in the patience mechanism can be denoted as β, for example, β=2.
[0066] The process of the inference model generating a thought chain text once can be regarded as a sampling. The number of times the inference model generates thought chain text is the sampling number. The iterative sampling allocation strategy can be to average the number of samples in each iteration, that is, the number of samples in each iteration n=floor(N / T), so that the total number of samples does not exceed the total number of generation times N.
[0067] In one feasible embodiment, by iteratively allocating and reducing the number of samples per round, and by aligning the value of N with the commonly used value of the Best-of-N technique, the total number of samples can be effectively controlled within a reasonable range.
[0068] According to an embodiment of the present invention, through the allocation mechanism of the number of times the thought chain text is generated, the system can achieve the optimal search effect within a limited computing budget. The round-by-round iterative search avoids the problem of fluctuation in the results generated at one time, and the multi-round verification mechanism makes the final reasoning result more reliable. Through the generation number allocation and round optimization mechanism, the optimal balance between search efficiency and quality is achieved under the constraint of limited computing resources.
[0069] According to an embodiment of the present invention, in response to receiving text to be processed, a plurality of initial constraint parameters are determined based on a predetermined search strategy, including: when the search iteration step is the initial iteration step, taking the peak value in the range of initial constraint parameters as the initial constraint parameters of the initial iteration step; when the search iteration step is the intermediate iteration step, determining the initial constraint parameters of the intermediate iteration step based on the valley value in the range of values and the current constraint parameters.
[0070] In embodiments of the present invention, the search iteration steps can be a phase division in a dynamic search process, including a starting iteration step, intermediate iteration steps, and a ending iteration step. The starting iteration step can be the first stage of the search process, mainly performing global exploration and coarse-grained search. The intermediate iteration steps can be the main search stage after the starting iteration step, performing local fine-grained optimization.
[0071] The peak (maximum) value of the initial constraint parameter can be the maximum value within the range of constraint parameter values, representing the maximum allowed number of inference steps. The trough value of the initial constraint parameter can be the minimum value within the range of constraint parameter values, representing the minimum necessary number of inference steps. The current constraint parameter can be the constraint parameter being evaluated in an intermediate iteration step.
[0072] For example, when the search iteration step is the starting iteration step, the peak value of the initial constraint parameter can be used as the initial constraint parameter of the starting iteration step, which is the average number of steps for the inference model to generate the thought chain without any constraints. This value can be obtained through prior experimental statistics.
[0073] For example, the valley value in the range is denoted as τ_min, and the current constraint parameter is denoted as τ. t Then the formula for determining the initial constraint parameters of the intermediate iteration steps is τ. t+1 =(τ t + τ_min) / 2.
[0074] In one feasible embodiment, the predetermined search strategy may further include constructing a search experience information base, which can be used to store statistical information on the confidence level of the inference results and the distribution of the length of the thought chain text for each iteration, with the record being empty at the beginning of the inference phase.
[0075] According to an embodiment of the present invention, the text to be processed is input into a prompt word template, and multiple initial thought chain texts are output based on multiple initial constraint parameters, including: updating the constraint conditions in the prompt word templates using multiple initial constraint parameters to obtain multiple updated prompt word templates; and using the multiple updated prompt word templates to output multiple initial thought chain texts corresponding to the text to be processed.
[0076] In embodiments of the present invention, constraints can be parameterized instructions in the prompt template that control the characteristics of thought chain text generation, such as limits on the number of reasoning steps or requirements for level of detail. Initial constraint parameters can be specific numerical instances of the constraints, such as the number of steps τ=3, 5, 7 representing different levels of detail. Updating the prompt template can be generating directly executable prompts by filling the variables in the prompt template with specific constraint parameter values.
[0077] For example, in the context of scientific explanation, constraint parameters can be used to control the academic depth of the explanation. τ=2 can represent an easy-to-understand analogy, τ=4 can represent basic concepts plus simple principle explanations, τ=6 can represent technical terms plus mathematical formula derivations, and τ=8 can represent citations of cutting-edge research plus comparisons between multiple schools of thought.
[0078] Understandably, prompt word templates can provide a unified generation format, ensuring the comparability of thought chain texts generated under different parameters; variable constraint parameters can be designed as placeholders through variable encapsulation, supporting parameterized batch generation, and the structure and integrity of the generated content can be constrained through template design.
[0079] For example, in the t-th iteration search step, the reasoning thought chain text is generated under the constraint-conditional prompt word template. This is based on the constraint parameter τ of the current search step. t Construct prompts with constraint parameters and input them into the model. Generate n initial thought chains Ct={c t1 , c t2 , ..., c tn Each initial thought chain text can contain initial reasoning steps and initial reasoning results.
[0080] According to an embodiment of the present invention, determining a target thought chain text from multiple initial thought chain texts based on the initial step number corresponding to each of the multiple initial thought chain texts and the confidence level of the inference results of each of the multiple initial thought chain texts includes: for multiple rounds of search in the iterative search process, sequentially selecting thought chain texts from the multiple initial thought chain texts whose inference results have a peak confidence level to obtain multiple candidate thought chain texts; selecting from the multiple candidate thought chain texts a thought chain text whose candidate inference results and the number of steps of the candidate inference results satisfy a preset condition as the target thought chain text.
[0081] In embodiments of the present invention, multi-round search can be achieved by dividing the optimization search process of the initial constraint parameters into multiple consecutive stages, with each round independently generating and evaluating thought chain texts. Peak confidence can be the highest confidence score among all thought chain texts in a single round of search, representing the quality index of the optimal solution in that round. Candidate thought chain texts can be the thought chain texts with the highest confidence scores selected in each round of search, serving as representative candidate solutions for that round. Candidate inference results can be the final inference results or conclusions corresponding to the candidate thought chain texts.
[0082] The preset conditions can be the confidence level of the reasoning result and the length of the reasoning steps. For example, the number of steps must meet the preset condition if the number of reasoning steps of the candidate thought chain text meets the preset optimization criteria, and the confidence level is greater than the confidence level threshold. The target thought chain text is the thought chain text that is finally selected as the best in terms of both confidence level and number of steps.
[0083] For example, methods for calculating the confidence of the inference result in the initial thought chain text may include: extracting each thought chain text c ti The reasoning result a ti Count the frequency of different reasoning results, calculate the proportion of each reasoning result (for example, if reasoning result "5" appears 8 times, and the total number of samples n=10, then the proportion is 80%), and take the reasoning result with the highest proportion as the "candidate reasoning result" for the current round. t The proportion of this is the confidence level b of the reasoning result. t (e.g., 80%).
[0084] It is understandable that by optimizing in stages through hierarchical screening in multiple rounds of search, the complex screening task can be decomposed into multiple manageable sub-tasks, reducing the complexity of single-round decision-making; through incremental improvement, each round is optimized based on the previous round, so as to continuously improve the quality of reasoning results; based on the early stopping mechanism, the search can be terminated in advance when a satisfactory solution is found in any round, thereby improving search efficiency.
[0085] According to an embodiment of the present invention, selecting a thought chain text from a plurality of candidate thought chain texts whose candidate reasoning results and the number of steps of the candidate reasoning results satisfy a preset condition, and using it as the target thought chain text, includes: processing multiple length information of the candidate thought chain texts to obtain candidate lengths of the multiple candidate thought chain texts, wherein the multiple length information is obtained by combining the sequence lengths of the multiple candidate thought chain texts; and using the candidate reasoning result as the target thought chain text when the candidate reasoning result at the current moment satisfies a first preset condition, the comparison result between the candidate length of the candidate reasoning result and the previous reasoning result satisfies a second preset condition, and the current iteration step satisfies the iteration number requirement.
[0086] In embodiments of the present invention, length information can be a quantifiable indicator of the complexity of the thought chain text steps. The sequence length can be the total number of tokens or characters in the thought chain text, reflecting the level of detail and complexity of the text. The candidate length can be a comprehensive length indicator obtained by aggregating multiple length information (such as combining, weighted averaging, or selecting the maximum value).
[0087] The candidate inference result at the current moment can be the final inference result or conclusion information of the candidate thought chain text generated in this iteration. The previous inference result can be the inference result obtained in a previous period, serving as a benchmark for comparison with the current round's inference result. The first precondition can be a quality comparison standard between the candidate inference result and the previous inference result, such as a confidence enhancement threshold, inference result consistency, or matching degree threshold. The second precondition can be an optimization comparison standard between the candidate length of the candidate inference result and the previous length, such as a length reduction ratio requirement. The iteration count requirement can be the minimum number of iterations required to terminate the search, ensuring sufficient exploration of the solution space.
[0088] For example, the distribution statistics of the candidate length and the preceding length of the candidate inference results can be calculated, denoted as L. t Filter out all generated candidate inference results a t The thought chain texts constitute a length set L t ={l ti , l ti It can be c ti The length of the token, c ti The reasoning result can be a t The chain of thought.
[0089] In a feasible embodiment, when calculating the statistical value of the step number (length) distribution of the inference results of the computational thinking chain text, stop words in the thinking chain text can be pre-deleted (for example, words that can be ignored during text processing, which can be high-frequency words lacking practical meaning, such as "of", "already", "and", etc.). Only the token lengths of the valid inference content are counted to avoid interference from format tokens and tokens without substantial content on the length statistics.
[0090] For example, the method for detecting whether the candidate inference result at the current moment and the previous inference result meet the first preset condition may include: judging the consistency between the candidate inference result at the current moment and the previous inference result according to the record status in the search experience information library (denoted as H).
[0091] If the search experience information library H is empty (i.e., t = 1), (a t ,l t ) can be stored in the experience information library H, enter the next round of iteration (t = 2), and update τ2=(τ_max + τ_min) / 2. This is the first step of the dynamic search strategy, which increases the constraint strength.
[0092] If the search experience information library H is not empty (i.e., t≥2), the candidate inference result a of the previous round can be extracted from H t-1 and the length statistical value l t-1 , and perform consistency detection of the inference results and length consistency. When the consistency detection results of the inference results and length consistency both meet the preset conditions and the current iteration step is the maximum iteration number, the candidate inference result is used as the target thinking chain text.
[0093] According to the embodiments of the present invention, considering that in the traditional technology, single-index screening (such as only focusing on the maximum confidence) ignores the length efficiency, resulting in overly long thinking chains during the inference process, it is difficult to ensure continuous improvement. The embodiments of the present invention ensure substantial improvement in each iteration through the first preset condition, prevent over-complication through the second preset condition, and further combine the multi-condition constraint mechanism of the iteration number requirement, which can achieve an optimal balance between the quality of the inference result and the complexity of the inference process.
[0094] According to the embodiments of the present invention, processing multiple length information of multiple candidate thinking chain texts to obtain the candidate lengths of multiple candidate thinking chain texts includes: processing the valley length, lower quartile length, and median length in the multiple length information to determine the length results of multiple candidate thinking chains as the candidate lengths.
[0095] In embodiments of the present invention, the minimum length value among multiple candidate thought chain texts represents the most concise version of reasoning; the lower quartile length can be the length value at the 25th percentile after the length dataset is sorted in ascending order, reflecting the boundary of concise thinking; the median length can be the middle value in the length dataset, representing the scale level of a typical thought chain. The length result can be a standardized length evaluation index obtained by comprehensively processing multiple statistics.
[0096] Candidate length can be a length metric used for screening decisions, such as min(Lt) which calculates the minimum candidate length Lt of the candidate inference results. t ), lower quartile Q1(L t ), median med(L t The specific calculation method for the candidate length distribution statistics is shown in the following formula (1):
[0097] (1);
[0098] It is understandable that formula (1) can comprehensively consider the statistical values of the length distribution and avoid the bias caused by a single statistic.
[0099] In related technologies, the length calculation method for thought chain text relies solely on the average value, making it susceptible to outliers. Fixed thresholds lack distribution adaptability and cannot distinguish quality differences between different levels of simplicity. According to embodiments of the present invention, determining candidate lengths through length information from different dimensions can improve evaluation accuracy, automatically adapt to the length characteristics of problems with varying complexity, and to some extent increase tolerance for extreme lengths.
[0100] According to an embodiment of the present invention, the above method further includes: when the inference result matches the reference result, updating the confidence of the inference result to obtain an updated confidence, so as to determine the candidate thought chain text using the updated confidence; or when the inference results of multiple initial thought chain texts are different in the current round of search, determining the generation probability of each of the multiple inference results, and taking the inference result corresponding to the peak probability in the generation probability as the candidate inference result to determine the candidate thought chain text.
[0101] In embodiments of the present invention, various special cases can be considered during the process of calculating the confidence level of the inference result. Matching the inference result with the reference result can indicate that the inference result and the reference result differ only literally, but actually represent the same meaning. Dissimilar inference results can mean that the inference results of all thought chain texts are different from each other in a certain iteration.
[0102] For example, when judging the consistency between the reasoning result and the reference result (such as the standard answer), and when counting the number of times each reasoning result is counted, semantic matching can be used for judgment. For example, "yes" and "correct" have the same meaning and should be merged into the same answer to avoid underestimation of confidence due to differences in expression.
[0103] For example, if the reasoning results of all thought chain texts are different in a certain round of iteration, then for each thought chain text corresponding to the reasoning result, calculate the logarithmic sum of its generation probability, and select the reasoning result with the largest logarithmic sum as the candidate reasoning result to avoid the dispersion of answers due to sampling randomness.
[0104] In natural language, the same reasoning result can be expressed in multiple ways (e.g., "yes" and "correct" both indicate affirmation). If only string-based exact matching is used, identical reasoning results may be counted as different, thus underestimating the confidence of the correct answer. Semantic matching, by merging semantically identical answers, can more accurately reflect the consensus of the reasoning model regarding the correct reasoning result. Through semantically consistent matching, the output expression habits are independent of specific reasoning models, adapting to the language style differences of different models. This is applicable to various task types such as mathematical calculations, common sense question answering, and reasoning judgments, enhancing cross-model and cross-task generalization capabilities.
[0105] According to an embodiment of the present invention, when the candidate inference result at the current moment satisfies a first preset condition with the previous inference result, the comparison result between the candidate length of the candidate inference result and the previous length satisfies a second preset condition, and the current iteration step meets the iteration number requirement, the candidate inference result is used as the target thought chain text. This includes: when the current inference result matches the previous inference result, and the thought chain text length of the current inference result is less than the thought chain text length of the previous inference result, the initial constraint parameter is iteratively updated to obtain intermediate constraint parameters; when the total number of current iteration steps is greater than or equal to the search rounds, multiple intermediate inference results are obtained based on the intermediate constraint parameters and the confidence level of the intermediate constraint parameters; and the inference result with a thought chain text length of valley value is selected from the multiple intermediate inference results as the target inference result to obtain the target thought chain text.
[0106] In embodiments of the present invention, the intermediate constraint parameters can be constraint parameter values dynamically adjusted during the iteration process, and the valley length can be the minimum length value among all candidate thought chain texts. The target inference result can be the final selected inference result that is optimal in terms of both inference accuracy and inference efficiency.
[0107] For example, methods for detecting consistency and length consistency in inference results can include: inference result consistency detection and length consistency detection. Inference result consistency detection includes: when a...t =a t-1 This indicates that the current candidate inference result is consistent with the previous inference result, showing that the accuracy has not decreased due to the increased constraints. Length consistency detection includes: when l t <l t-1 This indicates that the current length value is less than the previous length value, signifying that the strengthened constraints have effectively shortened the thought chain length. If both of the above conditions are met, the consistency check passes. At this point, the current candidate reasoning result and the candidate length information pair are denoted as (a...). t ,l t ), store in the search experience information database H, and update τ t+1 =(τ t + τ_min) / 2, further strengthen the constraints, and enter the next iteration.
[0108] When the current iteration count reaches the maximum iteration count T, the search terminates, and all information pairs (a) are extracted from the search experience information base. t ,l t Select the candidate inference result a_final with the highest confidence, and select the shortest thought chain text from all generated candidate inference results a_final as the final output thought chain c_final.
[0109] In embodiments of the present invention, a dynamic search strategy is used to monitor changes in the accuracy of the inference results and the length of the inference steps in real time through consistency checks. Constraints are strengthened only on the premise that the accuracy does not decrease, thereby avoiding the problem of accuracy decreasing due to shortening the length. At the same time, the patience mechanism can effectively avoid sampling errors and ensure search robustness.
[0110] According to an embodiment of the present invention, the method further includes: detecting the patience value of the current iteration step when at least one of the following preset judgment conditions is met; updating the subsequent constraint parameters to perform iterative search using the subsequent constraint parameters when the patience value indicates that the matching result between the current inference result and the previous inference result is an error result; terminating the iterative search and determining the target inference result from the current inference result and the previous inference result when the patience value indicates that the accuracy of the current inference result decreases or the intermediate constraint parameter update fails; wherein the preset judgment conditions include: the current inference result does not match the previous inference result; the length of the thought chain text of the current inference result is greater than or equal to the length of the thought chain text of the previous inference result.
[0111] In embodiments of the present invention, the preset judgment condition can be a prior condition for triggering patience value detection, including situations such as mismatch inference results and deterioration in the length of the thought chain text. The patience value can be an indicator that quantifies the degree of stagnation in the search process, used to assess the persistence of optimization stagnation. The current inference result can be the output conclusion and quality assessment of the candidate thought chain generated in this iteration; the previous inference result can be the best result obtained in previous iterations, serving as an improvement benchmark.
[0112] Error results can be quantified as the deviation between the current result and historical results. Later constraint parameters can be new constraint parameters adjusted based on patience values for subsequent searches. Decreased accuracy indicates a decline in the quality of the current result relative to the historical best result, while failed intermediate constraint parameter updates indicate an invalid update state where parameter adjustments did not produce a better solution.
[0113] For example, in the scenario of optimizing the thought chain generation for geometric proof problems, a constraint parameter τ=8 is set to trigger the generation of detailed proof chains. If mismatches occur after three consecutive iterations (different proof paths but consistent conclusions), a patience value check is performed, calculating the quality deviation between the current result and the historical best as 0.15 (slight stagnation). This allows for adjustment of the subsequent constraint parameter to τ=6, attempting a simpler proof path, generating a better proof chain with updated parameters, and continuing the search.
[0114] According to embodiments of the present invention, by introducing a patience-driven termination mechanism, resource waste caused by ineffective iterations can be effectively avoided. When a substantial stagnation in the search process is detected, the strategy can be adjusted in a timely manner, significantly shortening the convergence time and improving the utilization of computational resources. Compared to the fixed-iteration search strategy in traditional techniques, embodiments of the present invention can significantly reduce unnecessary computational overhead while maintaining result quality. A monitoring mechanism based on dual-condition triggering ensures that the search process remains under control. When a trend of quality degradation occurs, the system can intervene in a timely manner to prevent a continuous decline in result quality. A guarantee mechanism that selects the final output from historical best results ensures that a high-quality solution can be output even if the search terminates prematurely.
[0115] According to an embodiment of the present invention, determining the target inference result from the current inference result and the previous inference result includes: when the current inference result is equal to the target result in the previous inference result, updating the subsequent constraint parameter by taking the current constraint parameter as the peak value in the value range, wherein the target result is the inference result of the peak confidence in the previous inference result; when the current inference result is not equal to the target result in the previous inference result, updating the subsequent constraint parameter by taking the current constraint parameter as the valley value in the value range.
[0116] In embodiments of the present invention, if the current inference result is equal to the target result in previous inference results, it indicates that the optimal solution in the current round is semantically and logically identical to that in previous rounds. If the current inference result is not equal to the target result in previous inference results, it indicates that there is a substantial difference between the optimal solution in the current round and that in previous rounds.
[0117] For example, in the consistency and length consistency checks of the inference results, if at least one of the two conditions is not met, the consistency check fails. To address the consistency check failure, a patience value is further checked based on a patience mechanism to update the subsequent constraint parameters.
[0118] If the patience value β > 0, the patience value β can be reduced by β = β - 1, and τ can be updated. t+1 =(τ t + τ_min) / 2 indicates that the constraints are further strengthened, ignoring the random errors of the consistency check failure, and (a t ,l t Store it in H and proceed to the next iteration.
[0119] If the patience value β=0, it indicates that patience has been exhausted, meaning that the increased constraints have led to a decrease in the accuracy of the reasoning results or that there is no room for optimization in the number of reasoning steps (length). At this point, the current candidate reasoning result a can be compared. t By comparing the confidence levels of all candidate inference results in the search experience information base, find the inference result 'a' with the highest confidence level.
[0120] The current candidate inference result a can be further... t Compare with the target result (the reasoning result a with the highest confidence) in the previous reasoning results.
[0121] If a t =a indicates that the current inference result is still optimal, and at this time, τ_max=τ can be updated. t The current constraint parameters are used as the new easing boundary, τ. t+1 =(τ_max + τ_min) / 2, store in the search experience information base, and proceed to the next iteration.
[0122] If a t If ≠a, it indicates that the current inference result is not optimal, and the excessively strong constraints lead to a decrease in accuracy. In this case, τ_min = τ can be updated. t That is, the current constraint parameters are used as the new strict boundary, τ t+1 =(τ_max + τ_min) / 2, store in the search experience information base, and proceed to the next iteration.
[0123] It is understood that the dynamic search strategy for optimizing the length of the thought chain text for model inference in this embodiment of the invention includes: initializing search parameters and allocating the number of samples per round; iteratively generating prompts with constraint parameters to obtain the thought chain, and calculating the confidence of the inference result and the statistical values of the distribution of the number of inference steps (length); thereby performing a consistency check and adjusting the constraint parameters according to the check results; after the search terminates, selecting the thought chain text with the highest confidence and the shortest length (the target thought chain text) as the final output.
[0124] According to embodiments of the present invention, an intelligent strategy switching mechanism can dynamically adjust the optimization intensity based on the actual state of the search process. An aggressive peak strategy is employed to accelerate convergence as the search nears completion, while a robust valley strategy is used during the exploration phase to avoid oscillations, significantly improving the overall efficiency of the search process. This adaptive adjustment avoids the limitations of fixed strategies, making the allocation of search resources more rational. A comparison mechanism based on historical best results ensures that the search process does not experience quality regression. The conservative adjustment of the valley strategy when results are inconsistent prevents quality fluctuations caused by overexploration, while the targeted optimization of the peak strategy when results are consistent ensures continuous quality improvement. The synergistic effect of the two strategies guarantees a monotonic improvement trend in the quality of the results.
[0125] According to an embodiment of the present invention, the above method further includes: deleting redundant steps in multiple steps of the target thought chain text to obtain an updated thought chain text; generating an updated inference result using the updated thought chain text; and outputting the inference result based on the updated thought chain text, the updated inference result, and the output format information, provided that the confidence level of the updated inference result meets the confidence level threshold.
[0126] In embodiments of the present invention, redundant steps can be intermediate links in the thought chain text that contribute little to the core reasoning logic, are repetitive, or irrelevant. These steps increase text length without improving reasoning quality and may even introduce noise. Updating the thought chain can be achieved by deleting redundant steps to obtain a simplified version of the thought chain, retaining the core reasoning logic, removing irrelevant content, and improving the simplicity and clarity of the thought chain.
[0127] The updated reasoning result can be the final answer or conclusion regenerated or extracted based on the updated thought chain text, reflecting the output of the simplified thought chain. The confidence threshold can be a preset acceptable quality threshold used to determine whether the updated reasoning result is reliable; only results that reach or exceed this threshold will be the final output.
[0128] For example, in scenarios involving streamlining the steps of solving mathematical problems, when dealing with complex mathematical proofs, the target thought chain text may contain a large number of intermediate calculations and repetitive derivations. By identifying and removing those repetitive formula derivation steps, while retaining the application of key theorems and turning points, a more concise and clear proof process can be formed. For instance, multiple repetitive simplification steps can be merged into one step, highlighting the core derivation logic.
[0129] For example, in the logical extraction scenario of legal text analysis and in legal case reasoning, the target thought chain text may contain a large number of redundant factual statements and legal citations. Repeated factual descriptions and minor legal citations can be deleted to focus on key legal elements and judgment logic, thus forming a concise legal opinion.
[0130] Figure 3 A flowchart of a target thought chain text update method according to an embodiment of the present invention is shown.
[0131] To further improve the accuracy and conciseness of the target thought chain text, post-processing optimization can be performed on the target thought chain text c_final.
[0132] like Figure 3 As shown, the target thought chain update method of this embodiment includes operations S310 to S330.
[0133] In operation S310, the validity of the reasoning steps is checked. This includes operations S311 through S314.
[0134] In operation S311, determine whether the reasoning step is a critical step. If yes, execute operation S312; otherwise, execute operation S313.
[0135] In operation S312, retain this step.
[0136] In operation S313, delete this redundant step.
[0137] During operation S314, perform subsequent redundancy detection steps until the detection is complete.
[0138] For each reasoning step in the target thought chain text c_final, determine whether it is a critical step.
[0139] A critical step can be defined as follows: whether the reasoning logic is interrupted after deleting the reasoning step. The determination method can be: after deleting the step, regenerate and update the thought chain text. If the reasoning result remains unchanged and the reasoning logic is coherent, then the step is redundant and should be deleted; otherwise, it is a critical step and should be retained. Deleting redundant steps can further shorten the length of the thought chain.
[0140] When operating S320, the output format is standardized. The format for expressing the reasoning steps can be: "Step X: [Reasoning Logic]", and duplicate or irrelevant expressions such as "Let me check again", "The possible calculation process is", "Let me think", "etc." are removed to improve interpretability. At the same time, ensure that the format of the final reasoning result is consistent, for example, as mentioned in the prompt word template: "\boxed{final_answer}").
[0141] When operating the S330, the optimized updated thought chain text is output.
[0142] It is understood that the text reasoning method in this embodiment of the invention does not rely on a specific model training strategy. Based on a dynamic search strategy, it dynamically adjusts the range of hyperparameter values, thus adapting to diverse reasoning tasks of low, medium, and high difficulty. It eliminates the need for separate design schemes for different models or tasks and can be directly integrated into existing model reasoning systems, reducing the development and maintenance costs of technology implementation.
[0143] According to embodiments of the present invention, substantial improvements are achieved in multiple dimensions through a systematic redundancy removal and quality control mechanism. In terms of information density, the knowledge concentration of the thought chain is significantly increased, allowing each unit of text to carry more effective information and reducing the time cost for users to acquire core content. Regarding reasoning quality, eliminating interfering information makes key logic clearer, improving the traceability and verifiability of the problem-solving path. In terms of computational efficiency, the streamlined thought chain processes significantly faster, reducing computational resource consumption and enabling real-time applications. The reliability of results is also enhanced because the confidence threshold mechanism ensures that only optimized results meeting quality standards are output, avoiding a decrease in accuracy due to over-simplification.
[0144] Based on the above-described text reasoning method, this invention also provides a text reasoning device. The following will combine... Figure 4 The device is described in detail.
[0145] Figure 4 A structural block diagram of a text reasoning device according to an embodiment of the present invention is shown.
[0146] like Figure 4 As shown, the text reasoning device 400 of this embodiment includes a parameter determination module 410, an output module 420, a text determination module 430, and a generation module 440.
[0147] The parameter determination module 410 is configured to determine multiple initial constraint parameters based on a predetermined search strategy in response to receiving the text to be processed. These initial constraint parameters constrain the number of initial steps required for inference processing of the text to be processed. In one embodiment, the parameter determination module 410 may be used to perform the operation S210 described above, which will not be repeated here.
[0148] The output module 420 is used to input the text to be processed into the prompt word template and, based on multiple initial constraint parameters, output multiple initial thought chain texts. Each initial thought chain text includes multiple reasoning paragraphs corresponding to the initial number of steps, and each initial thought chain text includes multiple reasoning paragraphs corresponding to a set of reasoning results. In one embodiment, the output module 420 can be used to perform the operation S220 described above, which will not be repeated here.
[0149] The text determination module 430 is used to determine the target thought chain text from multiple initial thought chain texts based on the initial step number corresponding to each of the multiple initial thought chain texts and the confidence level of the reasoning results of each of the multiple initial thought chain texts. In one embodiment, the text determination module 430 can be used to perform the operation S230 described above, which will not be repeated here.
[0150] The generation module 440 is used to generate a reasoning answer for the text to be processed based on the target thought chain text. In one embodiment, the generation module 440 can be used to perform the operation S240 described above, which will not be repeated here.
[0151] According to an embodiment of the present invention, based on the parameter determination module 410, output module 420, text determination module 430 and generation module 440 in the text reasoning device 400, multiple initial constraint parameters are determined through a predetermined search strategy and initial thought chain texts corresponding to different number of steps are generated. Target thought chains are then selected based on a comprehensive evaluation of the number of steps and confidence level, thereby overcoming the limitations of existing static constraints. Under the premise of ensuring reasoning accuracy (high confidence level), the length of the thought chain (fewer steps) is actively optimized, achieving synergistic optimization of accuracy and conciseness. Furthermore, the target thought chain text obtained through selection retains key reasoning logic while eliminating redundant expressions, making the reasoning process clearer and more focused, improving the traceability of the reasoning answer and the efficiency of user comprehension. It achieves adaptive matching of the most suitable reasoning depth according to the actual complexity of the text to be processed, while avoiding resource waste in simple problems and reasoning interruption in complex problems, satisfying robustness and application flexibility in different scenarios.
[0152] According to an embodiment of the present invention, the predetermined search strategy includes a thought chain generation frequency strategy determined by search parameters; the above-mentioned device further includes: a frequency determination module, used to evenly distribute the total number of times thought chain text is generated in the search parameters to the search rounds, determine the number of times generated in a single round of search during the iterative search process, so as to perform iterative search based on the number of times generated, wherein the total number of times generated is less than or equal to a preset frequency threshold.
[0153] According to an embodiment of the present invention, the parameter determination module 410 includes: a submodule and a constraint parameter determination submodule. The submodule is used to, when the search iteration step is the starting iteration step, use the peak value in the range of initial constraint parameters as the initial constraint parameters for the starting iteration step; the constraint parameter determination submodule is used to, when the search iteration step is an intermediate iteration step, determine the initial constraint parameters for the intermediate iteration step based on the valley value in the range and the current constraint parameters.
[0154] According to an embodiment of the present invention, the output module 420 includes an update submodule and a text output submodule. The update submodule is used to update the constraints in the prompt word templates using multiple initial constraint parameters to obtain multiple updated prompt word templates; the text output submodule is used to output multiple initial thought chain texts corresponding to the text to be processed using the multiple updated prompt word templates.
[0155] According to an embodiment of the present invention, the text determination module 430 includes: a first selection submodule and a second selection submodule. The first selection submodule is used to select, for multiple rounds of searching in the iterative search process, thought chain texts whose inference result confidence is the peak confidence from multiple initial thought chain texts to obtain multiple candidate thought chain texts; the second selection submodule is used to select, from the multiple candidate thought chain texts, thought chain texts whose candidate inference result and the number of steps of the candidate inference result satisfy a preset condition, as the target thought chain text.
[0156] According to an embodiment of the present invention, the second selection submodule includes: a length information processing unit and a result as a unit. The length information processing unit is used to process multiple length information of the candidate thought chain text to obtain candidate lengths of multiple candidate thought chain texts, wherein the multiple length information is obtained by combining the sequence lengths of the multiple candidate thought chain texts; the result as a unit is used to select the candidate inference result as the target thought chain text when the candidate inference result at the current time satisfies a first preset condition, the comparison result between the candidate length of the candidate inference result and the previous inference result satisfies a second preset condition, and the current iteration step meets the iteration number requirement.
[0157] According to an embodiment of the present invention, the length information processing unit includes: a length processing subunit, used to process the valley length, lower quartile length and median length of multiple length information to determine the length results of multiple candidate thought chains as candidate lengths.
[0158] According to an embodiment of the present invention, the apparatus further includes: a confidence update module and a probability determination module. The confidence update module is used to update the confidence of the inference result when the inference result matches the reference result, obtaining an updated confidence, and using the updated confidence to determine candidate thought chain texts; or the probability determination module is used to determine the generation probability of each of the multiple inference results when, in the current round of search, the inference results of multiple initial thought chain texts are different, and to use the inference result corresponding to the peak probability among the generation probabilities as a candidate inference result to determine candidate thought chain texts.
[0159] According to an embodiment of the present invention, the result unit includes: a value update subunit, a reasoning result determination subunit, and a result selection subunit. The value update subunit is used to iteratively update the values of the initial constraint parameters to obtain intermediate constraint parameters when the current reasoning result matches a previous reasoning result and the length of the thought chain text of the current reasoning result is less than the length of the thought chain text of the previous reasoning result. The reasoning result determination subunit is used to obtain multiple intermediate reasoning results based on the intermediate constraint parameters and their confidence levels when the total number of current iteration steps is greater than or equal to the number of search rounds. The result selection subunit is used to select the reasoning result with a thought chain text length of the valley value from the multiple intermediate reasoning results as the target reasoning result, thus obtaining the target thought chain text.
[0160] According to an embodiment of the present invention, the apparatus further includes: a detection module, a parameter update module, and an inference result determination module. The detection module is used to detect the patience value of the current iteration step when at least one of the following preset judgment conditions is met; the parameter update module is used to update the subsequent constraint parameters to perform iterative search using the subsequent constraint parameters when the patience value indicates that the matching result between the current inference result and the previous inference result is an error result; the inference result determination module is used to terminate the iterative search and determine the target inference result from the current inference result and the previous inference result when the patience value indicates that the accuracy of the current inference result has decreased or the intermediate constraint parameter update has failed; wherein the preset judgment conditions include: a mismatch between the current inference result and the previous inference result; and the length of the thought chain text of the current inference result is greater than or equal to the length of the thought chain text of the previous inference result.
[0161] According to an embodiment of the present invention, the inference result determination module includes: a first update submodule and a second update submodule. The first update submodule is used to update the subsequent constraint parameters by taking the current constraint parameter as the peak value in the value range when the current inference result is equal to the target result in the previous inference result, wherein the target result is the inference result with peak confidence in the previous inference result; the second update submodule is used to update the subsequent constraint parameters by taking the current constraint parameter as the valley value in the value range when the current inference result is not equal to the target result in the previous inference result.
[0162] According to an embodiment of the present invention, the apparatus further includes a deletion module and a result output module. The deletion module is used to delete redundant steps in multiple steps of the target thought chain to obtain an updated thought chain; the result output module is used to generate an updated inference result using the updated thought chain text, and output the inference result based on the updated thought chain text, the updated inference result, and output format information, provided that the confidence level of the updated inference result meets a confidence level threshold.
[0163] According to an embodiment of the present invention, the device further includes: a template construction module, used to construct a prompt word template containing the initial constraint parameters using preset instructions, the value range of the initial constraint parameters, the text to be processed, and output format information.
[0164] According to embodiments of the present invention, any plurality of modules among the parameter determination module 410, output module 420, text determination module 430, and generation module 440 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of the present invention, at least one of the parameter determination module 410, output module 420, text determination module 430, and generation module 440 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any one of the three implementation methods or a suitable combination of any of them. Alternatively, at least one of the parameter determination module 410, output module 420, text determination module 430, and generation module 440 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0165] Figure 5 A block diagram of an electronic device suitable for implementing a text reasoning method according to an embodiment of the present invention is shown.
[0166] like Figure 5 As shown, an electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage portion 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor, and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0167] RAM 503 stores various programs and data required for the operation of electronic device 500. Processor 501, ROM 502, and RAM 503 are interconnected via bus 504. Processor 501 executes various operations of the method flow according to embodiments of the present invention by executing programs in ROM 502 and / or RAM 503. It should be noted that the programs may also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 may also execute various operations of the method flow according to embodiments of the present invention by executing programs stored in said one or more memories.
[0168] According to an embodiment of the present invention, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to a bus 504. The electronic device 500 may also include one or more of the following components connected to the input / output (I / O) interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 510 as needed so that computer programs read from it can be installed into the storage section 508 as needed.
[0169] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.
[0170] According to embodiments of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present invention, the computer-readable storage medium may include ROM 502 and / or RAM 503 and / or one or more memories other than ROM 502 and RAM 503 described above.
[0171] Embodiments of the present invention also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the text reasoning method provided in the embodiments of the present invention.
[0172] When the computer program is executed by the processor 501, it performs the functions defined in the system / apparatus of this invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0173] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 509, and / or installed from a removable medium 511. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0174] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by processor 501, it performs the functions defined in the system of this embodiment of the invention. According to embodiments of the invention, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0175] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0176] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0177] Those skilled in the art will understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments of the present invention can be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or combinations fall within the scope of the present invention.
[0178] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.
Claims
1. A text-based reasoning method, characterized in that, The method includes: In response to receiving the text to be processed, multiple initial constraint parameters are determined based on a predetermined search strategy, including: when the search iteration step is the initial iteration step, the peak value in the range of initial constraint parameters is used as the initial constraint parameter of the initial iteration step; when the search iteration step is an intermediate iteration step, the initial constraint parameter of the intermediate iteration step is determined based on the valley value in the range of values and the current constraint parameter, wherein the initial constraint parameters are used to constrain the number of initial steps required for inference processing of the text to be processed; The text to be processed is input into the prompt word template, and based on the multiple initial constraint parameters, multiple initial thought chain texts are output. Each initial thought chain text includes multiple reasoning paragraphs corresponding to the initial number of steps, and each initial thought chain text includes multiple reasoning paragraphs corresponding to a set of reasoning results. Based on the initial step number corresponding to each of the multiple initial thought chain texts, and the confidence level of the reasoning results of each of the multiple initial thought chain texts, the target thought chain text is determined from the multiple initial thought chain texts, including: For the multiple rounds of search in the iterative search process, the thought chain text with the peak confidence of the reasoning result is selected sequentially from the multiple initial thought chain texts to obtain multiple candidate thought chain texts; Multiple length information that characterize the step complexity of the candidate thought chain text is processed to obtain the candidate length of the multiple candidate thought chain texts, wherein the multiple length information is obtained by combining the sequence lengths of the multiple candidate thought chain texts; If the quality comparison standard between the current candidate inference result and the previous inference result meets the first preset condition, the length reduction ratio between the candidate length of the candidate inference result and the previous length meets the second preset condition, and the current iteration step meets the iteration number requirement, then the candidate inference result is used as the target thought chain text. The quality comparison standard includes a confidence enhancement threshold, inference result consistency, and matching degree threshold. Based on the target thought chain text, generate a reasoning answer for the text to be processed.
2. The method according to claim 1, characterized in that, The predetermined search strategy includes a strategy for the number of thought chain generation times determined by the search parameters; The method further includes: The total number of times the thought chain text is generated in the search parameters is evenly distributed among the search rounds to determine the number of times a single round of search is generated during the iterative search process, so as to perform iterative search based on the number of times generated, wherein the total number of times generated is less than or equal to a preset number threshold.
3. The method according to claim 1, characterized in that, The text to be processed is input into the prompt word template, and based on the multiple initial constraint parameters, multiple initial thought chain texts are output, including: The constraints in the prompt word template are updated using the multiple initial constraint parameters to obtain multiple updated prompt word templates; Using the multiple update prompt word templates, multiple initial thought chain texts corresponding to the text to be processed are output.
4. The method according to claim 1, characterized in that, Processing multiple length information of the candidate thought chain texts to obtain the candidate lengths of the multiple candidate thought chain texts includes: The valley length, lower quartile length, and median length in the multiple length information are processed to determine the length results of the multiple candidate thought chains, which are used as the candidate lengths.
5. The method according to claim 1, characterized in that, The method further includes: If the inference result matches the reference result, the confidence level of the inference result is updated to obtain an updated confidence level, which is then used to determine the candidate thought chain text; or In the current round of search, if the reasoning results of the multiple initial thought chain texts are different from each other, the generation probability of each of the multiple reasoning results is determined, and the reasoning result corresponding to the peak probability among the generation probabilities is taken as the candidate reasoning result to determine the candidate thought chain text.
6. The method according to claim 4, characterized in that, If the candidate inference result at the current moment satisfies a first preset condition compared to the previous inference result, the comparison result between the candidate length of the candidate inference result and the previous length satisfies a second preset condition, and the current iteration step meets the iteration number requirement, then the candidate inference result is used as the target thought chain text, including: If the current inference result matches the previous inference result, and the length of the thought chain text of the current inference result is less than the length of the thought chain text of the previous inference result, the value of the initial constraint parameter is iteratively updated to obtain the intermediate constraint parameter. If the total number of current iteration steps is greater than or equal to the number of search rounds, multiple intermediate inference results are obtained based on the intermediate constraint parameters and the confidence level of the intermediate constraint parameters. From the multiple intermediate inference results, the inference result with the thought chain text length being the valley length is selected as the target inference result, and the target thought chain text is obtained.
7. The method according to claim 6, characterized in that, The method further includes: The patience value of the current iteration step is detected if at least one of the following preset judgment conditions is met; If the patience value indicates that the matching result between the current inference result and the previous inference result is an error result, the subsequent constraint parameter is updated to perform iterative search using the subsequent constraint parameter; If the patience value indicates a decrease in the accuracy of the current inference result or a failure to update intermediate constraint parameters, the iterative search is terminated, and the target inference result is determined from the current inference result and the previous inference result. The preset judgment conditions include: The current inference result does not match the previous inference result; and The length of the thought chain text of the current reasoning result is greater than or equal to the length of the thought chain text of the previous reasoning result.
8. The method according to claim 7, characterized in that, Determining the target inference result from the current inference result and the previous inference result includes: If the current inference result is equal to the target result in the previous inference result, the current constraint parameter is taken as the peak value in the range and the subsequent constraint parameter is updated, wherein the target result is the inference result of the peak confidence in the previous inference result; If the current inference result is not equal to the target result in the previous inference result, the current constraint parameter is taken as the valley value in the value range, and the subsequent constraint parameter is updated.
9. The method according to claim 4, characterized in that, The method further includes: Redundant steps in multiple steps of the target thought chain text are deleted to obtain the updated thought chain text. An updated inference result is generated using the updated thought chain text. If the confidence level of the updated inference result meets the confidence level threshold, the inference result is output based on the updated thought chain text, the updated inference result, and the output format information.
10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: Using preset instructions, the value range of initial constraint parameters, the text to be processed, and output format information, a prompt word template containing the initial constraint parameters is constructed.
11. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 10.
12. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Data processing method, device and equipment and readable storage medium
CN120317365A
Large model question and answer method and device based on thinking chain
CN120874831A