Reasoning method and device of large language model based on thinking tree

By introducing a thinking tree structure into the large language model, and building and pruning the thinking tree to perform hierarchical reasoning, the problem of lack of logic and coherence in the reasoning of the traditional large language model is solved, and a more efficient and interpretable reasoning process is achieved.

CN118709786BActive Publication Date: 2025-02-07XIAN JIAYUBAO INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411068109.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-06
Publication Date
2025-02-07
Estimated Expiration
2044-08-06

AI Technical Summary

Technical Problem

Traditional large language models lack logic and coherence in reasoning, making it difficult to simulate the hierarchy of human thinking, resulting in low accuracy and efficiency of reasoning.

Method used

The large language model reasoning method based on thinking tree is adopted, and the large language model is guided to perform hierarchical reasoning by constructing a thinking tree, and the advantages of the tree structure are used to improve the coherence and accuracy of the reasoning. The specific steps include entering the problem into the model, building a thinking tree, scoring and pruning child nodes until the stop condition is reached, and finally determining the inference result.

Benefits of technology

Through tree structure modeling the inference process, the inference process is made clearer, coherent, interpretable and backtrackable, improving the flexibility and error correction ability of inference, and improving the accuracy of large language models in the inference process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118709786B_ABST
    Figure CN118709786B_ABST
Patent Text Reader

Abstract

The present application provides a reasoning method and device of a large language model based on a thinking tree, which belongs to the field of artificial intelligence technology. The method includes: inputting a first question into a large language model to obtain a second question; the large language model constructs a first thinking tree according to the second question, and the first thinking tree includes a root node and multiple child nodes; for each child node, the child node is spliced ​​with the root node, and is input into the large language model as a third question for scoring to obtain a scoring result; according to the scoring result, it is determined to retain the child node or prune the child node; repeatedly executing the process of inputting the second question into the large language model until the preset stop condition is reached to obtain a second thinking tree; the content corresponding to the child node with the highest score in the second thinking tree is determined as the final reasoning result. Through this scheme, the coherence and accuracy of the large language model in the reasoning process can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a reasoning method and device for a large language model based on a thinking tree. Background Art

[0002] With the rapid development of artificial intelligence technology, large language models (LLMs) and their applications in natural language processing have become a research focus. Large language models can not only generate natural language texts, but also deeply understand the meaning of texts and handle various natural language tasks, such as text summarization, question answering, translation, etc.

[0003] Traditional large language models often lack logic and coherence when performing reasoning, and it is difficult to simulate the hierarchical structure of human thinking, which leads to low accuracy and efficiency of large language model reasoning. To solve this problem, a smart question-answering method based on thinking chain is proposed in related technologies. By building a reasoning chain to guide the large language model to reason, the reasoning results generated by the large language model are supplemented and optimized to generate the final answer.

[0004] However, although the chain of thought can characterize the reasoning process, it is difficult to fully express the hierarchy of complex reasoning, which will affect the coherence and accuracy of the large language model in the reasoning process. Summary of the invention

[0005] The present application provides a reasoning method and device for a large language model based on a mind tree, which are used to improve the coherence and accuracy of the large language model during the reasoning process.

[0006] In a first aspect, the present application provides a training method for a large language model based on a mind tree, the method comprising:

[0007] S1, inputting a first question into a large language model to obtain a second question; the first question is an original natural language question, and the second question is a question to be inferred obtained after the large language model judges the first question;

[0008] S2, the large language model constructs a first thought tree according to the second question, the first thought tree comprising a root node and a plurality of child nodes; wherein the root node is the second question, and each of the child nodes is a sub-question related to the second question;

[0009] S3, for each of the sub-nodes, concatenate the sub-node with the root node, and input the concatenated sub-node into the large language model as the third question for scoring, thereby obtaining a scoring result;

[0010] S4, determining whether to retain the child node or prune the child node according to the scoring result;

[0011] S5, repeatedly executing S2 to S4 until a preset stop condition is reached, thereby obtaining a second thinking tree;

[0012] S6: Determine the content corresponding to the sub-node with the highest score in the second thinking tree as the final reasoning result.

[0013] In a possible design of the first aspect, inputting the first question into the large language model to obtain the second question includes:

[0014] Inputting the first question into the large language model;

[0015] The large language model determines whether the first question is suitable for reasoning;

[0016] When the first question is suitable for reasoning, outputting the second question;

[0017] When the first question is not suitable for reasoning, a result that the first question is not suitable for reasoning is output.

[0018] In a possible design of the first aspect, the large language model constructs a first thinking tree according to the second question, including:

[0019] The large language model generates a plurality of sub-questions related to the second question according to the second question;

[0020] The first thinking tree is constructed by taking the second question as the root node and the plurality of sub-questions as sub-nodes according to a preset thinking tree generation framework.

[0021] In a possible design of the first aspect, the large language model generates a plurality of sub-questions related to the second question according to the second question, including:

[0022] The large language model generates a plurality of sub-questions related to the second question according to the second question and preset prompt words.

[0023] In a possible design of the first aspect, the large language model generates a plurality of sub-questions related to the second question according to the second question, including:

[0024] The large language model generates a plurality of sub-questions related to the second question according to the second question and a preset temperature sampling strategy.

[0025] In a possible design of the first aspect, the child node is concatenated with the root node and input as the third question into the large language model for scoring to obtain a scoring result, including:

[0026] splicing the content of the child node with the content of the root node, and inputting the result as the third question into the large language model;

[0027] The large language model scores the relevance and reliability between the content of the child node and the content of the root node, respectively, to obtain a relevance score and a reliability score;

[0028] The relevance score and the reliability score are determined as the scoring result.

[0029] In a possible design of the first aspect, determining, according to the scoring result, whether to retain the child node or to prune the child node includes:

[0030] In the case where the relevance score in the scoring result is greater than a relevance threshold, and the reliability score is greater than a reliability threshold, determining to retain the child node;

[0031] When the relevance score in the scoring result is less than or equal to the relevance threshold, or when the reliability score is less than or equal to the reliability threshold, it is determined to prune the child node.

[0032] In a possible design of the first aspect, pruning the child node includes:

[0033] Determine whether the child node meets the preset pruning condition;

[0034] When the child node satisfies the preset pruning condition, the subtree where the child node is located is removed as a whole from the first thinking tree;

[0035] When the child node does not satisfy the preset pruning condition, the subtree where the child node is located is retained.

[0036] In a second aspect, the present application provides a reasoning device based on a large language model of a thinking tree, the device comprising:

[0037] An input module, configured to input a first question into a large language model to obtain a second question; the first question is an original natural language question, and the second question is a question to be inferred obtained after the large language model judges the first question;

[0038] A construction module, used for the large language model to construct a first thinking tree according to the second question, wherein the first thinking tree includes a root node and a plurality of child nodes; wherein the root node is the second question, and each of the child nodes is a sub-question related to the second question;

[0039] A concatenation module, configured to concatenate each of the sub-nodes with the root node, and input the concatenation as a third question into the large language model for scoring, to obtain a scoring result;

[0040] A first determination module, used to determine whether to retain the child node or prune the child node according to the scoring result;

[0041] A trigger module, used to trigger the processing of the building module until a preset stop condition is reached to obtain a second thinking tree;

[0042] The second determination module is used to determine the content corresponding to the sub-node with the highest score in the second thinking tree as the final reasoning result.

[0043] In a third aspect, the present application provides a computer device, comprising: a transceiver, a processor, and a memory communicatively connected to the processor;

[0044] The memory stores computer-executable instructions;

[0045] The processor executes the computer-executable instructions stored in the memory to implement the reasoning method based on the large language model of the thinking tree as described in any one of the first aspects.

[0046] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the reasoning method of a large language model based on a thinking tree as described in any one of the first aspects.

[0047] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the reasoning method of a large language model based on a thinking tree as described in any one of the first aspects.

[0048] The reasoning method and device of the large language model based on the thinking tree provided by the present application relate to the field of artificial intelligence technology. The method includes: inputting the first question into the large language model to obtain the second question; the large language model constructs the first thinking tree according to the second question, and the first thinking tree includes a root node and multiple child nodes; for each child node, the child node is spliced ​​with the root node, and is input as the third question into the large language model for scoring to obtain a scoring result; according to the scoring result, it is determined to retain the child node or prune the child node; repeatedly execute the processing of inputting the second question into the large language model until the preset stop condition is reached to obtain the second thinking tree; the content corresponding to the child node with the highest score in the second thinking tree is determined as the final reasoning result. Through this scheme, the tree structure is used to model the reasoning process, which is more in line with the characteristics of hierarchical thinking, making the reasoning process clearer, coherent, explainable and traceable, which can improve the flexibility and error correction ability of reasoning. At the same time, the thinking tree pruning mechanism is introduced in the reasoning process, which can be dynamically adjusted in the reasoning process to balance the breadth and depth of reasoning, thereby improving the accuracy of the large language model in the reasoning process. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0050] Figure 1 A flowchart of the reasoning method of the large language model based on the mind tree provided in this application;

[0051] Figure 2 A schematic structural diagram of a reasoning device based on a large language model of a thinking tree provided in this application;

[0052] Figure 3 A schematic structural diagram of a computer device provided for this application.

[0053] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0054] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0055] A large language model is a deep learning model trained with a large amount of text data that can generate natural language text or understand the meaning of language text. A large language model can handle a variety of natural language related problems, such as text classification, question answering, and dialogue.

[0056] Traditional large language models often lack logic and coherence when reasoning, and it is difficult to simulate the hierarchical structure of human thinking. When solving complex problems, humans usually break the problem into multiple sub-problems and gradually reason and draw conclusions in a certain logical order. This hierarchical and structured way of thinking helps improve the accuracy and efficiency of reasoning.

[0057] There are some existing ways to enhance the reasoning ability of large language models, including but not limited to: natural language processing methods that build domain knowledge graphs and combine domain knowledge graphs with large language models. Or, intelligent question-answering methods that guide large language models to reason by building question-based thinking chains.

[0058] However, the above methods still have certain shortcomings. Specifically, although the knowledge graph can provide rich external knowledge, it lacks explicit modeling and guidance of the reasoning process, and the threshold for building a domain knowledge graph is high, requiring a deep understanding of domain knowledge. It is difficult to build an effective and usable knowledge graph simply by using a large language model and other frameworks. Although the thinking chain can characterize the reasoning process, its linear chain structure is difficult to fully express the hierarchy and parallelism of complex reasoning, and because of its unidirectional nature, it is difficult to backtrack when problems arise in reasoning. Therefore, how to better guide the large language model to perform structured and logical reasoning is still a problem that needs to be solved urgently.

[0059] Based on this, the inventor of this application proposed a reasoning method for a large language model based on a thinking tree, which can guide the large language model to perform hierarchical reasoning by constructing a thinking tree, make full use of the advantages of the tree structure, improve the coherence and accuracy of reasoning, and realize an efficient and explainable reasoning process.

[0060] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0061] Figure 1 The flowchart of the reasoning method of the large language model based on the mind tree provided in this application is as follows. Figure 1 As shown, the reasoning method of the large language model based on the thinking tree of this embodiment may include:

[0062] S1, input the first question into the large language model to obtain the second question.

[0063] Among them, the first question is the original natural language question, and the second question is the question to be inferred after the large language model judges the first question.

[0064] Specifically, after the first question is input into the large language model, the large language model will preliminarily determine whether the first question is suitable for reasoning. When the first question is suitable for reasoning, the large language model will output the second question; when the first question is not suitable for reasoning, the large language model will output the result that the first question is not suitable for reasoning.

[0065] In a feasible implementation, the large language model can be based on a Transformer architecture of an encoder or decoder and is pre-trained on a massive text corpus in an unsupervised or self-supervised manner.

[0066] This step uses the large language model to make a preliminary understanding and judgment of the first question input by the user, and determines whether the first question is suitable and worth reasoning, which directly affects the efficiency and quality of the subsequent reasoning process.

[0067] When the large language model determines that the first question is suitable for reasoning, it obtains a suitable question to be reasoned and then enters S2.

[0068] S2, the large language model constructs a first thinking tree according to the second question, the first thinking tree includes a root node and multiple child nodes; wherein the root node is the second question, and each child node is a sub-question related to the second question.

[0069] In this step, after obtaining a suitable problem to be inferred, the large language model will automatically construct a first thinking tree according to the generation framework of the thinking tree. Among them, the first thinking tree includes a root node, an intermediate node and a leaf node. The root node represents the problem to be inferred, the intermediate node represents the sub-problem or intermediate conclusion in the reasoning process, and the leaf node represents the final conclusion or answer obtained by reasoning. In this embodiment, the intermediate node and the leaf node are called child nodes.

[0070] Specifically, when constructing the first thinking tree according to the second question, the second question is input into the large language model; the large language model generates multiple sub-questions related to the second question according to the second question; taking the second question as the root node and the multiple sub-questions as sub-nodes, the first thinking tree is constructed according to the preset thinking tree generation framework.

[0071] In one example, according to the preset thinking tree generation framework, the process of constructing the first thinking tree may include the following process:

[0072] 1. Generate the root node. The problem to be inferred is used as the root node of the thinking tree.

[0073] 2. Sub-question generation. Use the large language model to generate multiple related sub-questions as sub-nodes based on the root node question. Sub-questions can be generated in one of the following two ways:

[0074] (1) Use preset prompt words to guide the large language model to generate sub-questions. For example, prompt words can be "What information do we need to know to answer this question?", "How many steps can this question be broken down into?", etc., to guide the large language model to think about how to break down the problem from different angles.

[0075] (2) Use a preset temperature sampling strategy to control the diversity of sub-problems generated by the large language model. The higher the temperature, the more divergent and diverse the generated sub-problems; the lower the temperature, the more concentrated and conservative the generated sub-problems. By setting the temperature reasonably, the breadth and depth of the mind tree can be balanced.

[0076] 3. Recursive construction. For each generated child node, treat it as a new problem to be reasoned, recursively execute the above 1-2 process to generate the next layer of child nodes. Through recursive calls, the thinking tree can be constructed layer by layer from top to bottom.

[0077] 4. Recursive termination. Set recursive termination conditions, such as when the mind tree reaches the maximum depth, when the number or quality of generated sub-problems meets a certain threshold, etc. The purpose of setting termination conditions is to prevent the mind tree from becoming too large.

[0078] In a feasible implementation, when the large language model generates multiple sub-questions related to the second question based on the second question, it can specifically generate multiple sub-questions related to the second question based on the second question and preset prompt words, and then add child nodes to the root node through regularization technology and the node expansion module of the large language model.

[0079] Exemplarily, the template of the preset prompt words may be: “Original question: “{{root_question}}” Please generate a series of related sub-questions based on the above second question to help build a thinking tree and explore the problem in depth.

[0080] For example: Question 2: How to save electricity at home? Sub-question 1: What are the commonly used electrical appliances at home? Sub-question 2: Which appliances consume the most electricity? Sub-question 3: How to monitor the electricity consumption at home? Sub-question 4: When is the most electricity used? Sub-question 5: What habits lead to electricity waste?

[0081] Since how to select a large language model is the key to constructing the first mind tree, in one example, the large language model of this embodiment can select most of the available open source or closed source large language models. It can be understood that in the specific application process, the large language model can be selected according to actual needs, and this embodiment does not specifically limit the type of the large language model.

[0082] In another feasible implementation, when the large language model generates multiple sub-questions related to the second question based on the second question, it can specifically generate multiple sub-questions related to the second question based on the second question and a preset temperature sampling strategy. By introducing a preset temperature sampling strategy, the diversity and creativity of the generated content can be increased, and the first thinking tree can be prevented from converging to a suboptimal solution too early.

[0083] After introducing the preset temperature sampling strategy, the creativity of the generated content can be controlled by adjusting the temperature parameters. Specifically, the higher the temperature, the more diverse and unexpected the generated content is, and the lower the temperature, the more conservative and close to common sense the generated content is. In this way, users can use appropriate temperature parameters to achieve a balance between the quality and diversity of the generated content.

[0084] Since the construction of the thinking tree is a gradual and iterative process, the width and depth of the thinking tree will grow dynamically with the continuous expansion of nodes. Therefore, the node expansion module of the large language model can automatically decompose the second problem into sub-problems at multiple levels, and try to give solutions to each sub-problem, and finally form a complete reasoning path.

[0085] The large language model uses its powerful language understanding and generation capabilities to automatically build and expand the thinking tree, which can decompose complex problems into a series of relatively simple sub-problems and gradually infer the answers to the problems.

[0086] After constructing the first thinking tree according to the second question, enter S3:

[0087] S3: For each child node, concatenate the child node with the root node and input it into the large language model as the third question for scoring to obtain the scoring result.

[0088] In this step, after the large language model constructs the first thought tree according to the second question, the content of the subnode and the content of the root node are spliced ​​and input into the large language model, and the large language model evaluates the relevance and reliability score between the content of the subnode and the content of the root node, and retains the subnodes with scores exceeding the threshold. In this way, by putting the content of the subnode into the content of the root node for examination, the relevance and reliability of the content of the subnode and the content of the root node can be judged more accurately.

[0089] Specifically, the content of the child node is concatenated with the content of the root node and input into the large language model as the third question; the large language model scores the relevance and reliability between the content of the child node and the content of the root node, respectively, to obtain a relevance score and a reliability score; the relevance score and the reliability score are determined as the scoring results.

[0090] For example, let q represent the content of the root node, n i represents the i-th child node, c i Represents the content of the i-th child node, r i represents the relevance score between the content of the i-th child node and the content of the root node, t i represents the reliability score of the content of the ith child node, α represents the relevance threshold, and β represents the reliability threshold. Both the relevance threshold and the reliability threshold are set by the user.

[0091] For each child node n i Contents i , concatenate it with the content q of the root node to form a new input sequence s i :

[0092] s i =Concat(q,c i )

[0093] Among them, Concat(·) represents the concatenation operation.

[0094] Then, the sequence s i Input to the large language model (LLM) to get the relevance score r of the child node i and reliability score t i :

[0095] (r i ,t i )=LLM(s i )

[0096] Among them, LLM(·) represents the reasoning of the large language model, and the preset prompt words can be used to guide the large language model to output the relevance score and reliability score. For example, "Please evaluate the relevance of the following child nodes to the root node and the reliability of the content: original question: {{question}}; child node: {{child_node}}".

[0097] Exemplarily, the relevance score can be set to 0 to 5 points, with 0 indicating no relevance at all and 5 indicating very relevance; the reliability score can be set to 0 to 5 points, with 0 indicating no reliability at all and 5 indicating very reliability.

[0098] When evaluating a large language model, two numerical scores need to be given, and then the two score values ​​can be extracted using regularization technology.

[0099] After obtaining the relevance score and the reliability score, the relevance score is compared with the relevance threshold, and the result that the relevance score is less than the relevance threshold, the relevance score is greater than the relevance threshold, or the relevance score is equal to the relevance threshold is obtained. The reliability score is compared with the reliability threshold, and the result that the reliability score is less than the reliability threshold, the reliability score is greater than the reliability threshold, or the reliability score is equal to the reliability threshold is obtained.

[0100] The comparison result between the relevance score and the relevance threshold, and the comparison result between the reliability score and the reliability threshold are used as the scoring result. After the scoring result is obtained, the process proceeds to S4 to determine whether to retain or prune the child node according to the scoring result.

[0101] Furthermore, in order to improve the accuracy of the evaluation, more background information can be taken into consideration in practical applications. i Contents i It is concatenated with the entire problem description Q, the existing reasoning path P, and the content of the root node, and input into the large language model together:

[0102] s i =Concat(Q,P,c i )

[0103] In this way, the large language model can evaluate the sub-nodes with more comprehensive background information, which helps to further improve the accuracy of the scoring.

[0104] It should be noted that in practical applications, the relevance threshold and reliability threshold can be flexibly set according to specific problems and needs. It can be understood that higher relevance threshold and reliability threshold can improve the quality of the thinking tree, but may reduce the number of nodes and reduce the diversity of reasoning. On the contrary, lower relevance threshold and reliability threshold may reduce the quality of the thinking tree, but increase the number of nodes and improve the diversity of reasoning. Therefore, the setting of relevance threshold and reliability threshold needs to seek a balance between quality and quantity.

[0105] S4: Determine whether to retain or prune a child node based on the scoring result.

[0106] Among them, the scoring results may include a relevance score greater than a relevance threshold, and a reliability score greater than a reliability threshold; or, the scoring results may include a relevance score greater than a relevance threshold, and a reliability score less than or equal to a reliability threshold; or, the scoring results may include a relevance score less than or equal to a relevance threshold, and a reliability score greater than a reliability threshold; or, the scoring results may include a relevance score less than or equal to a relevance threshold, and a reliability score less than or equal to a reliability threshold.

[0107] In this step, if the relevance score in the scoring result is greater than the relevance threshold, and the reliability score is greater than the reliability threshold, the child node is determined to be retained. If the relevance score in the scoring result is less than or equal to the relevance threshold, or the reliability score is less than or equal to the reliability threshold, the child node is determined to be pruned.

[0108] Among them, the step of pruning the child node includes: judging whether the child node meets the preset pruning conditions; if the child node meets the preset pruning conditions, removing the subtree where the child node is located from the first thinking tree as a whole; if the child node does not meet the preset pruning conditions, retaining the subtree where the child node is located.

[0109] Specifically, in the backtracking process of the depth-first search, the first thinking tree is backtracked and pruned according to the relevance score and reliability score of the node and all its child nodes.

[0110] For example, in the process of depth-first search, after traversing the current node n i When all child nodes of the node n are ready to be traced back to their parent node, i Make pruning judgment.

[0111] The preset pruning condition may be, for example:

[0112]

[0113] Among them, PruneSubtree(n i )=1 indicates node n i The subtree where the branch is located is pruned, PruneSubtree(n i )=0 indicates node n i The subtree where the subtree is located is retained. i ) indicates that n i The subtree of the root node.

[0114] If node n i If the subtree where the node is located satisfies the pruning condition, that is, the relevance score or reliability score of all its child nodes is lower than the corresponding threshold, then node n i The subtree is removed from the first thought tree and the backtracking process continues.

[0115] It can be seen that by dynamically pruning the first thinking tree during the backtracking process, those subtrees that still do not meet the relevance and reliability requirements after deep exploration can be removed.

[0116] S5: Repeat S2 to S4 until a preset stop condition is reached to obtain a second thinking tree.

[0117] The second thinking tree is a thinking tree obtained by dynamically pruning the first thinking tree through the above S2 to S4.

[0118] The preset stop condition may be reaching a preset tree depth, reaching a preset number of nodes, or reaching a preset reasoning time. This step does not limit the specific preset stop condition, and it can be determined according to actual use requirements.

[0119] S6: Determine the content corresponding to the child node with the highest score in the second thinking tree as the final reasoning result.

[0120] In this step, the content corresponding to the highest-scoring sub-node in the second mind tree is output as the final reasoning result. After the reasoning process is completed, the sub-nodes of the second mind tree represent all possible candidate answers, and the content of the sub-node with the highest score and the most credible score is used as the final output, which completes a complete problem reasoning. If there are multiple sub-nodes with similar scores, the top few can also be listed for user reference. At the same time, the complete mind tree can also be displayed to the user so that he can understand the complete process and logical basis of reasoning.

[0121] The following is a specific example of using the application method to perform logical reasoning:

[0122] 1. Input the first question "Can all birds fly?" and convert it into the second question: "Based on the definition and characteristics of birds, determine whether all birds have the ability to fly."

[0123] 2. Based on the second question, construct the first thinking tree:

[0124] Root node: Based on the definition and characteristics of birds, determine whether all birds have the ability to fly.

[0125] Subnode 1: What are the typical characteristics of birds?

[0126] Subnode 2: What are some famous flightless birds in the world?

[0127] Subnode 3: What are the reasons for the differences in birds’ flying abilities?

[0128] 3. Connect the sub-nodes and the root node, input the model score, retain the high-molecular-weight nodes (such as 1 and 2), and prune the low-molecular-weight nodes (such as 3).

[0129] 4. Based on the retained child nodes, further expand the thinking tree:

[0130] Subnode 1-1: What is the relationship between bird wing structure and flight ability?

[0131] Subnode 1-2: How do the skeletal and muscle characteristics of birds affect flight?

[0132] Subnode 2-1: Why did the penguin lose the ability to fly?

[0133] Subnode 2-2: Why can’t ostriches fly?

[0134] 5. Repeat steps 2-4 until the preset stop condition is reached to obtain the second thinking tree.

[0135] 6. The sub-node content with the highest score may be:

[0136] Subnode 2-1: Why did the penguin lose the ability to fly?

[0137] Subnode 2-2: Why can’t ostriches fly?

[0138] 7. After arranging these contents, output the final inference results:

[0139] "Not all birds can fly. Although most birds have the ability to fly, there are exceptions. Penguins have evolved their wings into flipper-like structures due to living in water for a long time. Although they have wings, they cannot fly. Ostriches are huge and their wings are degenerate and cannot support flying, but their legs are strong and they are good at walking and running. This shows that the flying ability of birds varies depending on the species and living environment."

[0140] The reasoning method of the large language model based on the thinking tree provided by the present application relates to the field of artificial intelligence technology. The method obtains the second question by inputting the first question into the large language model; the large language model constructs the first thinking tree according to the second question, and the first thinking tree includes a root node and multiple child nodes; for each child node, the child node is spliced ​​with the root node, and is input as the third question into the large language model for scoring to obtain a scoring result; according to the scoring result, it is determined to retain the child node or prune the child node; repeatedly execute the processing of inputting the second question into the large language model until the preset stop condition is reached to obtain the second thinking tree; the content corresponding to the child node with the highest score in the second thinking tree is determined as the final reasoning result. Through this scheme, the tree structure is used to model the reasoning process, which is more in line with the characteristics of hierarchical thinking, making the reasoning process clearer, coherent, explainable and traceable, which can improve the flexibility and error correction ability of reasoning. At the same time, the thinking tree pruning mechanism is introduced in the reasoning process, which can be dynamically adjusted in the reasoning process to balance the breadth and depth of reasoning, thereby improving the accuracy of the large language model in the reasoning process.

[0141] Figure 2 This is a schematic structural diagram of the reasoning device based on the large language model of the thinking tree provided in this application. Figure 2As shown, the reasoning device 200 based on the large language model of the thinking tree provided in this embodiment may include: an input module 210, a construction module 220, a splicing module 230, a first determination module 240, a trigger module 250 and a second determination module 260.

[0142] Among them, the input module 210 is used to input the first question into the large language model to obtain the second question; the first question is the original natural language question, and the second question is the question to be inferred after the large language model judges the first question.

[0143] The construction module 220 is used for the large language model to construct a first thinking tree according to the second question, and the first thinking tree includes a root node and multiple child nodes; wherein the root node is the second question, and each child node is a sub-question related to the second question.

[0144] The concatenation module 230 is used to concatenate each sub-node with the root node, and input the concatenation as the third question into the large language model for scoring to obtain a scoring result.

[0145] The first determination module 240 is used to determine whether to keep a child node or to prune a child node according to the scoring result.

[0146] The trigger module 250 is used to trigger the processing of the construction module 220 until a preset stop condition is reached to obtain a second thinking tree.

[0147] The second determination module 260 is used to determine the content corresponding to the sub-node with the highest score in the second thinking tree as the final reasoning result.

[0148] In one embodiment, the input module 210 is specifically used for the large language model to judge whether the first question is suitable for reasoning; when the first question is suitable for reasoning, the second question is output; when the first question is not suitable for reasoning, the result that the first question is not suitable for reasoning is output.

[0149] In one embodiment, the construction module 220 is specifically used to input the second question into the large language model; the large language model generates multiple sub-questions related to the second question based on the second question; with the second question as the root node and multiple sub-questions as child nodes, a first thinking tree is constructed according to a preset thinking tree generation framework.

[0150] In one embodiment, when generating a plurality of sub-questions related to the second question, the construction module 220 is specifically configured to enable the large language model to generate a plurality of sub-questions related to the second question according to the second question and a preset prompt word.

[0151] In one embodiment, when generating a plurality of sub-questions related to the second question, the construction module 220 is specifically configured to enable the large language model to generate a plurality of sub-questions related to the second question according to the second question and a preset temperature sampling strategy.

[0152] In one embodiment, the splicing module 230 is specifically used to splice the content of the child node with the content of the root node, and input it into the large language model as the third question; the large language model scores the relevance and reliability between the content of the child node and the content of the root node, respectively, to obtain a relevance score and a reliability score; the relevance score and the reliability score are determined as the scoring results.

[0153] In one embodiment, the first determination module 240 is specifically used to determine to retain the child node when the relevance score in the scoring result is greater than the relevance threshold and the reliability score is greater than the reliability threshold; and to determine to prune the child node when the relevance score in the scoring result is less than or equal to the relevance threshold, or the reliability score is less than or equal to the reliability threshold.

[0154] In one embodiment, when determining to prune a child node, the first determination module 240 is specifically used to determine whether the child node meets a preset pruning condition; if the child node meets the preset pruning condition, the subtree where the child node is located is removed from the first thinking tree as a whole; if the child node does not meet the preset pruning condition, the subtree where the child node is located is retained.

[0155] The reasoning device based on the large language model of the thinking tree provided in this embodiment can be used to execute the reasoning method based on the large language model of the thinking tree in any of the aforementioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0156] Figure 3 This is a schematic structural diagram of the computer device provided in this application. Figure 3 As shown, the computer device may specifically include a transceiver 301, a processor 302, and a memory 303. The transceiver 301 is used to receive a first question input, and the memory 303 stores computer execution instructions; the processor 302 executes the computer execution instructions stored in the memory 303 to implement the reasoning method based on the large language model of the mind tree in the above embodiment.

[0157] This embodiment provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the reasoning method of the large language model based on the thinking tree in the above embodiment.

[0158] This embodiment also provides a computer program product, including a computer program, which, when executed by a processor, implements the reasoning method of the large language model based on the thinking tree provided in any of the above embodiments.

[0159] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A reasoning method for a large language model based on a mind tree, characterized in that: The method comprises: S1, inputting a first question into a large language model to obtain a second question; the first question is an original natural language question, and the second question is a question to be inferred obtained after the large language model judges the first question; S2, the large language model constructs a first thought tree according to the second question, the first thought tree comprising a root node and a plurality of child nodes; wherein the root node is the second question, and each of the child nodes is a sub-question related to the second question; S3, for each of the sub-nodes, concatenate the sub-node with the root node, and input the concatenated sub-node into the large language model as the third question for scoring, thereby obtaining a scoring result; S4, determining whether to retain the child node or prune the child node according to the scoring result; S5, repeatedly executing S2 to S4 until a preset stop condition is reached, thereby obtaining a second thinking tree; S6, determining the content corresponding to the sub-node with the highest score in the second thinking tree as the final reasoning result; The step of concatenating the child node with the root node and inputting the third question into the large language model for scoring to obtain a scoring result includes: splicing the content of the child node with the content of the root node, and inputting the result as the third question into the large language model; The large language model scores the relevance and reliability between the content of the child node and the content of the root node, respectively, to obtain a relevance score and a reliability score; The relevance score and the reliability score are determined as the scoring result.

2. The method according to claim 1, characterized in that The step of inputting the first question into the large language model to obtain the second question includes: Inputting the first question into the large language model; The large language model determines whether the first question is suitable for reasoning; When the first question is suitable for reasoning, outputting the second question; When the first question is not suitable for reasoning, a result that the first question is not suitable for reasoning is output.

3. The method according to claim 1, characterized in that The large language model constructs a first thinking tree according to the second question, including: The large language model generates a plurality of sub-questions related to the second question according to the second question; The first thinking tree is constructed by taking the second question as the root node and the plurality of sub-questions as sub-nodes according to a preset thinking tree generation framework.

4. The method according to claim 3, characterized in that The large language model generates a plurality of sub-questions related to the second question according to the second question, including: The large language model generates a plurality of sub-questions related to the second question according to the second question and preset prompt words.

5. The method according to claim 3, characterized in that: The large language model generates a plurality of sub-questions related to the second question according to the second question, including: The large language model generates a plurality of sub-questions related to the second question according to the second question and a preset temperature sampling strategy.

6. The method according to claim 1, characterized in that Determining whether to retain the child node or prune the child node according to the scoring result includes: In the case where the relevance score in the scoring result is greater than a relevance threshold, and the reliability score is greater than a reliability threshold, determining to retain the child node; When the relevance score in the scoring result is less than or equal to the relevance threshold, or when the reliability score is less than or equal to the reliability threshold, it is determined to prune the child node.

7. The method according to claim 6, characterized in that Pruning the child node, comprising: Determine whether the child node meets the preset pruning condition; When the child node satisfies the preset pruning condition, the subtree where the child node is located is removed as a whole from the first thinking tree; When the child node does not satisfy the preset pruning condition, the subtree where the child node is located is retained.

8. A reasoning device based on a large language model of a thinking tree, characterized in that: The device comprises: An input module, configured to input a first question into a large language model to obtain a second question; the first question is an original natural language question, and the second question is a question to be inferred obtained after the large language model judges the first question; A construction module, used for the large language model to construct a first thinking tree according to the second question, wherein the first thinking tree includes a root node and a plurality of child nodes; wherein the root node is the second question, and each of the child nodes is a sub-question related to the second question; A concatenation module, configured to concatenate each of the sub-nodes with the root node, and input the concatenation as a third question into the large language model for scoring, to obtain a scoring result; A first determination module, used to determine whether to retain the child node or prune the child node according to the scoring result; A trigger module, used to trigger the processing of the building module until a preset stop condition is reached to obtain a second thinking tree; A second determination module, configured to determine the content corresponding to the sub-node with the highest score in the second thinking tree as the final reasoning result; The splicing module is specifically used to: splice the content of the child node with the content of the root node, and input it into the large language model as a third question; the large language model scores the relevance and reliability between the content of the child node and the content of the root node, respectively, to obtain a relevance score and a reliability score; and determine the relevance score and the reliability score as the scoring result.

9. A computer device, characterized in that: include: A transceiver, a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the reasoning method based on the large language model of the thinking tree as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Relay protection setting value checking method, device and equipment

    CN116646891A

  • Automatic service generation method and device, computer equipment and storage medium

    CN116976640A