An open domain table question and answer method, system, terminal and storage medium for future data prediction
By using a large language model to generate SQL statements in a table-based question-and-answer system and combining them with a time series forecasting model, the problem of insufficient modeling of dynamic time series data in existing technologies is solved, and the accuracy of numerical forecasting is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING NORMAL UNIV AT ZHUHAI
- Filing Date
- 2026-05-11
- Publication Date
- 2026-06-05
AI Technical Summary
Existing table-based question-answering methods mainly focus on retrieval and reasoning based on static historical data, lacking a modeling mechanism for dynamic time series data, resulting in poor performance when directly used for numerical prediction.
The system filters the tabular database using a large language model, generates SQL statements for querying, expands historical data sequences using a time series prediction model, and transforms the data using the large language model to generate query answers.
It improves the accuracy of data prediction in the form-based question-and-answer system, especially in the prediction of dynamic time series data.
Smart Images

Figure CN122152862A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to an open-domain table-based question-and-answer method, system, terminal, and computer-readable storage medium for future data prediction. Background Technology
[0002] Tabular data, with its structured and easy-to-understand characteristics, has become the main carrier of data analysis and information retrieval. With the development of natural language processing technology, people often use computers to automatically parse large amounts of tabular data to improve the efficiency of data analysis.
[0003] Existing table-based question answering methods primarily rely on large language models to understand user-submitted questions and parse the structure and content of tables in a tabular database. Based on the results of question understanding and table parsing, they search for matching data within the tables to generate human-readable answers. However, these methods mainly focus on retrieval and reasoning based on static historical data, lacking a modeling mechanism for dynamic time-series data. This results in poor performance when directly applied to numerical prediction.
[0004] Therefore, existing technologies still need to be improved and developed. Summary of the Invention
[0005] The main objective of this invention is to provide an open-domain table question-answering method, system, terminal, and storage medium for future data prediction. This invention aims to address the problem that existing table question-answering methods primarily focus on retrieval and reasoning based on static historical data, lacking a modeling mechanism for dynamic time series data, resulting in poor performance when directly applied to numerical prediction.
[0006] To achieve the above objectives, this invention provides an open-domain table-based question-answering method for future data prediction, comprising the following steps: Obtain the user query statement and table database, determine the large language model, and filter the table database according to the user query statement using the large language model to obtain the target table; The target SQL statement is obtained by generating an SQL statement based on the user query and the target table using the large language model. The target SQL statement is used to query the table database to obtain historical data sequences, and a time series prediction model is determined. The historical data sequences are then extended using the time series prediction model to obtain the target data sequence. The user query statement is classified using the large language model to obtain the query type, and the target data sequence is transformed according to the query type to obtain the query answer.
[0007] Optionally, the open-domain table question-answering method for future data prediction, wherein obtaining the user query statement and table database, determining a large language model, and filtering the table database according to the user query statement using the large language model to obtain the target table, specifically includes: Obtain the user query statement, determine the large language model, and rewrite the user query statement using the large language model to obtain the table title summary; Obtain the table database, and directly match the table title summary with the table database. If a direct match result is obtained, the direct match result is used as the target table. If a direct match cannot be obtained, a text retrieval algorithm is determined, and the relevance calculation is performed on the table title summary and the tables in the table database using the text retrieval algorithm to obtain the target table.
[0008] Optionally, the open-domain table question-answering method for future data prediction, wherein the step of generating a target SQL statement by using the large language model based on the user query and the target table, specifically includes: Obtain query examples and add them to the system suggestion words of the large language model to obtain a query example library; The user query statement and the query example library are compared using the large language model to obtain the query intent. The query intent and the target table are then mapped and aligned to obtain the initial SQL statement. The initial SQL statement is modified to obtain the target SQL statement.
[0009] Optionally, the open-domain table question-answering method for future data prediction, wherein the step of modifying the initial SQL statement to obtain the target SQL statement specifically includes: The initial SQL statement was executed on a trial basis, and an error message was obtained. The error information is cleaned to obtain feedback information; The initial SQL statement is corrected using the large language model based on the feedback information and the query example library to obtain the target SQL statement.
[0010] Optionally, in the open-domain table question-answering method for future data prediction, the step of performing data cleaning processing on the error information to obtain feedback information specifically includes: The error message is processed using regular expression matching to obtain the core error description; Obtain the actual information of the target table, and concatenate the core error description, the initial SQL statement, and the actual information to obtain the feedback instruction; The feedback instructions are de-identified to obtain feedback information.
[0011] Optionally, the open-domain table question-answering method for future data prediction, wherein the step of querying the table database according to the target SQL statement to obtain a historical data sequence, determining a time series prediction model, and expanding the historical data sequence using the time series prediction model to obtain the target data sequence specifically includes: The target SQL statement is used to perform a query in the table database to obtain the query results, and the query results are converted into a list of values to obtain a historical data sequence. A time series baseline model is determined, and missing values in the historical data sequence are filled in using the time series baseline model to obtain the sequence to be predicted; A time series forecasting model is determined, and the forecasting process is performed on the sequence to be predicted using the time series forecasting model to obtain future forecast data. The target data sequence is then obtained based on the future forecast data and the historical data sequence.
[0012] Optionally, in the open-domain table question-answering method for future data prediction, the query type includes a first query type and a second query type. The process of classifying the user's query statement using the large language model to obtain the query type, and then performing data transformation on the target data sequence based on the query type to obtain the query answer, specifically includes: The user query statement is categorized using the large language model to obtain the query type. When the query type is the first query type, the target data sequence is numerically extracted using the large language model to obtain key values, and the key values are then converted into natural language to obtain the query answer. When the query type is the second query type, the target data sequence is analyzed and processed by the large language model to obtain the analysis results, and the analysis results are processed by natural language conversion to obtain the query answer.
[0013] Furthermore, to achieve the above objectives, the present invention also provides an open-domain table-based question-answering system for future data prediction, wherein the open-domain table-based question-answering system for future data prediction includes: The table matching module is used to obtain the user's query statement and the table database, determine the large language model, and filter the table database according to the user's query statement using the large language model to obtain the target table. The SQL statement generation module is used to generate the target SQL statement by performing SQL statement generation processing based on the user query statement and the target table through the large language model. The data prediction module is used to perform query processing on the table database according to the target SQL statement to obtain historical data sequences, determine a time series prediction model, and expand the historical data sequences through the time series prediction model to obtain the target data sequence. The answer generation module is used to classify the user query statement through the large language model to obtain the query type, and to perform data transformation processing on the target data sequence according to the query type to obtain the query answer.
[0014] Furthermore, to achieve the above objectives, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and an open-domain table question-and-answer program for future data prediction stored in the memory and executable on the processor, wherein when the open-domain table question-and-answer program for future data prediction is executed by the processor, it implements the steps of the open-domain table question-and-answer method for future data prediction as described above.
[0015] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores an open-domain table question-and-answer program for future data prediction, and the open-domain table question-and-answer program for future data prediction, when executed by a processor, implements the steps of the open-domain table question-and-answer method for future data prediction as described above.
[0016] In this invention, a user query statement and a table database are obtained, a large language model is determined, and the table database is filtered based on the user query statement using the large language model to obtain a target table. Then, an SQL statement is generated based on the user query statement and the target table using the large language model to obtain a target SQL statement. The target SQL statement is then queried in the table database to obtain a historical data sequence, and a time series prediction model is determined. This time series prediction model is then used to expand the historical data sequence to obtain a target data sequence. Finally, the user query statement is categorized using the large language model to obtain query types, and the target data sequence is transformed based on these query types to obtain a query answer. This invention improves the accuracy of data prediction in a table-based question-and-answer system by generating SQL statements from user queries, querying the table database to obtain historical data sequences, expanding the historical data sequences using a time series prediction model to obtain target data sequences, and then transforming the target data sequences using a large language model to obtain query answers. Attached Figure Description
[0017] Figure 1 This is a flowchart of a preferred embodiment of the open-domain table question-answering method for future data prediction of the present invention; Figure 2 This is a system architecture diagram of the open-domain table question-answering method for future data prediction according to the present invention; Figure 3 This is a structural diagram of a preferred embodiment of the open-domain table question-answering system for future data prediction of the present invention; Figure 4 This is a structural diagram of a preferred embodiment of the terminal of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0019] Tabular data, with its structured and easy-to-understand characteristics, has become the main carrier of data analysis and information retrieval. With the development of natural language processing technology, people often use computers to automatically parse large amounts of tabular data to improve the efficiency of data analysis.
[0020] Existing table-based question answering methods primarily rely on large language models to understand user-submitted questions and parse the structure and content of tables in a tabular database. Based on the results of question understanding and table parsing, they search for matching data within the tables to generate human-readable answers. However, these methods mainly focus on retrieval and reasoning based on static historical data, lacking a modeling mechanism for dynamic time-series data. This results in poor performance when directly applied to numerical prediction.
[0021] To address the aforementioned issues, this invention proposes an open-domain table-based question-and-answer method for future data prediction. It generates a Structured Query Language (SQL) statement based on the user's query and performs a query in a table database to obtain a historical data sequence. This historical data sequence is then expanded using a time series prediction model to obtain a target data sequence. Finally, a large language model is used to transform the target data sequence to obtain the query answer, thereby improving the accuracy of data prediction in the table-based question-and-answer system.
[0022] The open-domain table question-answering method for future data prediction described in the preferred embodiment of the present invention, such as... Figure 1 As shown, the open-domain table question-answering method for future data prediction includes the following steps: Step S10: Obtain the user query statement and table database, determine the large language model, and filter the table database according to the user query statement using the large language model to obtain the target table.
[0023] To address table-based question-answering problems involving future data prediction and inference in open-domain scenarios, this invention decomposes the complex task into three collaborative modules: 1. Retriever: Responsible for data acquisition, using a two-stage "summary-matching" strategy to locate data tables, and autonomously generating and modifying SQL statements to extract historical data sequences; 2. Forecaster: Responsible for compensating for the shortcomings of the prediction capabilities of the Large Language Model (LLM). It uses a function calling mechanism to schedule external professional missing value imputation models and time series prediction models to generate high-precision future data. 3. Analyzer: Responsible for synthesizing results, classifying them according to question type (predictive or inferential), and combining historical and predictive data to generate standardized and consistent final answers.
[0024] Specifically, the user query statement is obtained, a large language model is determined, and the user query statement is rewritten using the large language model to obtain a table title summary.
[0025] like Figure 2 As shown, the search engine module first performs a table search, using a "summary first, then match" strategy to retrieve tables related to the user's query.
[0026] First, leveraging the reasoning capabilities of LLM, the user query is rewritten into a standard table caption-style summary. Specifically, due to the illusion problem inherent in LLM, the generated captions may not necessarily match those in the database; therefore, the LLM-generated captions are referred to as summaries.
[0027] Furthermore, a table database is obtained, and the table title summary is directly matched with the table database. If a direct matching result is obtained, the direct matching result is used as the target table. like Figure 2 As shown, the summary generated by LLM is then used to match one or more of the most relevant table headings in the tabular database.
[0028] First, the abstract is directly matched with the table titles in the database. If the abstract can be directly matched with the table name in the database, then that table is used as the target table.
[0029] Furthermore, if a direct matching result cannot be obtained, a text retrieval algorithm is determined, and the relevance calculation is performed on the table title summary and the tables in the table database using the text retrieval algorithm to obtain the target table.
[0030] like Figure 2 As shown, if the summary generated by LLM cannot find an exact match in the database (this is more common because user queries vary), the system will start the BM25 (Best Matching 25) algorithm to calculate the semantic similarity between the summary and the table title, and retrieve the most relevant table.
[0031] Specifically, BM25 is a classic text retrieval algorithm that ranks queries and documents by calculating a relevance score. The BM25 algorithm calculates the similarity score between the summary generated by the LLM and each table title. In this invention, it considers term frequency (TF) and inverse document frequency (IDF), outputs the similarity score between each table title and summary, and finally outputs the table with the highest score as the target table.
[0032] Step S20: The large language model is used to generate SQL statements based on the user query and the target table to obtain the target SQL statement.
[0033] like Figure 2 As shown, the retrieval module generates SQL query statements based on the table structure of the target table using In-Context Learning (ICL).
[0034] Specifically, query examples are obtained and added to the system prompts of the large language model to obtain a query example library.
[0035] The system prompt includes multiple (e.g., 5) diverse examples covering different query types (single entity, multi-entity comparison, etc.). Each example strictly consists of three parts: a natural language query example, a summary of the corresponding real table structure or table header, and a standard target SQL statement.
[0036] Furthermore, the user query statement and the query example library are compared using the large language model to obtain the query intent, and the query intent is mapped and aligned with the target table to obtain the initial SQL statement.
[0037] The system receives the user's current query statement and the table structure of the target table retrieved by the front-end module, and inputs both into the large language model. The model automatically understands the intent of the current question by analogy with the example logic in the query example library and extracts the query conditions. The extracted query conditions are mapped and aligned with the field attributes of the current target table to generate the first version of the initial SQL statement.
[0038] For example, if the input query is "What will be the permanent population of area A next year?", the LLM extracts the query conditions as "Region: Area A; Query attribute: Number of people". Then, according to the query conditions, it selects the two attributes of region and number of people in the target table for mapping and alignment.
[0039] Furthermore, the initial SQL statement is executed on a trial basis to obtain error information.
[0040] like Figure 2 As shown, a dedicated external SQL execution agent is invoked to send the generated initial SQL statement to the real database environment for execution, testing whether the SQL statement can run normally. If the execution is successful, the SQL logic is directly confirmed to be correct, and the final SQL and query results are output. If the execution fails, the agent will capture the specific database error information (such as syntax errors, field mismatches, etc.) and send the error feedback back to the LLM.
[0041] Further, the error information is processed by regular expression matching to obtain a core error description; the actual information of the target table is obtained, and the core error description, the initial SQL statement, and the actual information are concatenated to obtain a feedback instruction; the feedback instruction is anonymized to obtain feedback information.
[0042] Since raw database errors often contain a large number of redundant characters and system-level paths, directly feeding back these errors would waste LLM context tokens and even interfere with the model's attention. Therefore, an "error message preprocessing" step needs to be added.
[0043] The specific steps of error message preprocessing include: 1. Core error extraction: Using regular expressions or exception handling modules, the execution stack of the underlying code is stripped away to extract only the core error description returned by the database (such as the error (ERROR) field mentioned above). 2. Context Restructuring and Guidance: The extracted core error message, the abnormal SQL statement that triggered the error, and the correct header and field types of the target table are formatted and concatenated to obtain prompts that instruct the LLM to self-correct. For example, it can be restructured as "The following error occurred when executing the SQL you generated [abnormal SQL]: [core error], please correct the SQL according to the actual structure of the table [header attributes] and re-output it"; 3. Desensitization and interception: If the original error message exposes the Internet Protocol (IP) address or core architecture information of the underlying database, the preprocessing script needs to perform regular expression desensitization and replace it with a general placeholder to prevent sensitive information from entering the LLM environment.
[0044] This preprocessing step addresses the issues of "long text attention distraction" and token overrun caused by long stack logs in the underlying database. By precisely feeding "lesions (errors) + reference objects (table structures)," it greatly improves the self-correction success rate of LLM, reduces the number of ineffective iterative trials, and thus lowers the overall system response latency.
[0045] Furthermore, the initial SQL statement is corrected using the large language model based on the feedback information and the query example library to obtain the target SQL statement.
[0046] LLM re-examines the target table structure and corrects the SQL statement based on the feedback information, and then submits it for trial run again. This execution-feedback loop will continue until the SQL runs successfully or the preset maximum number of iterations is reached.
[0047] LLM can typically correct the following types of raw database errors: 1. Field or table name does not exist (illusion error): For example, the large model may have fabricated column names. When correcting this, the LLM should be prompted to re-examine the actual column names in the table structure. 2. SQL syntax or logical errors (syntax errors): such as missing keywords or improper use of aggregate functions; 3. Data type mismatch (type error): For example, directly comparing a string with a number. When correcting, the LLM prompts that the data type needs to be converted using the CAST function or quotation marks need to be added. The CAST function is a data type conversion function in the SQL standard.
[0048] Step S30: Perform query processing on the table database according to the target SQL statement to obtain the historical data sequence, determine the time series prediction model, and expand the historical data sequence through the time series prediction model to obtain the target data sequence.
[0049] Specifically, the target SQL statement is used to perform a query in the table database to obtain query results, and the query results are converted into a list of values to obtain a historical data sequence.
[0050] like Figure 2 As shown, the final generated SQL statement is executed to obtain the query results. The query results are then input into the predictor module to generate a data sequence that integrates historical and future data.
[0051] The query data is preprocessed to transform the query results into a historical data sequence, such as a list of triples containing project name, year, and number of people. Then, the length of the historical data sequence is fixed according to the length of the list, and placeholders are filled for any missing parts of the data.
[0052] Furthermore, a time series baseline model is determined, and the missing values in the historical data sequence are filled in using the time series baseline model to obtain the sequence to be predicted.
[0053] The TimesNet model is used to interpolate and fill in missing values in historical sequences to generate complete historical sequences. For example, if there is no data for a certain month, the data for that month needs to be filled in. TimesNet is a time series analysis model that can capture complex time patterns more effectively by converting one-dimensional time series into two-dimensional tensors. It is suitable for various tasks such as prediction, interpolation, classification, and anomaly detection.
[0054] Furthermore, a time series prediction model is determined, and the prediction process is performed on the sequence to be predicted using the time series prediction model to obtain future prediction data. The target data sequence is then obtained based on the future prediction data and the historical data sequence.
[0055] Based on the imputed sequence, the TimeXer model is invoked to predict data trends over a specific future time period (e.g., the next 12 months), returning a target data sequence containing the predicted future data. This target data sequence is used for subsequent data analysis. The TimeXer model is a time series forecasting model that incorporates exogenous variables.
[0056] Step S40: The user query statement is classified using the large language model to obtain the query type, and the target data sequence is transformed according to the query type to obtain the query answer.
[0057] Specifically, the query type includes a first query type and a second query type; the user query statement is classified by the large language model to obtain the query type; when the query type is the first query type, the target data sequence is numerically extracted by the large language model to obtain key values, and the key values are converted into natural language to obtain the query answer.
[0058] The analyzer module performs data analysis based on the target data sequence integrated by the predictor module to answer the user's query.
[0059] like Figure 2 As shown, a classifier (Bidirectional Encoder Representations from Transformers, BERT) or LLM is used to determine whether the intent of a user's query statement belongs to "Time Series Forecasting" or "Forecast-based Reasoning".
[0060] Time series forecasting focuses on specific numerical results. Users directly ask for a specific data point in the future (e.g., "How many people will there be next year?"), and the system only needs to output the predicted number. Forecast-based reasoning, on the other hand, focuses on comparisons, trend judgments, or logical conclusions. Users ask for the analysis results based on future data (e.g., "Will the overall trend of data increase or decrease over the next ten years?"). The system must first predict the value, then perform logical comparisons, and finally output a qualitative conclusion (such as "increase", "decrease", or the item name).
[0061] like Figure 2 As shown, for time series prediction problems, specialized numerical extraction prompts are used to limit LLM output to only key numerical results, avoiding redundant text.
[0062] Specifically, the key numerical result refers to the pure number (or set of numbers) that the model calculates to directly answer the user's question. All unnecessary words, unit descriptions, derivation processes, or irrelevant punctuation have been removed. During processing, all modifiers such as "because therefore" and "will be" are removed, and the remaining pure predicted number (e.g., 16887) is used as the output result. The purpose is to allow subsequent systems to read and use it directly.
[0063] Furthermore, when the query type is the second query type, the target data sequence is analyzed and processed by the large language model to obtain the analysis results, and the analysis results are processed by natural language conversion to obtain the query answer.
[0064] like Figure 2 As shown, for prediction-based reasoning problems, historical and predicted data are provided as context (in the form of key-value pairs) to guide LLM to compare, sort, or perform trend analysis, and derive reasoning conclusions as output.
[0065] The key innovations of this invention include: 1. Three-agent collaborative architecture: This paper proposes an architecture that decouples the open-domain future prediction question answering task into three independent agents: Retriever, Forecaster, and Analyzer. Existing technologies usually process the task end-to-end with a single model. This solution solves the problem that LLM cannot handle complex retrieval and accurate numerical prediction at the same time by dividing the roles. 2. "Abstract-Generation-Feedback" retrieval mechanism: an indirect retrieval method that utilizes LLM to first generate table titles and then retrieve the table, and an execution-feedback self-correction mechanism for SQL generation; 3. Prediction method combining LLM with professional time series models: LLM is used as the controller to handle semantic understanding, while specialized models such as TimesNet and TimeXer are used to handle numerical computation (filling in and prediction), and the two are connected through a tool call interface; 4. Adaptive response generation based on query classification: Automatically identifies "prediction" and "reasoning" intentions, and calls the numerical extraction module or logical reasoning module respectively to standardize the response format.
[0066] Possible design modifications to this invention include: 1. Replacement of time series models: The external models (TimesNet and TimeXer) called in the predictor can be replaced with other advanced time series prediction models (such as TimeMixer, i-Transformer, AutoTimes and Time-MoE, etc.), or replaced with traditional prediction models based on statistics (such as ARIMA), without changing the overall framework and process; 2. Replacement of retrieval algorithm: The BM25 algorithm in the table retrieval stage can be replaced by a vector-based dense retrieval algorithm, which matches by calculating the cosine similarity between the query vector and the table vector; 3. Expansion of application areas: This method can be directly migrated to other vertical fields such as meteorological data, only requiring a change of the underlying database; 4. In the prediction phase, in addition to using historical target variables, external covariates can be introduced into the prediction model to improve prediction accuracy.
[0067] This invention generates an SQL statement based on the user's query and performs a query in a table database to obtain a historical data sequence. The historical data sequence is then expanded using a time series prediction model to obtain a target data sequence. Finally, the target data sequence is transformed using a large language model to obtain the query answer, thereby improving the prediction accuracy of the table-based question-and-answer system.
[0068] Furthermore, such as Figure 3 As shown, based on the above-described open-domain table question-answering method for future data prediction, this invention also provides an open-domain table question-answering system for future data prediction, wherein the open-domain table question-answering system for future data prediction includes: The table matching module 51 is used to obtain the user query statement and the table database, determine the large language model, and filter the table database according to the user query statement through the large language model to obtain the target table. SQL statement generation module 52 is used to perform SQL statement generation processing based on the user query statement and the target table through the large language model to obtain the target SQL statement; The data prediction module 53 is used to perform query processing on the table database according to the target SQL statement to obtain historical data sequences, determine a time series prediction model, and extend the historical data sequences through the time series prediction model to obtain the target data sequence. The answer generation module 54 is used to classify the user query statement through the large language model to obtain the query type, and to perform data transformation processing on the target data sequence according to the query type to obtain the query answer.
[0069] Furthermore, such as Figure 4 As shown, based on the above-mentioned open-domain table question-answering method and system for future data prediction, the present invention also provides a terminal, which includes a processor 10, a memory 20 and a display 30. Figure 4 Only some of the terminal components are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0070] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory. In other embodiments, the memory 20 may be an external storage device of the terminal, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Further, the memory 20 may include both internal and external storage devices. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code installed on the terminal. The memory 20 can also be used to temporarily store data that has been output or will be output. In one embodiment, the memory 20 stores an open-domain table question-and-answer program 40 for future data prediction, which can be executed by the processor 10 to implement the open-domain table question-and-answer method for future data prediction in this application.
[0071] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in the memory 20 or process data, such as executing the open-domain table question-and-answer method for future data prediction.
[0072] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 30 is used to display information on the terminal and to display a visual user interface.
[0073] In one embodiment, when processor 10 executes open-domain table question-and-answer program 40 for future data prediction in memory 20, the following steps are performed: Obtain the user query statement and table database, determine the large language model, and filter the table database according to the user query statement using the large language model to obtain the target table; The target SQL statement is obtained by generating an SQL statement based on the user query and the target table using the large language model. The target SQL statement is used to query the table database to obtain historical data sequences, and a time series prediction model is determined. The historical data sequences are then extended using the time series prediction model to obtain the target data sequence. The user query statement is classified using the large language model to obtain the query type, and the target data sequence is transformed according to the query type to obtain the query answer.
[0074] The steps of obtaining user query statements and table databases, determining a large language model, and filtering the table database based on the user query statements using the large language model to obtain the target table specifically include: Obtain the user query statement, determine the large language model, and rewrite the user query statement using the large language model to obtain the table title summary; Obtain the table database, and directly match the table title summary with the table database. If a direct match result is obtained, the direct match result is used as the target table. If a direct match cannot be obtained, a text retrieval algorithm is determined, and the relevance calculation is performed on the table title summary and the tables in the table database using the text retrieval algorithm to obtain the target table.
[0075] Specifically, the step of generating a target SQL statement by using the large language model based on the user query and the target table includes: Obtain query examples and add them to the system suggestion words of the large language model to obtain a query example library; The user query statement and the query example library are compared using the large language model to obtain the query intent. The query intent and the target table are then mapped and aligned to obtain the initial SQL statement. The initial SQL statement is modified to obtain the target SQL statement.
[0076] Specifically, the step of modifying the initial SQL statement to obtain the target SQL statement includes: The initial SQL statement was executed on a trial basis, and an error message was obtained. The error information is cleaned to obtain feedback information; The initial SQL statement is corrected using the large language model based on the feedback information and the query example library to obtain the target SQL statement.
[0077] Specifically, the step of performing data cleaning processing on the error information to obtain feedback information includes: The error message is processed using regular expression matching to obtain the core error description; Obtain the actual information of the target table, and concatenate the core error description, the initial SQL statement, and the actual information to obtain the feedback instruction; The feedback instructions are de-identified to obtain feedback information.
[0078] Specifically, the process of querying the table database according to the target SQL statement to obtain a historical data sequence, determining a time series prediction model, and expanding the historical data sequence using the time series prediction model to obtain the target data sequence includes: The target SQL statement is used to perform a query in the table database to obtain the query results, and the query results are converted into a list of values to obtain a historical data sequence. A time series baseline model is determined, and missing values in the historical data sequence are filled in using the time series baseline model to obtain the sequence to be predicted; A time series forecasting model is determined, and the forecasting process is performed on the sequence to be predicted using the time series forecasting model to obtain future forecast data. The target data sequence is then obtained based on the future forecast data and the historical data sequence.
[0079] The query types include a first query type and a second query type; The process of classifying the user's query statement using the large language model to obtain the query type, and then performing data transformation on the target data sequence based on the query type to obtain the query answer, specifically includes: The user query statement is categorized using the large language model to obtain the query type. When the query type is the first query type, the target data sequence is numerically extracted using the large language model to obtain key values, and the key values are then converted into natural language to obtain the query answer. When the query type is the second query type, the target data sequence is analyzed and processed by the large language model to obtain the analysis results, and the analysis results are processed by natural language conversion to obtain the query answer.
[0080] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores an open-domain table question-and-answer program for future data prediction, and the open-domain table question-and-answer program for future data prediction, when executed by a processor, implements the steps of the open-domain table question-and-answer method for future data prediction as described above.
[0081] In summary, this invention provides an open-domain table-based question-answering method, system, terminal, and computer-readable storage medium for future data prediction. The method includes: acquiring a user query statement and a table database; determining a large language model; filtering the table database using the large language model based on the user query statement to obtain a target table; generating an SQL statement using the large language model based on the user query statement and the target table to obtain a target SQL statement; querying the table database using the target SQL statement to obtain a historical data sequence and determining a time series prediction model; expanding the historical data sequence using the time series prediction model to obtain a target data sequence; classifying the user query statement using the large language model to obtain a query type; and transforming the target data sequence according to the query type to obtain a query answer. This invention improves the prediction accuracy of the table-based question-answering system by generating an SQL statement from the user query statement, querying the table database to obtain a historical data sequence, expanding the historical data sequence using a time series prediction model to obtain a target data sequence, and transforming the target data sequence using a large language model to obtain a query answer.
[0082] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal. Unless otherwise specified, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or terminal that includes that element.
[0083] Of course, those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.). The program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The computer-readable storage medium can be a memory, magnetic disk, optical disk, etc.
[0084] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. An open-domain table-based question-answering method for future data prediction, characterized in that, The open-domain table question-answering method for future data prediction includes: Obtain the user query statement and table database, determine the large language model, and filter the table database according to the user query statement using the large language model to obtain the target table; The target SQL statement is obtained by generating an SQL statement based on the user query and the target table using the large language model. The target SQL statement is used to query the table database to obtain historical data sequences, and a time series prediction model is determined. The historical data sequences are then extended using the time series prediction model to obtain the target data sequence. The user query statement is classified using the large language model to obtain the query type, and the target data sequence is transformed according to the query type to obtain the query answer.
2. The open-domain table question-answering method for future data prediction according to claim 1, characterized in that, The process of obtaining the user query statement and table database, determining the large language model, and filtering the table database according to the user query statement using the large language model to obtain the target table specifically includes: Obtain the user query statement, determine the large language model, and rewrite the user query statement using the large language model to obtain the table title summary; Obtain the table database, and directly match the table title summary with the table database. If a direct match result is obtained, the direct match result is used as the target table. If a direct match cannot be obtained, a text retrieval algorithm is determined, and the relevance calculation is performed on the table title summary and the tables in the table database using the text retrieval algorithm to obtain the target table.
3. The open-domain table question-answering method for future data prediction according to claim 1, characterized in that, The process of generating the target SQL statement using the large language model based on the user query and the target table specifically includes: Obtain query examples and add them to the system suggestion words of the large language model to obtain a query example library; The user query statement and the query example library are compared using the large language model to obtain the query intent. The query intent and the target table are then mapped and aligned to obtain the initial SQL statement. The initial SQL statement is modified to obtain the target SQL statement.
4. The open-domain table question-answering method for future data prediction according to claim 3, characterized in that, The step of modifying the initial SQL statement to obtain the target SQL statement specifically includes: The initial SQL statement was executed on a trial basis, and an error message was obtained. The error information is cleaned to obtain feedback information; The initial SQL statement is corrected using the large language model based on the feedback information and the query example library to obtain the target SQL statement.
5. The open-domain table question-answering method for future data prediction according to claim 4, characterized in that, The step of cleaning and processing the error information to obtain feedback information specifically includes: The error message is processed using regular expression matching to obtain the core error description; Obtain the actual information of the target table, and concatenate the core error description, the initial SQL statement, and the actual information to obtain the feedback instruction; The feedback instructions are de-identified to obtain feedback information.
6. The open-domain table-based question-answering method for future data prediction according to claim 1, characterized in that, The process of querying the table database according to the target SQL statement to obtain a historical data sequence, determining a time series prediction model, and expanding the historical data sequence using the time series prediction model to obtain the target data sequence specifically includes: The target SQL statement is used to perform a query in the table database to obtain the query results, and the query results are converted into a list of values to obtain a historical data sequence. A time series baseline model is determined, and missing values in the historical data sequence are filled in using the time series baseline model to obtain the sequence to be predicted; A time series forecasting model is determined, and the forecasting process is performed on the sequence to be predicted using the time series forecasting model to obtain future forecast data. The target data sequence is then obtained based on the future forecast data and the historical data sequence.
7. The open-domain table-based question-answering method for future data prediction according to claim 1, characterized in that, The query types include a first query type and a second query type; The process of classifying the user's query statement using the large language model to obtain the query type, and then performing data transformation on the target data sequence based on the query type to obtain the query answer, specifically includes: The user query statement is categorized using the large language model to obtain the query type. When the query type is the first query type, the target data sequence is numerically extracted using the large language model to obtain key values, and the key values are then converted into natural language to obtain the query answer. When the query type is the second query type, the target data sequence is analyzed and processed by the large language model to obtain the analysis results, and the analysis results are processed by natural language conversion to obtain the query answer.
8. An open-domain table-based question-answering system for future data prediction, characterized in that, The open-domain table-based question-and-answer system for future data prediction includes: The table matching module is used to obtain the user's query statement and the table database, determine the large language model, and filter the table database according to the user's query statement using the large language model to obtain the target table. The SQL statement generation module is used to generate the target SQL statement by performing SQL statement generation processing based on the user query statement and the target table through the large language model. The data prediction module is used to perform query processing on the table database according to the target SQL statement to obtain historical data sequences, determine a time series prediction model, and expand the historical data sequences through the time series prediction model to obtain the target data sequence. The answer generation module is used to classify the user query statement through the large language model to obtain the query type, and to perform data transformation processing on the target data sequence according to the query type to obtain the query answer.
9. A terminal, characterized in that, The terminal includes a memory, a processor, and an open-domain table question-and-answer program for future data prediction stored in the memory and executable on the processor. When the processor executes the open-domain table question-and-answer program for future data prediction, it implements the steps of the open-domain table question-and-answer method for future data prediction as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an open-domain table question-and-answer program for future data prediction, which, when executed by a processor, implements the steps of the open-domain table question-and-answer method for future data prediction as described in any one of claims 1-7.