Question answering method based on large language model, model training method and equipment
By disassembling complex problems into target semantic graphs and using large language models to answer sub-problems, the problem of difficult performance improvement of large language models in complex problem-solving tasks is solved, and the accuracy and efficiency of answers are improved.
Patent Information
- Application Number
- CN202311493357.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-09
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2043-11-09
AI Technical Summary
The performance improvement curve of large language models in complex question-solving tasks tends to flatten, making it difficult to effectively improve their performance in complex question-solving tasks.
By disassembling the pending target problem into a target semantic graph, including sub-problems and sub-problems relationships, a large language model is used to answer sub-problems in the target semantic graph, and the answer to the target problem is determined based on the answers to the sub-problems.
The performance and accuracy of large language models in complex problem-solving tasks are improved, and the structure of nonlinear thinking graphs can better match the human thinking process, reducing the instability problem in the thinking chain prompt method.
Smart Images

Figure CN117932008B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to the technical fields of large language models, natural language processing, etc. Specifically, it relates to a question-answering method based on a large language model, a model training method, and a device. Background Art
[0002] A large language model (LLM) is a generative language model characterized by its large size, large number of parameters and training data. By using more parameters and larger data sets for training, its performance and sample efficiency on various downstream tasks are effectively improved.
[0003] However, the study found that as the number of model parameters increases, the performance improvement curve in multi-step complex question answering tasks tends to be flat. Therefore, it is very important to improve the performance of large language models in complex question answering tasks. Summary of the invention
[0004] The present invention provides a question-answering method based on a large language model, a model training method, and a device.
[0005] According to one aspect of the present disclosure, a question answering method based on a large language model is provided, comprising:
[0006] Using a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships;
[0007] A large language model is used to answer the sub-questions in the target semantic graph to obtain the answers to the sub-questions, and the answer to the target question is determined based on the answers to the sub-questions.
[0008] According to one aspect of the present disclosure, a method for training a large language model is provided, comprising:
[0009] Obtaining a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions and sub-question relationships in the sample question;
[0010] Inputting the sample question into the first pre-trained language model to obtain a candidate semantic graph;
[0011] Inputting the sample question and the candidate semantic graph into a pre-trained second largest language model to obtain the quality of the candidate semantic graph;
[0012] A target semantic graph is selected according to the quality of the candidate semantic graph, and the first large language model is fine-tuned according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and the second large language model is fine-tuned to obtain a feedback model.
[0013] According to one aspect of the present disclosure, a question-answering device based on a large language model is provided, comprising:
[0014] A problem decomposition module is used to use a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships;
[0015] The question answering module is used to use a large language model to answer sub-questions in the target semantic graph to obtain answers to the sub-questions, and determine the answer to the target question based on the answers to the sub-questions.
[0016] According to one aspect of the present disclosure, a large language model training device is provided, comprising:
[0017] A sample semantic graph module is used to obtain a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions in the sample question and sub-question relationships;
[0018] A candidate semantic graph module, used for inputting the sample question into a pre-trained first language model to obtain a candidate semantic graph;
[0019] A quality module, used for inputting the sample question and the candidate semantic graph into a pre-trained second language model to obtain the quality of the candidate semantic graph;
[0020] A model fine-tuning module is used to select a target semantic graph according to the quality of the candidate semantic graph, and to fine-tune the first large language model according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and to fine-tune the second large language model to obtain a feedback model.
[0021] According to another aspect of the present disclosure, there is provided an electronic device, the electronic device comprising:
[0022] at least one processor; and
[0023] a memory communicatively connected to the at least one processor; wherein,
[0024] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by any embodiment of the present disclosure.
[0025] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by any embodiment of the present disclosure.
[0026] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method provided according to any embodiment of the present disclosure is implemented.
[0027] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0029] Figure 1a is a flowchart of a question-answering method based on a large language model provided according to an embodiment of the present disclosure;
[0030] Figure 1b is a schematic diagram of problem decomposition provided according to an embodiment of the present disclosure;
[0031] Figure 2a is a flowchart of another question-answering method based on a large language model provided according to an embodiment of the present disclosure;
[0032] Figure 2b It is a schematic diagram of problem decomposition based on a large language model provided according to an embodiment of the present disclosure;
[0033] Figure 2c is a schematic diagram of a target semantic graph provided according to an embodiment of the present disclosure;
[0034] Figure 2d is a schematic diagram of a target problem solving stage provided according to an embodiment of the present disclosure;
[0035] Figure 3a is a flowchart of another question-answering method based on a large language model provided according to an embodiment of the present disclosure;
[0036] Figure 3b is a schematic diagram of a target problem solving stage provided according to an embodiment of the present disclosure;
[0037] Figure 3c It is a schematic diagram of the principle of a question-answering method based on a large language model provided according to an embodiment of the present disclosure;
[0038] Figure 4 is a flowchart of a large language model training method provided according to an embodiment of the present disclosure;
[0039] Figure 5 is a structural diagram of a question-answering device based on a large language model provided according to an embodiment of the present disclosure;
[0040] Figure 6 is a structural schematic diagram of a large language model training device provided according to an embodiment of the present disclosure;
[0041] Figure 7 It is a block diagram of an electronic device used to implement the question-answering method based on a large language model or the training method of a large language model of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] Figure 1a 1 is a flowchart of a question-answering method based on a large language model according to an embodiment of the present disclosure. The method is applicable to the case of performing nonlinear question answering based on a large language model. The method can be executed by a question-answering device based on a large language model, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 1a As shown, the question answering method based on the large language model of this embodiment may include:
[0043] S101, using a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships;
[0044] S102, using a large language model to answer sub-questions in the target semantic graph to obtain answers to the sub-questions, and determining an answer to the target question based on the answers to the sub-questions.
[0045] In the present disclosure, the problem solving process may include a problem breaking phase and a problem solving phase (also referred to as a problem solving phase). In the problem breaking phase, the problem may be broken down into a fine-grained semantic graph (also referred to as a mind map or a problem computation graph) by prompt learning or fine-tuning, which may serve as a guiding signal for the problem solving phase.
[0046] This disclosure proposes a semantic graph technology for the problem decomposition stage, and uses a large language model to decompose the target problem to be processed into a target semantic graph, that is, to decompose the problem into fine-grained sub-problems and the relationship between different sub-problems. The nonlinear structure of the semantic graph matches the nonlinear thinking process of humans. Compared with the continuous linear relationship in the thought chain, it can solve the instability problem caused by different choices in the thought chain prompt method, improve the accuracy of problem answering, and thus improve the problem answering quality of the large language model, so that the large language model can provide high-quality question-answering services in the fields of education, tourism consultation, medical consultation, etc.
[0047] In the present disclosure, an input target text may be obtained as a target question to be processed; an input target speech may also be obtained, and the target speech may be recognized to obtain a target text as a target question to be processed. The large language model may decompose the target text based on the semantic relationship in the target text to obtain a target semantic graph.
[0048] The target semantic graph is a nonlinear tree structure, including at least two branches. In the problem decomposition stage, the large language model can be used to decompose the target problem to obtain sub-problems and sub-problem relationships in the target problem, and the sub-problems are used as child nodes of the target semantic graph. The target problem is used as the root node of the target semantic graph, and the topological relationship between nodes is constructed based on the sub-problem relationship. Figure 1b , taking the target question of which movie A or movie B will be released first as an example, the problem can be decomposed as follows: Sub-question Q1-When will movie A be released? Sub-question Q2-When will movie B be released? Sub-question Q3-Which one will be released first, Q1 or Q2? Accordingly, the root node in the target semantic graph is the target question, the parent node of sub-nodes Q1 and Q2 is the root node, and the parent node of sub-node Q3 is sub-node Q1 and sub-node Q2.
[0049] It should be noted that the graph structure of the target semantic graph can be described in natural language, that is, the target semantic graph can be represented by the child nodes and the parent nodes of the child nodes described in natural language. Taking the target question of which movie A or movie B will be released first as an example, the target semantic graph described in natural language can be as follows: Child node 1: Q1-When will movie A be released? The parent node is the root node; Child node 2: Q2-When will movie B be released? The parent node is the root node; Child node 3: Q3-Compare Q1 and Q2, which one will be released first? The parent nodes are child node 1 and child node 2.
[0050] In the problem-solving phase, the sub-problems are solved and traversed based on the target semantic graph. That is, the sub-problems are traversed based on the sub-problem relationships of the target semantic graph, and the large language model is used to solve the sub-problems currently being traversed to obtain the answers to the sub-problems. The answer to the target question is obtained based on the answers to the sub-problems. Figure 1b , the answer to sub-question Q3 can be used as the answer to the target question.
[0051] The technical solution provided by the embodiment of the present disclosure decomposes the target problem to be processed into a target semantic graph and solves the problem based on the target semantic graph. The nonlinear topological relationship between the sub-nodes in the target semantic graph can better reflect the problem solving logic, and solving the problem based on the sub-problem relationship in the target semantic graph improves the accuracy of the target problem solution, thereby improving the quality of the large language model's solution to complex problems.
[0052] In an optional implementation, the root node of the target semantic graph is the target problem, the child nodes of the target semantic graph are subproblems, and the subproblem relationships are obtained based on the parent nodes of the child nodes.
[0053] The nonlinear topological relationship of the target semantic graph is consistent with the nonlinear thinking process. By solving the target problem based on the target semantic graph, the quality of the solution to the target problem is improved.
[0054] In an optional implementation manner, different sub-questions are different, and the answer to the last sub-question in the answer sequence is the answer to the target question.
[0055] By making different sub-questions different from each other, that is, the sub-questions in the target semantic graph are different from each other, the structure of the target semantic graph can be simplified, thereby improving the efficiency of problem solving based on the target semantic graph. In addition, by controlling the answer to the last sub-question in the answering sequence to be consistent with the answer to the target question, the answer to the last sub-question can be directly used as the answer to the target question without introducing other processing, thereby further improving the quality of problem solving.
[0056] Figure 2a is a flowchart of another question-answering method based on a large language model provided according to an embodiment of the present disclosure. Figure 2a The question answering method based on the large language model of this embodiment may include:
[0057] S201, inputting the target problem to be processed into a problem decomposition model to obtain at least two candidate semantic graphs;
[0058] S202, inputting the target question and the candidate semantic graph into a feedback model to obtain the quality of the candidate semantic graph;
[0059] S203, selecting the target semantic graph from the candidate semantic graphs according to quality;
[0060] The target semantic graph includes sub-problems and sub-problem relationships in the target problem; the problem decomposition model and the feedback model both belong to a large language model.
[0061] S204, using a large language model to answer sub-questions in the target semantic graph to obtain answers to the sub-questions, and determining an answer to the target question based on the answers to the sub-questions.
[0062] Among them, the question decomposition model and the feedback model can be obtained by prompting learning or fine-tuning the generative large language model. Figure 2b In the problem decomposition stage, the target problem to be processed can be input into the problem decomposition model to obtain at least two candidate semantic graphs. For each candidate semantic graph, the target problem and the candidate semantic graph are input into the feedback model to obtain the quality of the candidate semantic graph; the candidate semantic graph with the highest quality can be selected as the target semantic graph.
[0063] By using a problem decomposition model to decompose the target problem to obtain at least two candidate semantic graphs, using a feedback model to provide quality feedback on the candidate semantic graphs, and selecting a target semantic graph based on the quality of each candidate semantic graph, the quality of the target semantic graph can be improved, thereby improving the accuracy of subsequent question answering based on the target semantic graph.
[0064] In the question answering stage, the question answering model can be used to answer the sub-questions in the target semantic graph to obtain the answers to the sub-questions, and the answer to the last sub-question is used as the answer to the target question. The question answering model can also be obtained by prompting learning or fine-tuning the generative large language model. It should be noted that the question decomposition model and the question stage model can be constructed based on the same generative large language model or based on different generative large language models.
[0065] In an optional implementation, the use of a large language model to answer sub-problems in a target semantic graph to obtain answers to the sub-problems includes: obtaining at least two sub-problems in the target question and parent question identifiers of the sub-problems based on question relationships in the target semantic graph; inputting the at least two sub-problems and the parent question identifiers of the sub-problems into a question answering model to obtain answers to the sub-problems; wherein the question answering model belongs to the large language model.
[0066] The question answering stage can be divided into a step-by-step mode and a non-step-by-step mode. In the non-step-by-step mode, the input of the question answering model is the target question and each sub-question in the target semantic graph, and the parent question identifier of the sub-question. Through prompt learning, the large language model is guided to answer each sub-question in sequence until the answer to the last sub-question is obtained as the answer to the target question, thereby solving the target question.
[0067] Specifically, based on the question relationship in the target semantic graph, at least two sub-questions in the target question and the parent question identifiers of the sub-questions are obtained; the sub-questions can be sorted according to the sub-question relationship in the target semantic graph, and the target question, the sorted sub-questions, and the parent question identifiers of the sub-questions are input into the question answering model to obtain the answers to the sub-questions; the answer to the last sub-question can be used as the answer to the target question. The use of the non-step-by-step mode can improve the efficiency of question answering for large language models.
[0068] Combination Figure 2c and Figure 2d, take the answer to the following target question in a non-step-by-step mode as an example: Zhang San went shopping, he bought a pair of shoes for 200 yuan, with a 30% discount, and bought two shirts for 80 yuan. When checking out, the cashier said there was an additional 5% discount. How much did he spend after all the discounts? After disassembly, the target semantic graph may include the following: Child Node 1-How much is the discount for a pair of shoes? Its parent node is the root node; Child Node 2-How much did he spend on a pair of shoes? Its parent node is the root node and Child Node 1; Child Node 3: How much did he spend on two shirts? Its parent node is the root node; Child Node 4: What is his initial purchase cost? Its parent node is the root node, Child Node 2, and Child Node 3; Child Node 5-How much extra discount did he get? Its parent node is the root node and Child Node 4; Child Node 6-How much did he spend after all the discounts? The parent node is the root node, Child Node 4, and Child Node 5.
[0069] refer to Figure 2d , the answer results based on the target semantic graph may include the following: subnode 1-according to the target question, the discount for a pair of shoes is 200×30%=60 yuan; subnode 2-according to the target question and the discount for a pair of shoes is 200×30%=60 yuan, it can be known that he spent 200-60=140 yuan to buy a pair of shoes; subnode 3-according to the target question, he spent 2×80=160 yuan to buy two shirts; subnode 4-according to the target question, he spent 140 yuan to buy a pair of shoes, and he spent 160 yuan to buy two shirts, it can be known that his initial purchase cost was 140+160=300 yuan; subnode 5-according to the target question and his initial purchase cost was 300 yuan, it can be known that he got an additional discount of 300×5%=15 yuan; subnode 6-according to the target question, his initial purchase cost was 300 yuan, he got an additional discount of 15 yuan, it can be known that after all discounts he spent 300-15=285 yuan. In other words, the answer to the target question is 285 yuan.
[0070] The technical solution provided by the embodiment of the present disclosure can improve the quality of the target semantic graph by using the problem decomposition model and the feedback model to cooperate with each other to decompose the target problem; and can improve the problem answering efficiency by using a non-step-by-step mode to answer the target problem based on the target semantic graph.
[0071] Figure 3a is a flowchart of another question-answering method based on a large language model provided according to an embodiment of the present disclosure. Figure 3a The question answering method based on the large language model of this embodiment may include:
[0072] S301, using a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships;
[0073] S302, for each sub-problem, obtaining the parent problem of the sub-problem based on the problem relationship in the target semantic graph;
[0074] S303, if the parent question of the sub-question is a sub-question, obtaining the identifier of the parent question and the answer to the parent question;
[0075] S304, inputting the sub-question, the identifier of the parent question and the answer to the parent question into a question answering model to obtain an answer to the sub-question; wherein the question answering model belongs to a large language model;
[0076] S305, determining the answer to the target question according to the answers to the sub-questions.
[0077] In the problem-solving stage, when the problem is solved in a step-by-step mode, the sub-problem solution traversal scheduling is performed based on the target semantic graph; for the currently traversed sub-problem, the parent problem of the sub-problem is obtained; it is determined whether the parent problem is the target problem or other sub-problems (also called pre-order sub-problems). If the parent problem is other sub-problems, the identification information of the parent problem and the answer to the parent problem are obtained, and the identification information of the currently traversed sub-problem, the identification information of the parent problem and the answer to the parent problem are input into the problem-solving model to obtain the answer to the currently traversed sub-problem. If the parent problem is the target problem, the identification information of the currently traversed sub-problem and the parent problem are input into the problem-solving model to obtain the answer to the currently traversed sub-problem. It should be noted that the parent problem can include both the target problem and other sub-problems, and the identification information of the target problem, other sub-problems, and the answers to other sub-problems can all be input into the large language model. In the step-by-step solution mode, the identification information of the parent question and the answer to the parent question are input into the question-solving model as the context of the currently traversed sub-question, so that irrelevant and interfering information is eliminated from the target question, and the solution to the sub-question is limited to a specific context, thereby improving the efficiency and accuracy of sub-question solution.
[0078] Combination Figure 3b , take the following target problem as an example: Wang Er bought a dozen lemons and gave 1 / 4 to his neighbor. How many lemons does Wang Er have left? Sub-problem 1 in the target semantic graph is: How many lemons did Wang Er buy? Parent node: target problem; after solving sub-problem 1, the answer is: Wang Er bought a dozen lemons, which means he bought 12 lemons; Sub-problem 2: How many lemons did Wang Er give to his neighbor? Parent node: target problem, sub-problem 1; after solving sub-problem 2, the answer is: Wang Er gave 1 / 4 to his neighbor. Since 1 / 4 of 12 is equal to 3, Wang Er gave his neighbor 3 lemons; Sub-problem 3 is: How many lemons does Wang Er have left? Parent nodes are target problem, sub-problem 1 and sub-problem 2; after solving sub-problem 3, the answer is: Wang Er has 12-3=9 lemons left.
[0079] In an optional implementation, the method further includes: determining the order of answering each sub-problem based on the topological order between the sub-nodes in the target semantic graph.
[0080] The sub-problems are solved based on the topological order between the child nodes in the target semantic graph. The parent node is solved before the child node. By solving each sub-problem in topological order, the answer of the parent node can be obtained first, and the answer of the parent node is used to solve the child node.
[0081] The technical solution provided by the embodiment of the present disclosure, in the process of answering each sub-question, limits the answer to the sub-question to its relevant context by using the identification information and answer of the parent node as its relevant context, thereby eliminating interference information in the answering process and improving the efficiency and accuracy of answering the sub-questions.
[0082] In an optional implementation, the use of a large language model to answer sub-problems in a target semantic graph to obtain answers to the sub-problems includes: inputting the sub-problems in the target semantic graph into the large language model to determine the type of knowledge to which the sub-problems belong; and calling a knowledge base associated with the knowledge type to answer the sub-problems.
[0083] In the process of answering sub-questions, the large language model can also be used to determine whether the sub-question belongs to a knowledge-based question. If so, the knowledge type output by the large language model is obtained, and the knowledge base associated with the knowledge type is called to answer the sub-question. The knowledge base is used to store professional knowledge, including but not limited to dictionaries, knowledge graphs, works, pre-set rules, etc. By introducing the knowledge base to answer sub-questions of the knowledge type, it is possible to reduce knowledge errors and factual errors in the process of answering sub-questions, thereby improving the accuracy of the answers.
[0084] Figure 3c is a schematic diagram of the principle of a question-answering method based on a large language model provided according to an embodiment of the present disclosure, with reference to Figure 3c , obtain the target problem to be processed, input the target problem to be processed into the problem decomposition model to obtain the target semantic graph, schedule the solution of sub-problems based on the target semantic graph, and for the current sub-problem to be scheduled, obtain the identification information of the previous sub-problem and the answer to the previous sub-problem, input the current sub-problem, the identification information of the previous sub-problem, and the answer to the previous sub-problem into the problem solving model to obtain the answer to the current sub-problem; in the process of solving the current sub-problem, the context or knowledge base can be combined to further improve the accuracy of the answer; the answer to the last sub-problem is used as the answer to the target problem.
[0085] In addition, the efficiency and accuracy of problem decomposition and problem solving can be further improved by processing the prompts of the problem decomposition model and the problem node model.
[0086] Among them, the prompt of the problem decomposition model may include the following strategies: the problem should be decomposed as detailed as possible; overlap between different sub-problems should be avoided; when generating a new sub-problem (i.e., sub-node), all known sub-problems related to it should be identified and used as parent nodes of the new sub-problem; new variables or equations can be set at any time during the problem decomposition process.
[0087] Among them, the prompt of the question-solving model may include the following strategies: the sub-problems should be solved in the topological order of the target semantic graph, that is, sub-problems 1, 2, 3... should be solved in sequence; when solving each sub-problem, the parent node should be relied on to obtain the answer of the parent node to limit the solution of the sub-problem to its relevant context; the answer to the last sub-problem is the answer to the target question.
[0088] Figure 4 1 is a flow chart of a method for training a large language model according to an embodiment of the present disclosure. The method is applicable to the case where a large language model is fine-tuned and trained to have the ability to solve problems. The method can be executed by a training device for a large language model, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 4 As shown, the training method of the large language model of this embodiment may include:
[0089] S401, obtaining a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions in the sample question and sub-question relationships;
[0090] S402, inputting the sample question into a pre-trained first language model to obtain a candidate semantic graph;
[0091] S403, inputting the sample question and the candidate semantic graph into a pre-trained second language model to obtain the quality of the candidate semantic graph;
[0092] S404, selecting a target semantic graph according to the quality of the candidate semantic graph, and fine-tuning the first large language model according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and fine-tuning the second large language model to obtain a feedback model.
[0093] Among them, both the first largest language model and the second largest language model can be generative large language models, and the second largest language model can be obtained by adding a fully connected layer to the first largest language model. When the problem decomposition model and the feedback model are obtained by fine-tuning the generative large language model, the sample question and the sample semantic graph marked by the sample question can be obtained, and the sample semantic graph includes sub-questions and sub-question relationships in the sample question. Optionally, the root node of the sample semantic graph is the sample question, the child nodes of the sample semantic graph are sub-questions, and the sub-question relationship is obtained according to the parent node of the child node; and, different sub-questions in the sample semantic graph are different, and the answer to the last sub-question is the answer to the sample question.
[0094] Specifically, the sample question can be input into the pre-trained first language model to obtain the candidate semantic graph output by the first language model; for each candidate semantic graph, the sample question and the candidate semantic graph can be input into the pre-trained second language model to obtain the quality of the second language model output; the target semantic graph is selected according to the quality of each candidate semantic graph, and the loss function is constructed according to the target semantic graph and the sample semantic graph, and the first language model and the second language model are fine-tuned using the loss function to obtain the problem decomposition model and the feedback model. By fine-tuning the problem decomposition model and the problem answering model based on the pre-trained first language model and the second language model, the huge time-consuming process of training the model from scratch can be avoided, thereby improving the construction efficiency of the problem decomposition model and the problem answering model.
[0095] The technical solution provided by the embodiment of the present disclosure can improve the construction efficiency of the problem decomposition model and the problem answering model by using sample questions and annotated sample semantic graphs to fine-tune the pre-trained first language model and the second language model to obtain the problem decomposition model and the problem answering model.
[0096] In addition, the large language model can be given the ability to solve problems by prompt learning to obtain a problem solving model. The following is an example of a few shot of prompt learning:
[0097] Please refer to the following example to break down the problem.
[0098] Target Question:
[0099] Zhang San went shopping. He bought a pair of shoes for 200 yuan with a 30% discount and two shirts for 80 yuan. When checking out, the cashier said there was an additional 5% discount. How much did he spend after all the discounts?
[0100] 《Solution steps》:
[0101] Child node 1: What is the discount for a pair of shoes? Its parent node is the root node
[0102] Child Node 2: How much did he spend on a pair of shoes? Its parent node is the root node and child node 1
[0103] Child node 3: How much did he spend on the two shirts? Its parent node is the root node;
[0104] Child node 4: What is his initial purchase cost? Its parent node is the root node, child node 2 and child node 3;
[0105] Child Node 5 - How much extra discount did he get? Its parent node is the root node and child node 4;
[0106] Child Node 6 - How much did he spend after all discounts? The parent node is the root node, child node 4 and child node 5.
[0107] The related technology performs complex problem-solving tasks through a two-stage prompt learning scheme. The first stage is to disassemble the problem from top to bottom, and the second stage is to solve the problem from bottom to top. When solving each sub-problem, it can be regarded as a process of thinking chain prompt learning. In this way, the related technology implements the corresponding "solution outline" before solving the problem. Using this "solution outline" to guide problem solving can alleviate the instability problem caused by different example selections in the thinking chain prompt method and improve the accuracy of problem solving. However, this thinking process is still linear. The human thinking process is often nonlinear, not a simple continuous chain of thinking. And when solving sub-problems, the related technology does not limit the context to the information related to it, but all the context information, which will lead to interference information and affect the quality of the final problem solution.
[0108] In view of the limitations of related technologies, the present disclosure proposes a semantic graph technology, which first decomposes a given problem into fine-grained sub-problems and models the relationship between different sub-problems. Then, the decomposed sub-problems are answered in sequence until the entire problem is solved.
[0109] Figure 5 1 is a schematic diagram of a question-answering device based on a large language model according to an embodiment of the present disclosure. This embodiment is applicable to the case of performing nonlinear question answering based on a large language model. The device can be implemented in software and / or hardware. Figure 5 As shown, the question-answering device 500 based on the large language model of this embodiment may include:
[0110] A problem decomposition module 510 is used to decompose the target problem to be processed using a large language model to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships;
[0111] The question answering module 520 is used to use a large language model to answer the sub-questions in the target semantic graph to obtain answers to the sub-questions, and determine the answer to the target question based on the answers to the sub-questions.
[0112] In an optional implementation, the root node of the target semantic graph is the target problem, the child nodes of the target semantic graph are subproblems, and the subproblem relationships are obtained based on the parent nodes of the child nodes.
[0113] In an optional implementation manner, different sub-questions are different, and the answer to the last sub-question in the answer sequence is the answer to the target question.
[0114] In an optional implementation, the problem solving module 510 includes:
[0115] A problem decomposition unit, used for inputting the target problem to be processed into a problem decomposition model to obtain at least two candidate semantic graphs;
[0116] A feedback unit, used for inputting the target question and the candidate semantic graph into a feedback model to obtain the quality of the candidate semantic graph;
[0117] A semantic graph selection unit, configured to select the target semantic graph from the candidate semantic graphs according to quality;
[0118] Among them, the question decomposition model and the feedback model both belong to large language models.
[0119] In an optional implementation, the question answering module 520 includes:
[0120] A parent question unit is used to obtain the parent question of each sub-question based on the question relationship in the target semantic graph;
[0121] A parent answer unit, used for obtaining the identifier of the parent question and the answer to the parent question when the parent question of the sub-question belongs to the sub-question;
[0122] A sub-question answering unit, used for inputting the sub-question, the identifier of the parent question and the answer to the parent question into a question answering model to obtain an answer to the sub-question;
[0123] Among them, the question answering model belongs to a large language model.
[0124] In an optional implementation, the question answering module 520 further includes:
[0125] The solution order unit is used to determine the solution order of each sub-problem based on the topological order between the sub-nodes in the target semantic graph.
[0126] In an optional implementation, the question answering module 520 includes:
[0127] A parent question unit, used to obtain at least two sub-questions in the target question and parent question identifiers of the sub-questions based on the question relationship in the target semantic graph;
[0128] A question answering unit, configured to input the at least two sub-questions and the parent question identifier of the sub-questions into a question answering model to obtain answers to the sub-questions;
[0129] Among them, the question answering model belongs to a large language model.
[0130] In an optional implementation, the question answering module 520 includes:
[0131] The knowledge type unit is used to input the sub-questions in the target semantic graph into the large language model and determine the knowledge type to which the sub-questions belong;
[0132] The knowledge base calling unit is used to call the knowledge base associated with the knowledge type to answer the sub-question.
[0133] The technical solution of the disclosed embodiment proposes a semantic graph technology. For a given target problem, the problem is first broken down into fine-grained sub-problems, and the relationship between different sub-problems is modeled to obtain a target semantic graph. The sub-problems are solved and traversed based on the topological relationship in the target semantic graph. In addition, in a step-by-step mode, by limiting the solution of the sub-problem to its related context, interference information is eliminated in the problem-solving process, thereby improving the efficiency and accuracy of the sub-problem solution.
[0134] Figure 6 1 is a schematic diagram of a large language model training device according to an embodiment of the present disclosure. This embodiment is applicable to the case where a large language model is fine-tuned and trained to have the ability to solve problems. The device can be implemented in software and / or hardware. Figure 6 As shown, the large language model training device 600 of this embodiment may include:
[0135] A sample semantic graph module 610 is used to obtain a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions in the sample question and sub-question relationships;
[0136] A candidate semantic graph module 620, configured to input the sample question into a pre-trained first language model to obtain a candidate semantic graph;
[0137] A quality module 630, configured to input the sample question and the candidate semantic graph into a pre-trained second language model to obtain the quality of the candidate semantic graph;
[0138] The model fine-tuning module 640 is used to select a target semantic graph according to the quality of the candidate semantic graph, and fine-tune the first large language model according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and fine-tune the second large language model to obtain a feedback model.
[0139] The technical solution of the disclosed embodiment obtains a question-answering model by fine-tuning the large language model, which is used to decompose the target problem to be solved into a semantic graph with a non-linear structure, which matches the non-linear thinking process of humans, thereby improving the accuracy of subsequent problem answers and improving the quality of problem answers by the large language model.
[0140] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0141] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0142] Figure 7 It is a block diagram of an electronic device used to implement the question-answering method based on a large language model or the model training method of the embodiment of the present disclosure.
[0143] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0144] like Figure 7 As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0145] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0146] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), an image processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a question-answering method based on a large language model and a training method for a model. For example, in some embodiments, a question-answering method based on a large language model and a training method for a model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the question-answering method based on the large language model and the training method for the model described above may be executed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute a question-answering method or a model training method based on a large language model in any other appropriate manner (eg, by means of firmware).
[0147] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0148] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0149] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0150] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0151] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0152] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0153] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, machine learning / deep learning technology, big data processing technology, knowledge graph technology, and other major directions.
[0154] Cloud computing refers to a technology system that uses network access to elastically scalable shared physical or virtual resource pools. Resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for technical applications such as artificial intelligence and blockchain, as well as model training.
[0155] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0156] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A question answering method based on a large language model, comprising: Using a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships; A large language model is used to answer the sub-questions in the target semantic graph to obtain the answers to the sub-questions, and the answers to the target questions are determined based on the answers to the sub-questions. The root node of the target semantic graph is the target question, the child nodes of the target semantic graph are sub-questions, and the sub-question relationship is obtained according to the parent node of the child node; different sub-questions are different, and the answer to the last sub-question in the answering order is the answer to the target question; The method of using a large language model to decompose the target problem to be processed to obtain a target semantic graph includes: Input the target problem to be processed into the problem decomposition model to obtain at least two candidate semantic graphs; Inputting the target question and the candidate semantic graph into a feedback model to obtain the quality of the candidate semantic graph; Selecting the target semantic graph from the candidate semantic graphs according to quality; Among them, the question decomposition model and the feedback model both belong to large language models.
2. The method according to claim 1, wherein: The method of using the large language model to answer the sub-questions in the target semantic graph to obtain answers to the sub-questions includes: For each sub-problem, obtain the parent problem of the sub-problem based on the problem relationship in the target semantic graph; If the parent question of the sub-question is a sub-question, obtaining the identifier of the parent question and the answer to the parent question; Inputting the sub-question, the identifier of the parent question and the answer to the parent question into a question answering model to obtain an answer to the sub-question; Among them, the question answering model belongs to a large language model.
3. The method according to claim 2, further comprising: The order of answering each sub-problem is determined based on the topological order between the sub-nodes in the target semantic graph.
4. The method according to claim 1, wherein: The method of using the large language model to answer the sub-questions in the target semantic graph to obtain answers to the sub-questions includes: Based on the problem relationship in the target semantic graph, at least two sub-problems in the target problem and parent problem identifiers of the sub-problems are obtained; Inputting the at least two sub-questions and the parent question identifier of the sub-questions into a question answering model to obtain answers to the sub-questions; Among them, the question answering model belongs to a large language model.
5. The method according to claim 1, wherein: The method of using the large language model to answer the sub-questions in the target semantic graph to obtain answers to the sub-questions includes: Input the sub-questions in the target semantic graph into the large language model to determine the knowledge type to which the sub-questions belong; The knowledge base associated with the knowledge type is called to answer the sub-question.
6. A method for training a large language model, comprising: Obtaining a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions and sub-question relationships in the sample question; Inputting the sample question into the first pre-trained language model to obtain a candidate semantic graph; Inputting the sample question and the candidate semantic graph into a pre-trained second largest language model to obtain the quality of the candidate semantic graph; Selecting a target semantic graph according to the quality of the candidate semantic graph, and fine-tuning the first large language model according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and fine-tuning the second large language model to obtain a feedback model; Among them, the root node of the sample semantic graph is the sample question, the child nodes of the sample semantic graph are sub-questions, and the sub-question relationship is obtained according to the parent node of the child node; different sub-questions are different, and the answer to the last sub-question in the answer order is the answer to the target question.
7. A question-answering device based on a large language model, comprising: A problem decomposition module is used to use a large language model to decompose the target problem to be processed to obtain a target semantic graph; wherein the target semantic graph includes sub-problems in the target problem and sub-problem relationships; A question answering module is used to answer sub-questions in the target semantic graph using a large language model to obtain answers to the sub-questions, and determine the answer to the target question based on the answers to the sub-questions; The root node of the target semantic graph is the target question, the child nodes of the target semantic graph are sub-questions, and the sub-question relationship is obtained according to the parent node of the child node; different sub-questions are different, and the answer to the last sub-question in the answering order is the answer to the target question; Wherein, the problem disassembly module includes: A problem decomposition unit, used for inputting the target problem to be processed into a problem decomposition model to obtain at least two candidate semantic graphs; A feedback unit, used for inputting the target question and the candidate semantic graph into a feedback model to obtain the quality of the candidate semantic graph; A semantic graph selection unit, configured to select the target semantic graph from the candidate semantic graphs according to quality; Among them, the question decomposition model and the feedback model both belong to large language models.
8. The device according to claim 7, wherein: The question answering module includes: A parent question unit is used to obtain the parent question of each sub-question based on the question relationship in the target semantic graph; A parent answer unit, used for obtaining the identifier of the parent question and the answer to the parent question when the parent question of the sub-question belongs to the sub-question; A sub-question answering unit, used for inputting the sub-question, the identifier of the parent question and the answer to the parent question into a question answering model to obtain an answer to the sub-question; Among them, the question answering model belongs to a large language model.
9. The apparatus according to claim 8, wherein the question answering module further comprises: The solution order unit is used to determine the solution order of each sub-problem based on the topological order between the sub-nodes in the target semantic graph.
10. The device according to claim 7, wherein: The question answering module includes: A parent question unit, used to obtain at least two sub-questions in the target question and parent question identifiers of the sub-questions based on the question relationship in the target semantic graph; A question answering unit, configured to input the at least two sub-questions and the parent question identifier of the sub-questions into a question answering model to obtain answers to the sub-questions; Among them, the question answering model belongs to a large language model.
11. The device according to claim 7, wherein: The question answering module includes: The knowledge type unit is used to input the sub-questions in the target semantic graph into the large language model and determine the knowledge type to which the sub-questions belong; The knowledge base calling unit is used to call the knowledge base associated with the knowledge type to answer the sub-question.
12. A large language model training device, comprising: A sample semantic graph module is used to obtain a sample question and a labeled sample semantic graph; the sample semantic graph includes sub-questions in the sample question and sub-question relationships; A candidate semantic graph module, used for inputting the sample question into a pre-trained first language model to obtain a candidate semantic graph; A quality module, used for inputting the sample question and the candidate semantic graph into a pre-trained second language model to obtain the quality of the candidate semantic graph; A model fine-tuning module, configured to select a target semantic graph according to the quality of the candidate semantic graph, and fine-tune the first large language model according to the sample semantic graph and the target semantic graph to obtain a question decomposition model, and fine-tune the second large language model to obtain a feedback model; Among them, the root node of the sample semantic graph is the sample question, the child nodes of the sample semantic graph are sub-questions, and the sub-question relationship is obtained according to the parent node of the child node; different sub-questions are different, and the answer to the last sub-question in the answer order is the answer to the target question.
13. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 1-6.
15. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Answer acquisition method based on knowledge graph
CN114896377A
Method and device for obtaining result, electronic equipment and storage medium
CN115203366A