Table question and answer method and system based on large language model and prompt learning
By employing large language models and prompt-based learning methods, this approach addresses the challenge of handling structured tables in existing technologies, enabling automated and efficient table-based question answering and enhancing the versatility and generalization capabilities of data processing.
Patent Information
- Application Number
- CN202510875884.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-10-21
AI Technical Summary
Existing technologies struggle to effectively process structured tabular data, lack versatility, and have high maintenance costs. They also make it difficult to directly understand and manipulate tabular data through large models.
We employ a method based on large language models and prompting learning. Through a process of question classification, sub-question decomposition, sub-table retrieval, and answer generation, we utilize the decomposition and code generation capabilities of large language models to automate the processing of structured tabular data.
It achieves efficient and automated form-based question answering, improves generalization capabilities, and provides a universal data processing and decision support tool.
Smart Images

Figure CN120821741A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of large models, and in particular to a table question-answering method and system based on a large language model and prompt learning. Background Art
[0002] Structured tabular data is ubiquitous, whether in spreadsheets, databases, or various documents, containing a wealth of critical information. In the past, processing this data often relied on manual manipulation using software such as Excel or database management systems, a time-consuming and labor-intensive process that was difficult to automate. While some deep learning methods have attempted to address tabular tasks through pre-training or specialized model architectures, these approaches are typically tailored to specific types of tables or tasks, lack versatility, and have high maintenance costs in practical applications. The rapid development of large model technology in recent years has brought new breakthroughs to table-based question answering. Pre-trained large language models have demonstrated impressive capabilities in natural language understanding and generation. However, due to the fundamental differences between the two-dimensional nature of structured tables and plain text, enabling large models to directly understand and manipulate tabular data remains a major challenge. In the future, through multimodal fusion, specialized table encoder design, and efficient instruction fine-tuning strategies, it is expected that structured tables can be processed automatically and efficiently using natural language instructions, providing more powerful intelligent tools for data processing and decision support across various industries. Summary of the Invention
[0003] The purpose of the present invention is to solve the problems existing in the prior art and provide a table question answering method based on a large language model and prompt learning.
[0004] In order to achieve the above-mentioned object of the invention, the present invention specifically adopts the following technical solutions:
[0005] In a first aspect, the present invention provides a table question answering method based on a large language model and prompt learning, which comprises the following steps:
[0006] S1. Obtain a user question expressed in natural language and a target table, input the user question, example question classification, and pre-built question classification prompt words into the large language model, and use the large language model to determine the question type;
[0007] S2. Based on the currently determined question type, the user question, target table, question decomposition examples, and pre-built question decomposition prompts for the current question type are input into the large language model. The large language model then decomposes the original question into sub-questions according to the pre-set decomposition strategies for different question types.
[0008] S3. Input each sub-question, target table, sub-table retrieval example, and pre-built sub-table retriever prompt words into the large language model, and use the large language model to recall the sub-table related to each sub-question from the target table;
[0009] S4. For each sub-question, generate an answer by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering;
[0010] S5. Determine the next step required to generate the final answer based on the question type currently determined, and generate the final answer based on all the results obtained after the final execution.
[0011] Based on the above solution, each step can be implemented in the following preferred specific manner.
[0012] As a preferred embodiment of the above-mentioned first aspect, in step S1, the problem types are divided into three types: dependency problems, independence problems and atomic problems; definitions of the three problem types need to be given in the problem classification prompt words, among which dependency problems satisfy the requirement that they can be decomposed into several sub-problems, and there is a forward and backward dependency relationship between each sub-problem, that is, subsequent problems must rely on the output results of the previous stage to be executed correctly; independence problems satisfy the requirement that they can be decomposed into several sub-problems, and each sub-problem is independent of each other, and there is no situation where the next operation must rely on the output results of the previous problem; atomic problems satisfy the requirement that the problem cannot be further decomposed.
[0013] As a preferred embodiment of the above-mentioned first aspect, in the problem decomposition prompt words of step S2, if the problem type is an atomic problem, the original problem is directly returned as the decomposed sub-problem; if the problem type is an independence problem, the problem is decomposed into several sub-problems and then returned; if the problem type is a dependency problem, only the first sub-problem is returned as the starting point for subsequent iterative processing.
[0014] As a preferred embodiment of the first aspect, in step S3, the subtable retriever prompt word is composed of a row search prompt word and a column search prompt word. For each sub-question, the specific method of recalling the subtable related to the current sub-question from the target table is:
[0015] S31. Input the current sub-question, target table, sub-table search examples, and pre-built row search prompts into the large language model, and obtain relevant rows through the large language model;
[0016] S32. Input the current sub-question, target table, sub-table search examples, and pre-built column search prompts into the large language model, and obtain relevant columns through the large language model;
[0017] S33. Based on the extracted relevant rows and relevant columns, extract the corresponding relevant sub-table from the target table as the recall result.
[0018] As a preferred embodiment of the first aspect, the auxiliary tool in step S4 includes a Python code tool for generating relevant codes required for analyzing the table according to the sub-questions and executing the generated codes to obtain answers to the sub-questions.
[0019] As a preferred embodiment of the above-mentioned first aspect, in step S5, if the question type is an atomic question, the answer to the atomic question is directly output as the final answer; if the question type is an independent question, all sub-questions, the answers to each sub-question, the original question and the preset final answer generation prompt words are input into the large language model together, and the large language model is integrated to obtain the final answer; if the question type is a dependent question, it is necessary to determine whether the final answer is obtained. If the final answer is not obtained, steps S2 to S4 are re-executed to continue decomposing the question to generate the next sub-question and retrieve the sub-table to generate the answer. If the final answer has been obtained, the iteration is stopped and the final answer is output.
[0020] In a second aspect, the present invention provides a table question answering system based on a large language model and prompt learning, which includes the following steps:
[0021] The question type determination module is used to obtain a user question expressed in natural language and a target table, input the user question, question classification examples, and pre-built question classification prompts into the large language model, and determine the question type through the large language model;
[0022] The sub-question decomposition module is used to input the user question, target table, question decomposition examples, and pre-built question decomposition prompts for the current question type into the large language model based on the currently determined question type. The large language model then decomposes the original question into sub-questions according to the pre-set decomposition strategies for different question types.
[0023] The subtable recall module is used to input each subquestion, target table, subtable search examples, and pre-built subtable searcher prompt words into the large language model, and use the large language model to recall the subtable related to each subquestion from the target table;
[0024] The sub-question answering module is used to generate the answer for each sub-question by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering;
[0025] The final answer generation module is used to determine the next step required to generate the final answer based on the question type currently determined, and to generate the final answer based on all the results obtained after the final execution.
[0026] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a table question-answering method based on a large language model and prompt learning as described in any of the schemes in the first aspect above is implemented.
[0027] In a fourth aspect, the present invention provides a computer electronic device comprising a memory and a processor;
[0028] The memory is used to store computer programs;
[0029] The processor is used to implement a table question answering method based on a large language model and prompt learning as described in any of the solutions of the first aspect above when executing the computer program.
[0030] In a fifth aspect, the present invention provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements a table question-answering method based on a large language model and prompt learning as described in any of the schemes in the first aspect above.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] The present invention fully utilizes the problem-solving and code-generating capabilities of large models, and designs a complete process consisting of question classification, sub-question decomposition, sub-table retrieval, and sub-question answering for table question-answering tasks, thereby improving the effectiveness and generalization capabilities of table question-answering. The present invention utilizes large language models and prompt learning, without the need to train specific models, and can significantly improve the question-answering effect. The present invention can automatically and efficiently process structured tables through natural language instructions, and extract the required information as answers, which is expected to provide universal data processing and decision support tools for different industries. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 Flowchart of the table question answering method based on large language model and prompt learning;
[0034] Figure 2 Question and answer flow chart for independence question form;
[0035] Figure 3 Question and answer flow chart for dependency question form;
[0036] Figure 4 A schematic diagram of the modules of a table question answering system based on a large language model and prompt learning;
[0037] Figure 5 It is a structural diagram of computer electronic equipment. DETAILED DESCRIPTION
[0038] In order to make the above-mentioned objects, features and advantages of the present invention more clearly understood, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. The technical features in the various embodiments of the present invention can be combined accordingly without conflicting with each other.
[0039] In the description of the present invention, it should be understood that the terms "first" and "second" are only used for the purpose of distinction and description.
[0040] It cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features.
[0041] like Figure 1 As shown, in a preferred implementation of the present invention, the table question answering method based on a large language model and prompt learning primarily includes the following five subtasks: question classification, question decomposition, table decomposition, sub-question answering, and answer generation. This includes steps S1 to S5. The specific implementation process is described below.
[0042] 1. Problem Classification
[0043] S1. Obtain a user question expressed in natural language and a target table, input the user question, one or more sets of question classification examples, and pre-built question classification prompts into a large language model, and use the large language model to determine the question type;
[0044] It should be noted that the target form in the present invention is a form from which questions need to be extracted, and the specific form needs to be specified and input by the user according to the user's actual question and answer needs.
[0045] In step S1 of the present invention, the types of questions included are dependency questions, independence questions and atomic questions. Among them, dependency questions and independence questions can be decomposed into several sub-questions, while atomic questions do not need to be decomposed. The above-mentioned question classification prompt words need to give definitions of three types of questions, among which dependency questions satisfy the requirement that they can be decomposed into several sub-questions, and there is a front-to-back dependency relationship between each sub-question, that is, subsequent questions must rely on the output results of the previous stage to be executed correctly; independence questions satisfy the requirement that they can be decomposed into several sub-questions, and each sub-question is independent of each other, and there is no situation where the output results of the previous question must be relied on to proceed to the next step; atomic questions satisfy the requirement that the problem cannot be further decomposed. Therefore, the large language model can identify the type of user questions based on the definitions of these three types of questions.
[0046] 2. Problem Analysis
[0047] S2. Based on the currently determined question type, the user question, target table, one or several groups of question decomposition examples, and pre-built question decomposition prompts for the current question type are input into the large language model. The large language model then decomposes the original question into one or several sub-questions according to the preset decomposition strategies for different question types.
[0048] In step S2 of the present invention, the specific prompt words for problem solving are as follows:
[0049] If the problem type is an atomic problem, the original problem is directly returned as the decomposed sub-problem; if the problem type is an independence problem, the problem is decomposed into several sub-problems and then returned; if the problem type is a dependency problem, only the first decomposed sub-problem is returned as the starting point for subsequent iterative processing. When S2 is repeated next time, the next sub-problem can be further decomposed based on the previous sub-problem until the final answer is obtained. The answer process for independence and dependency problems is as follows: Figure 2 and Figure 3 shown.
[0050] 3. Table Search
[0051] S3. Input each sub-question, the target table, one or several groups of sub-table retrieval examples, and pre-built sub-table retriever prompt words into the large language model, and use the large language model to recall the sub-table related to each sub-question from the target table;
[0052] In step S3 of the present invention, the subtable searcher prompt word is composed of a row search prompt word and a column search prompt word. For each sub-question, the specific method of recalling the subtable related to the current sub-question from the target table is:
[0053] S31. Input the current sub-question, target table, sub-table search examples, and pre-built row search prompts into the large language model, and obtain relevant rows through the large language model;
[0054] S32. Input the current sub-question, target table, sub-table search examples, and pre-built column search prompts into the large language model, and obtain relevant columns through the large language model;
[0055] S33. Based on the extracted relevant rows and relevant columns, extract the corresponding relevant sub-table from the target table as the recall result.
[0056] For each sub-problem, it is necessary to iterate S31 to S33 to obtain the relevant sub-table. Note that in S31 and S32, the row index of the relevant row and the column index of the relevant column can be recorded, and then the corresponding content can be extracted from the target table based on the row and column indexes to form the relevant sub-table.
[0057] 4. Sub-question Q&A
[0058] S4. For each sub-question, generate an answer by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering.
[0059] In step S4 of the present invention, if the large language model cannot directly answer the sub-question, it is necessary to call relevant auxiliary tools to obtain the answer. For the table question and answer scenario, the auxiliary tools used are mainly Python code tools, which are used to generate the relevant code required to analyze the table based on the sub-question and execute the generated code to obtain the answer to the sub-question. Of course, if the large language model can answer the sub-question without the use of auxiliary tools, the answer can be generated directly based on the large model.
[0060] 5. Answer Generation
[0061] S5. Determine the next step required to generate the final answer based on the question type currently determined, and generate the final answer based on all the results obtained after the final execution.
[0062] The specific process of step S5 of the present invention is as follows:
[0063] If the question type is an atomic question, the answer to the atomic question is directly output as the final answer, skipping the iteration or large language model integration reasoning process; if the question type is an independent question, all sub-questions, the answers to each sub-question, the original question and the preset final answer generation prompt words are input into the large language model together, and the final answer is obtained by integration of the large language model; if the question type is a dependent question, it is necessary to determine whether the final answer is obtained. If the final answer is not obtained, re-execute steps S2 to S4, continue to decompose the question to generate the next sub-question and retrieve the sub-table to generate the answer. If the final answer has been obtained, stop iteration and output the final answer.
[0064] It should be noted that the above-mentioned prompt words for generating the final answer need to drive the large language model to integrate the answers to all sub-questions and output the final answer to the original question.
[0065] The above-mentioned question classification prompt words, question decomposition prompt words, sub-table retriever prompt words and final answer generation prompt words can be designed according to the prompt word project. The specific form is not limited and is subject to meeting the required functions.
[0066] In order to better demonstrate the specific implementation and technical effects of the present invention, a table question-answering method based on a large language model and prompt learning shown in the above-mentioned preferred implementation method is applied to two specific examples. The implementation process of each step is as described above and will not be repeated here.
[0067] Example 1
[0068] The following is an example of using the method of the present invention to perform a table question answering. The question Q is: "In 2013, how many more passengers flew from Manzanillo Airport to Los Angeles than to Saskatoon?" The original table is as follows:
[0069] Table 1. Example 1 table information
[0070] Ranking City Passenger volume Sub-ranking airline 1 Los Angeles, USA 14749 Alaska Airlines 2 Houston, USA 5465 United Express 3 Calgary, Canada 3761 Air Transat, WestJet 4 Saskatoon, Canada 2282 4 5 Vancouver, Canada 2103 Air Transat 6 Phoenix, USA 1829 1 US Airways 7 Toronto, Canada 1202 1 Air Transat, CanJet 8 Edmonton, Canada 110 9 Oakland, USA 107
[0071] Table 1 above records the passenger flow ranking information of different cities. Each row shows a city (and its country), the corresponding number of passengers, additional ranking in some cases, and information about airlines related to the city.
[0072] The table question answering method based on the large language model and prompt learning based on this table is as follows:
[0073] 1. Problem Classification
[0074] The question classification prompt provided to the large language model is: "You are an assistant, and your task is to classify the given questions. The following are your requirements: (1) Question types include <independence questions>, <dependence questions>, and <atomic questions>; (2) The three question types are defined as follows: Independence questions: can be split into several sub-questions, and there is a front-to-back dependency relationship between each sub-question, that is, the subsequent question must rely on the output results of the previous stage to be executed correctly; Dependence questions: can be split into several sub-questions, and each sub-question is independent of each other. There is no situation where the next step must rely on the output results of the previous question; Atomic questions: cannot be split into multiple questions; (3) The output format is <question type>, and only one needs to be output."
[0075] An example of a set of question classifications is: "Question 1: Which album by the band Schnell Fenster generated the most singles on the Australian charts? Type 1: <Dependency question> Question 2: Which is deeper, Lake Tuz or Lake PalasTuzla? Type 2: <Independence question> Question 3: Which team won before Crettayard? Type 3: <Atomic question>".
[0076] For the given question Q, the question type output by the large language model is <independence question>.
[0077] II. Problem Decomposition
[0078] Regarding the independence problem, the problem decomposition prompt provided to the large language model is: "You are an assistant, and your task is to decompose the given problem. The following are the requirements for you: (1) If the given problem can be decomposed into multiple sub - problems, then decompose it; if it cannot be decomposed, return the original problem; (2) The final return format is <Q1: Problem 1><Q2: Problem 2>...<Qn: Problem n>; (3) The sub - problems are independent of each other and do not have an inclusion or overlapping relationship."
[0079] An example of problem decomposition is: "Input original problem: Which is deeper, Lake Tuz or Lake Palas Tuzla?? Output sub - problems: <Q1: How deep is Lake Tuz?><Q2: How deep is Lake Tuz?>"
[0080] For the given problem Q, the large language model decomposes the problem into Q1: "What is the total number of passengers flying from Manzanillo Airport to Los Angeles in 2013?" and Q2: "What is the total number of passengers flying from Manzanillo Airport to Saskatoon in 2013?".
[0081] III. Table Retrieval
[0082] The row retrieval prompt provided to the large language model is: "You are an assistant, and your task is to return the relevant row information based on the problem and the table. The following are the requirements for you: (1) You need to return the serial numbers of the rows related to the problem; (2) The output format is <row id>, where id is the serial number of the row; (3) The row where the table column names are located is defaulted to the 0th row and does not need to be returned." An example related to it is: "Input problem: How deep is Lake Tuz? Input table: Output row: <row 2>". The specific content of Table a is as follows:
[0083] Table 2. Information of Table Retrieval Example Table a
[0084]
[0085]
[0086] The column retrieval prompt is: "You are an assistant, and your task is to return the relevant column information based on the problem and the table. The following are the requirements for you: (1) You need to return the serial numbers of the columns related to the problem; (2) The output format is <column name 1, column name 2... column name n>;". An example related to it is: "Input problem: How deep is Lake Tuz? Input table: Output column: <Lake Name, Depth>".
[0087] For the original table and sub-question Q1, the large language model retrieves the relevant behavior: "<row 1>" and the relevant column "<city, passenger volume>". Based on the obtained rows and columns, the corresponding sub-table T1 is retrieved.
[0088] Similarly, for the original table and sub-question Q2, the corresponding sub-table T2 is also retrieved.
[0089] 4. Sub-question Q&A
[0090] The prompt provided to the large language model is: "You are an assistant, and your task is to answer questions based on the table information. The following are your requirements: (1) You can answer directly, or use Python code tools to assist in answering."
[0091] For subtable T1 and subquestion Q1, the answer given by the large language model is: 14749.
[0092] For subtable T2 and subquestion Q2, the answer given by the large language model is: 2282.
[0093] 5. Answer Generation
[0094] For independence questions, the prompt words provided to the large language model are: "You are an assistant, and your task is to summarize the above questions and generate the final answer. The following are your requirements: (1) Based on the given questions and related answers, summarize and generate the answer to the original question (2) Directly output the answer, and try to be as concise as possible." The relevant example is: "Enter the original question: Which is deeper, Lake Tuz or Lake Palas Tuzla? Sub-question Q1: How deep is Lake Tuz? Answer 1: 2m
[0095] Sub-question Q2: How deep is Palas Tuzla Lake? Answer 2: 15m Final answer: Palas Tuzla Lake".
[0096] Based on the above results, the final answer is: 12467.
[0097] Example 2
[0098] The following is an example of using the method of the present invention to perform a table question-answering. Unlike the previous example, this example is a dependency question. The question Q is: "Which players play the same position as Ardo Kreek?" The original table is as follows:
[0099] Table 3. Example 2 table information
[0100]
[0101]
[0102] Table 3 above records the detailed information of the players, including serial number, name, date of birth, weight, height, position on the field and the club they are currently playing for.
[0103] The table question-answering method based on large language models and prompt learning based on this table is as follows:
[0104] I. Question classification
[0105] The question classification prompt words provided to the large language model are: "You are an assistant, and your task is to classify the given question. The following are the requirements for you: (1) The question types include <independent questions>, <dependent questions> and <atomic questions>; (2) The definitions of the three question types are as follows. Independent questions: Can be split into several sub-questions, and there is a front-to-back dependency relationship between each sub-question, that is, the subsequent questions must depend on the output results of the previous stage to be correctly executed. Dependent questions: Can be split into several sub-questions, and each sub-question is independent of each other, and there is no situation where the next step of operation must depend on the output results of the previous question. Atomic questions: Cannot be split into multiple questions; (3) The output format is <question type>, and only one needs to be output".
[0106] A set of examples of question classification is: "Question 1: Which album released by the Schnell Fenster band produced the most singles on the Australian charts? Type 1: <dependent question> Question 2: Which is deeper, Lake Tuz or Lake Palas Tuzla? Type 2: <independent question> Question 3: Which team won before Crettyard? Type 3: <atomic question>".
[0107] For the given question Q, the question type output by the large language model is <dependent question>.
[0108] II. Question decomposition
[0109] For dependent questions, the question decomposition prompt words provided to the large language model are: "You are an assistant, and your task is to decompose the given question. The following are the requirements for you: (1) For the given question, decompose the question and return the question to be solved first; (2) The final return format is <Q1: question 1>;".
[0110] A set of examples of question decomposition is: "Input original question: Which album released by the Schnell Fenster band produced the most singles on the Australian charts? Output sub-question: <Q1: Which albums has the Schnell Fenster band released?>".
[0111] For the given question Q, the large language model decomposes the question into Q1: "What position does Ardo Kreek play?".
[0112] 3. Table Search
[0113] The row retrieval prompt provided to the large language model is: "You are an assistant, and your task is to return relevant row information based on questions and tables. The following are your requirements: (1) You need to return the serial number of the row related to the question; (2) The output format is <row id>, where id is the serial number of the row; (3) The row where the table column name is located defaults to row 0 and does not need to be returned." The relevant example is: "Input question: How deep is Lake Tuz? Input table: Output row: <row 2>".
[0114] The column search prompt is: "You are an assistant, and your task is to return relevant column information based on questions and tables. The following are your requirements: (1) You need to return the serial number of the column related to the question; (2) The output format is <column name 1, column name 2...column name n>;", and the relevant example is: "Input question: How deep is Lake Tuz? Input table: Output column: <lake name, depth>".
[0115] For the original table and sub-question Q1, the large language model retrieves the relevant behavior: "<row 1>", and the relevant columns "<player, position>". Based on the obtained rows and columns, the corresponding sub-table T1 is retrieved.
[0116] 4. Sub-question Q&A
[0117] The prompt provided to the large language model is: "You are an assistant, and your task is to answer questions based on the table information. The following are your requirements: (1) You can answer directly, or use Python code tools to assist in answering."
[0118] For sub-table T1 and sub-question Q1, the answer given by the large language model is: deputy attacker.
[0119] 5. Answer Generation
[0120] For dependency questions, repeat steps 2 to 4 until the problem is solved. The given question Q is further split into sub-question Q2: "Which other players play the position of "secondary attacker"?" The answer given by the large model is: "Siim Ennemuist, Andri Aganits"
[0121] Based on the above results, the final answer is: Siim Ennemuist, AndriAganits.
[0122] It should be noted that the table question-answering method steps based on a large language model and prompt learning shown in S1 to S5 above can essentially be implemented in the form of a computer program or software function module.
[0123] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a table question answering system based on a large language model and prompt learning corresponding to the table question answering method based on a large language model and prompt learning provided in the above embodiment, such as Figure 4 As shown, it includes:
[0124] The question type determination module is used to obtain a user question expressed in natural language and a target table, input the user question, question classification examples, and pre-built question classification prompts into the large language model, and determine the question type through the large language model;
[0125] The sub-question decomposition module is used to input the user question, target table, question decomposition examples, and pre-built question decomposition prompts for the current question type into the large language model based on the currently determined question type. The large language model then decomposes the original question into sub-questions according to the pre-set decomposition strategies for different question types.
[0126] The subtable recall module is used to input each subquestion, target table, subtable search examples, and pre-built subtable searcher prompt words into the large language model, and use the large language model to recall the subtable related to each subquestion from the target table;
[0127] The sub-question answering module is used to generate the answer for each sub-question by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering;
[0128] The final answer generation module is used to determine the next step required to generate the final answer based on the question type currently determined, and to generate the final answer based on all the results obtained after the final execution.
[0129] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the table question answering method based on a large language model and prompt learning provided in the above embodiment, such as Figure 5 As shown, it includes a memory and a processor;
[0130] The memory is used to store computer programs;
[0131] The processor is configured to implement a table question answering method based on a large language model and prompt learning in the above embodiment when executing the computer program.
[0132] Furthermore, the logic instructions in the aforementioned memory can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention.
[0133] Therefore, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer-readable storage medium corresponding to the above-mentioned embodiment, and the storage medium stores a computer program on the table question and answer method based on a large language model and prompt learning. When the computer program is executed by the processor, it can implement the table question and answer method based on a large language model and prompt learning in the above-mentioned embodiment.
[0134] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer program product corresponding to the table question-answering method based on a large language model and prompt learning provided in the above embodiment, including a computer program / instruction. When the computer program / instruction is executed by the processor, it can implement a question-answering method based on a general table large model and a data intelligent body in the above embodiment.
[0135] It is understood that the storage medium may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage medium may be any medium capable of storing program code, such as a USB flash drive, a mobile hard drive, a magnetic disk, or an optical disk.
[0136] It is understandable that the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0137] It should also be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the various embodiments provided in this application, the division of steps or modules in the system and method is only a logical function division. In actual implementation, there may be other division methods, for example, multiple modules or steps can be combined or integrated together, and a module or step can also be split.
[0138] The embodiment described above is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Persons skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent substitution or equivalent transformation falls within the scope of protection of the present invention.
Claims
1. A table question answering method based on a large language model and prompt learning, characterized in that: The following steps are involved: S1. Obtain a user question expressed in natural language and a target table, input the user question, example question classification, and pre-built question classification prompt words into the large language model, and use the large language model to determine the question type; S2. Based on the currently determined question type, the user question, target table, question decomposition examples, and pre-built question decomposition prompts for the current question type are input into the large language model. The large language model then decomposes the original question into sub-questions according to the pre-set decomposition strategies for different question types. S3. Input each sub-question, target table, sub-table retrieval example, and pre-built sub-table retriever prompt words into the large language model, and use the large language model to recall the sub-table related to each sub-question from the target table; S4. For each sub-question, generate an answer by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering; S5. Determine the next step required to generate the final answer based on the question type currently determined, and generate the final answer based on all the results obtained after the final execution.
2. A table question answering method based on a large language model and prompt learning according to claim 1, characterized in that: In step S1, the problem types are divided into three types: dependency problems, independence problems and atomic problems; the definitions of the three problem types need to be given in the problem classification prompt words, among which dependency problems meet the requirement of being able to be decomposed into several sub-problems, and there is a front-to-back dependency relationship between each sub-problem, that is, the subsequent problem must rely on the output result of the previous stage to be executed correctly; independence problems meet the requirement of being able to be decomposed into several sub-problems, and each sub-problem is independent of each other, and there is no situation where the next operation must rely on the output result of the previous problem; atomic problems meet the requirement that the problem cannot be further decomposed.
3. A table question answering method based on a large language model and prompt learning according to claim 1, characterized in that: In the problem decomposition prompt word of step S2, if the problem type is an atomic problem, the original problem is directly returned as the decomposed sub-problem; if the problem type is an independence problem, the problem is decomposed into several sub-problems and then returned; If the problem type is a dependency problem, only the first subproblem is returned as the starting point for subsequent iterative processing.
4. A table question answering method based on a large language model and prompt learning according to claim 1, characterized in that: In step S3, the subtable search prompt word is composed of a row search prompt word and a column search prompt word. For each sub-question, the specific method of recalling the subtable related to the current sub-question from the target table is: S31. Input the current sub-question, target table, sub-table search examples, and pre-built row search prompts into the large language model, and obtain relevant rows through the large language model; S32. Input the current sub-question, target table, sub-table search examples, and pre-built column search prompts into the large language model, and obtain relevant columns through the large language model; S33. Based on the extracted relevant rows and relevant columns, extract the corresponding relevant sub-table from the target table as the recall result.
5. The table question answering method based on large language model and prompt learning according to claim 1, characterized in that: The auxiliary tool in step S4 includes a Python code tool, which is used to generate relevant codes required for analyzing the table according to the sub-questions and execute the generated codes to obtain answers to the sub-questions.
6. A table question answering method based on a large language model and prompt learning according to claim 1, characterized in that: In step S5, if the question type is an atomic question, the answer to the atomic question is directly output as the final answer; if the question type is an independent question, all sub-questions, the answers to each sub-question, the original question and the preset final answer generation prompt words are input into the large language model together, and the large language model is integrated to obtain the final answer; if the question type is a dependent question, it is necessary to determine whether the final answer is obtained. If the final answer is not obtained, steps S2 to S4 are re-executed to continue decomposing the question to generate the next sub-question and retrieve the sub-table to generate the answer. If the final answer has been obtained, the iteration is stopped and the final answer is output.
7. A table question answering system based on a large language model and prompt learning, characterized in that The following steps are involved: The question type determination module is used to obtain a user question expressed in natural language and a target table, input the user question, question classification examples, and pre-built question classification prompts into the large language model, and determine the question type through the large language model; The sub-question decomposition module is used to input the user question, target table, question decomposition examples, and pre-built question decomposition prompts for the current question type into the large language model based on the currently determined question type. The large language model then decomposes the original question into sub-questions according to the pre-set decomposition strategies for different question types. The subtable recall module is used to input each subquestion, target table, subtable search examples, and pre-built subtable searcher prompt words into the large language model, and use the large language model to recall the subtable related to each subquestion from the target table; The sub-question answering module is used to generate the answer for each sub-question by inferring from the sub-table related to the sub-question by calling auxiliary tools or directly answering; The final answer generation module is used to determine the next step required to generate the final answer based on the question type currently determined, and to generate the final answer based on all the results obtained after the final execution.
8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which, when executed by a processor, implements a table question-answering method based on a large language model and prompt learning as described in any one of claims 1 to 6.
9. A computer electronic device, characterized in that: including memory and processor; The memory is used to store computer programs; The processor is configured to implement a question-answering method based on a general table model and a data agent as described in any one of claims 1 to 6 when executing the computer program.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, it can implement a table question answering method based on a large language model and prompt learning as described in any one of claims 1 to 6.