Methods, devices, media, equipment, and programs for searching and answering questions in tables.
By generating search suggestions and dynamically switching search strategies, the problem of insufficient accuracy and adaptability of table-based question and answer services in complex enterprise environments has been solved, achieving efficient and accurate table-based question and answer services in enterprise environments.
Patent Information
- Application Number
- CN202510942423.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-07-08
AI Technical Summary
Existing table-based question-answering technologies cannot generate accurate SQL in complex enterprise environments, and semantic retrieval is limited by pre-training and fine-tuning, making it unable to adapt to changes in the enterprise environment, resulting in unreliable search results.
By generating search suggestions, the first major model is used for search planning. Combining candidate table data and query questions, the search strategy is dynamically switched, and the second major model is used to generate answers, thus realizing the query of the target table data.
It improves the accuracy and flexibility of form-based question and answer in complex enterprise environments, reduces retrieval costs, and adapts to frequent changes in the enterprise environment.
Smart Images

Figure CN120429310B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of intelligent retrieval technology, specifically to a retrieval question-and-answer method, apparatus, medium, device, and program product for tables. Background Technology
[0002] Table-based question-and-answer retrieval is typically achieved through Natural Language to Structured Query Language (NL2SQL) or semantic retrieval.
[0003] In related technologies, traditional NL2SQL relies on the structure and naming of database schemas to generate Structured Query Language (SQL). This fails to generate accurate SQL in complex enterprise environments, leading to unreliable search results. Furthermore, semantic retrieval, through pre-training and fine-tuning of a general-purpose LLM (Large Language Model) to adapt to specific tabular databases for semantic question-answering, suffers from limitations imposed by pre-training and fine-tuning, making it unsuitable for tabular question-answering retrieval in complex enterprise environments. In summary, neither of the aforementioned methods can effectively perform question-answering retrieval in complex enterprise environments using appropriate search techniques. Summary of the Invention
[0004] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] Firstly, this disclosure provides a retrieval question-and-answer method for tables, the retrieval question-and-answer method for tables including:
[0006] In response to a user's input query, a pre-retrieval is performed in the tabular database based on the query to obtain candidate tabular data for answering the query.
[0007] Based on the candidate table data and the query question, generate a search suggestion statement;
[0008] The first major model is used to perform retrieval planning based on the retrieval prompts to obtain a retrieval strategy;
[0009] Based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data, target table data for answering the query question is obtained;
[0010] The second major model generates an answer to the query question based on the target table data.
[0011] Secondly, this disclosure provides a query-answering device for tables, the query-answering device for tables comprising:
[0012] The response module is configured to respond to a user-input query by performing a pre-retrieval in a tabular database based on the query to obtain candidate tabular data for answering the query.
[0013] The first generation module is configured to generate search suggestion statements based on the candidate table data and the query question;
[0014] The retrieval planning module is configured to perform retrieval planning based on the retrieval prompt statement using the first major model to obtain a retrieval strategy.
[0015] The execution module is configured to obtain target table data for answering the query question based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data.
[0016] The second generation module is configured to generate an answer to the query question based on the target table data using a second major model.
[0017] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the method described in the first aspect.
[0018] Fourthly, this disclosure provides an electronic device, comprising:
[0019] A storage device on which computer programs are stored;
[0020] A processing device for executing the computer program in the storage device to implement the method described in the first aspect.
[0021] In another aspect, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0022] The above technical solution generates search suggestions based on the query question and pre-retrieved candidate table data. The candidate table data changes according to the search scenario, allowing for the generation of search suggestions tailored to different search scenarios. Subsequently, the first major model performs search planning based on these suggestions, determining corresponding search strategies for different scenarios. This enables flexible switching between different search strategies in complex enterprise environments, meeting the table-based question-and-answer search needs in such environments. Furthermore, determining the target table data based on the search strategy, search suggestions, and candidate table data allows for query backtracking of the target table data, improving the accuracy of the target table data in the search results and thus enhancing the accuracy of table-based question-and-answer in complex enterprise environments.
[0023] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0024] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:
[0025] Figure 1 This is a flowchart illustrating a retrieval question-and-answer method for tables according to an exemplary embodiment of this disclosure.
[0026] Figure 2 This is a schematic diagram illustrating a search plan according to an exemplary embodiment of the present disclosure.
[0027] Figure 3 This is a flowchart illustrating a record retrieval strategy according to an exemplary embodiment of this disclosure.
[0028] Figure 4 This is another flowchart illustrating a record retrieval strategy according to an exemplary embodiment of this disclosure.
[0029] Figure 5 This is a flowchart illustrating an analysis and retrieval strategy according to an exemplary embodiment of the present disclosure.
[0030] Figure 6 This is another flowchart illustrating a retrieval question-and-answer method for tables according to an exemplary embodiment of this disclosure.
[0031] Figure 7 This is another flowchart illustrating a retrieval question-and-answer method for tables according to an exemplary embodiment of the present disclosure.
[0032] Figure 8This is a block diagram illustrating a table retrieval question-and-answer device according to an exemplary embodiment of the present disclosure.
[0033] Figure 9 This is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation
[0034] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0035] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0036] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0037] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0038] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0039] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0040] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0041] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0042] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0043] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0044] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0045] It's worth noting that NL2SQL achieves tabular data access by converting natural language questions into SQL to retrieve relevant data. Semantic retrieval pre-trains and fine-tunes a general LLM based on a specific tabular database to obtain an LLM adapted to that database, and then performs semantic retrieval within that database using the LLM. However, in real-world enterprise environments, the complexity of question-answering retrieval tasks increases exponentially, primarily in the following aspects:
[0046] I. The Schema-Linking Paradox in Complex Enterprise Environments:
[0047] 1. Schema Ambiguity: In enterprise environments, tabular database schemas often suffer from large scale and high complexity, integration of multiple data sources, frequent version iterations, and legacy issues. This results in a large number of semantically similar or poorly named tables and columns (e.g., consumer_1, dept_2022, usage cost 1, text). Incorrect table or column selection can lead to SQL generation failures, making it extremely difficult for NL2SQL to accurately determine the true intent of the user's query.
[0048] 2. Schema Complexity: Enterprise-level query answering often involves complex business logic that is not explicitly defined in tabular databases. For example, queries may require complex joins across multiple tables, with join conditions involving multiple columns or even non-equi-joins; or they may require advanced operations such as window functions and Common Table Expressions (CTEs). NL2SQL often performs poorly when synthesizing these complex queries that require a deep understanding of table relationships and implicit business rules.
[0049] 3. The Inherent Paradox of Schema-Linking: When dealing with complex schemas, NL2SQL introduces a large amount of irrelevant noise into the LLM by using the entire massive database schema as context input. This not only significantly increases computational costs but may also interfere with the model's focus, leading to performance degradation. On the other hand, pruning the schema to reduce noise (i.e., schema linking) carries a very high risk: incorrectly excluding any necessary table or column inevitably generates incorrect SQL. This inherent conflict between minimizing noise and preserving critical information constitutes a significant obstacle that current technologies struggle to overcome.
[0050] II. The high cost and unreliability of LLM customization solutions:
[0051] 1. Limitations of Fine-Tuning: While fine-tuning enables general-purpose LLMs to learn domain-specific knowledge, this process is costly, labor-intensive, and lacks scalability. For dynamic enterprise environments where patterns and data content change frequently, continuously re-fine-tuning models to maintain their freshness is both operationally and economically impractical. Furthermore, for data platforms supporting ToB (To Business) operations, the diversity of domain knowledge among different enterprises and the scarcity of data from individual enterprises within the platform's perspective amplify this problem.
[0052] 2. Limitations of Few-Shot Learning: While guiding the model by providing a small number of query examples in the prompt is less costly than fine-tuning, its reliability is highly questionable. First, the output of a general-purpose LLM is extremely sensitive to the wording of the prompt and the choice of examples; even small changes can lead to significant differences in results, lacking stability. Second, research shows that few-shot learning has poor generalization ability, and its performance drops sharply when faced with new, unseen databases or domains. The most critical challenge is that the most efficient examples are those from the same domain as the target query (i.e., the same tabular database or table). However, manually creating and maintaining a comprehensive, high-quality example library for hundreds or thousands of tables in an enterprise implies extremely high operational costs. Furthermore, configuring examples or summaries for hundreds of thousands or even more data points in a single large table faces the dilemma of information compression ratio, making it difficult to balance effectiveness and configuration costs.
[0053] In summary, existing table-based question-answering technologies are primarily developing along two paths: NL2SQL and semantic retrieval. Both paths have irreconcilable drawbacks. NL2SQL is too rigid and cannot adapt to the complexities of the real world; while semantic retrieval, based on general-purpose LLM customization, is too expensive and unreliable, making it difficult to deploy at scale in enterprises. Neither path provides an enterprise-level solution that combines accuracy, adaptability, and cost-effectiveness.
[0054] In view of the above, this disclosure provides a method, apparatus, medium, device and program product for searching and answering questions in tables, in order to solve some or all of the above-mentioned technical problems.
[0055] The embodiments of this disclosure will be further explained below with reference to the accompanying drawings.
[0056] Figure 1 This is a flowchart illustrating a retrieval question-and-answer method for tables according to an exemplary embodiment of this disclosure. For example... Figure 1 As shown, the retrieval question-and-answer method for tables may include the following steps:
[0057] In step S11, in response to the query question input by the user, a pre-retrieval is performed in the table database based on the query question to obtain candidate table data for answering the query question.
[0058] In step S12, a search suggestion statement is generated based on the candidate table data and the query question.
[0059] In step S13, the first major model performs retrieval planning based on retrieval prompts to obtain a retrieval strategy.
[0060] In step S14, target table data for answering the query question is obtained based on the retrieval strategy, retrieval prompts, and candidate table data.
[0061] In step S15, the second model generates an answer to the query question based on the target table data.
[0062] It is worth noting that, based on the query question and the candidate table data obtained from the pre-retrieval, a search suggestion statement is generated. This statement is then used by the first major model to determine the subsequent search strategy for calling the natural language to the structured query module (i.e., the NL2SQL module) and / or the open search module (i.e., the OpenSearch module). This enables the optional fusion of NL2SQL for retrieval and question answering within the semantic retrieval chain.
[0063] In this embodiment, search suggestions provide the basis for search planning. Since the search suggestions include candidate sample data and the query question, and the candidate sample data originates from the tabular database being queried by the user (which is domain-specific data), the search suggestions have domain relevance. Furthermore, the candidate sample data is obtained through semantic retrieval based on the current query question, thus the search suggestions have high query relevance. On the other hand, the process of obtaining search suggestions is fully automated, requiring no manual pre-writing or maintenance of a sample library. For example, the search suggestions show the actual data types to the primary model (e.g., the search suggestion indicates that the actual value of a column in the tabular database is "Beijing" instead of "Beijing," or that a date format is YYYY-MM-DD), which greatly improves the primary model's understanding of fuzzy column names, complex data formats, and implicit business rules, thereby generating more accurate and robust SQL queries. This shifts the model from guessing to referencing, improving the accuracy of search results.
[0064] For example, a lightweight, pre-emptive semantic retrieval (pre-retrieval) is performed in the tabular database based on the query question. Based on the entities and intent in the user's query, the pre-retrieval quickly retrieves a small subset (e.g., 10 records) of candidate tabular data (i.e., record details) that are semantically most relevant to the query question. Contextual hints (i.e., query suggestion statements) are generated based on the candidate tabular data and the query question, serving as input to the first main model for subsequent retrieval planning.
[0065] The above technical solution generates search suggestions based on the query question and pre-retrieved candidate table data. The candidate table data changes according to the search scenario, allowing for the generation of search suggestions tailored to different search scenarios. Subsequently, the first major model performs search planning based on these suggestions, determining corresponding search strategies for different table-based question-and-answer scenarios. This enables flexible switching between different search strategies in complex enterprise environments, meeting the table-based question-and-answer search needs in such environments. Furthermore, by determining the target table data based on the search strategy, search suggestions, and candidate table data, the system enables query backtracking of the target table data, improving the accuracy of the target table data in the search results and thus enhancing the accuracy of table-based question-and-answer searches in complex enterprise environments.
[0066] To facilitate understanding of the table retrieval question-and-answer method provided in this disclosure, the following describes possible implementations of this disclosure.
[0067] Among the possible approaches, the primary model can be used for retrieval planning in the following manner:
[0068] Perform intent recognition on the search prompt statements to obtain intent recognition results;
[0069] When the intent recognition result indicates that the query question belongs to a rule-based statistical scenario, the retrieval strategy is determined as the first retrieval strategy. The first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data, or the first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data and retrieve the table data in the candidate table data that is semantically related to the query question.
[0070] If the intent recognition result indicates that the query question belongs to a semantic-based retrieval scenario, the retrieval strategy is determined to be the second retrieval strategy. The second retrieval strategy is used to retrieve table data in the candidate table data that are semantically related to the query question.
[0071] It should be understood that because the search suggestion statement is generated from candidate table data and the query question, it means that for any input query question, a one-time, highly rich contextual suggestion (i.e., search suggestion statement) can be constructed dynamically and instantly at runtime. This search suggestion statement includes the user's original natural language query question, the relevant schema definition of the table database (such as table structure and column information), and real data row samples related to the query question. This eliminates the need for manual schema annotation, writing few-shot suggestion words, or expensive fine-tuning of the primary model, and can automatically adapt to any changes in the database (e.g., added tables, modified column names, changed data content, etc.). By directly drawing from the current table database at the time of the query, it offers scalability and maintainability while reducing retrieval costs.
[0072] It is worth noting that in the process of semantic retrieval or NL2SQL retrieval, the main problem faced by the table question-and-answer scenario is to integrate the semantic-based retrieval scenario and the rule-based statistical scenario. Therefore, by performing intent recognition on the query prompt statement, the retrieval scenario to which the query question belongs can be determined, and then the retrieval strategy under the corresponding retrieval scenario can be determined, so as to achieve dynamic integration of semantic retrieval and NL2SQL retrieval.
[0073] In this embodiment, retrieval planning based on retrieval prompts eliminates the need for expensive and continuous manual intervention, such as model fine-tuning, pattern labeling, or planning and maintenance of small sample examples. This makes the entire retrieval process highly scalable and can seamlessly adapt to the dynamic environment of frequent pattern and data changes in enterprises, solving the core cost and maintenance challenges faced by enterprises when deploying and promoting NL2SQL technology.
[0074] For example, such as Figure 2 As shown, taking SQL to Domain Specific Language (SQL2DSL) retrieval in the NL2SQL class retrieval as an example, SQL2DSL retrieval converts SQL query statements into domain specific language (DSL) query statements in order to retrieve data in certain specific systems or frameworks.
[0075] SQL2DSL retrieval includes four structured query languages: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Data Query Language (DQL). This disclosure embodiment may respond only to DQL. Specifically, DQL includes the following:
[0076] 1. Record retrieval.
[0077] For example, what are some records with a transaction amount greater than 100?
[0078] 2. Maximum and minimum value problems.
[0079] For example, find the record (value) with the largest transaction amount.
[0080] Scenario a: Values:
[0081] Query: What is the maximum transaction amount for office software?
[0082] SQL:
[0083] SELECT*
[0084] FROM translations
[0085] WHERE product_name='Office Software'
[0086] AND amount =(
[0087] SELECT MAX(amount)
[0088] FROM translations
[0089] WHERE product_name='Office Software'
[0090] LIMIT 20 ):
[0092] Scene b: Record:
[0093] Query: Find the record with the largest transaction amount for (all) office software transactions.
[0094] SQL:
[0095] SELECT*
[0096] FROM translations
[0097] WHERE product_name='Office Software'
[0098] AND amount =(
[0099] SELECT MAX(amount)
[0100] FROM translations
[0101] WHERE product_name='Office Software'
[0102] LIMIT 20 ):
[0104] 3. Statistical issues.
[0105] For example, the average transaction value (AVG) / total transaction value (SUM) / number of transactions (COUNT).
[0106] Query: Find all transaction amounts related to office software and calculate their average.
[0107] SQL: SELECT AVG('Amount') FROM 'tbl8QEjWmSoWlomv' WHERE 'Product' = 'Office Software'
[0108] 4. Other issues.
[0109] For example, sorting (ORDER), finding differences (DISTINCT), grouping (GROUP BY), filtering (HAVING); mixed queries: finding both maximum and minimum values and average values simultaneously; multi-table queries (JOIN).
[0110] In summary, NL2SQL retrieval can be divided into three scenarios: Scenario 1, NL2SQL search results and semantic search results can be directly merged; Scenario 2, NL2SQL search results can be merged with semantic search results after adjustment; Scenario 3, NL2SQL search results and semantic search results cannot be merged. The retrieval strategies that can be used in different scenarios can also differ.
[0111] In the above technical solution, by correctly interpreting the user's intent in the search prompt statement, the accuracy of the subsequent SQL generation is greatly improved. Furthermore, based on the intent recognition result, it is determined whether the query question tends to be a statistical scenario that requires precise calculation or a retrieval scenario that tends to find specific information. In this way, the corresponding retrieval strategy is determined, and different retrieval strategies can be flexibly switched to adapt to the dynamic environment in which the patterns and data in enterprises change frequently, thus possessing high scalability.
[0112] In one possible manner, the first retrieval strategy includes an analytical retrieval strategy, or the first retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, wherein the analytical retrieval strategy is used to analyze the table data in the candidate table data that is related to the query question, the record retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question.
[0113] When the intent recognition result indicates that the query problem belongs to a rule-based statistical scenario, the retrieval strategy determined as the first retrieval strategy may include:
[0114] When the intent recognition result indicates that the query problem belongs to the extreme value query or rule-based record retrieval, the retrieval strategy is determined to include record retrieval strategy and semantic retrieval strategy;
[0115] When the intent identification result indicates that the query question belongs to rule-based statistical analysis query, determining the retrieval strategy includes analyzing the retrieval strategy.
[0116] For example, when the intent recognition result indicates that the query problem belongs to the extreme value query, the retrieval strategy includes record retrieval strategy and semantic retrieval strategy, such as Figure 3 As shown, the record retrieval strategy is executed through the Natural Language to Structured Query module, the SQL to Domain-Specific Language module (i.e., the SQL2DSL module), the Validation module, the ReRank module, and the Generate module; the semantic retrieval strategy is executed through the Open Search module, the ReRank module, and the Generate module. The execution path of the first retrieval strategy is shown below. Figure 3 .
[0117] When the intent recognition result represents a query problem that falls under rule-based record retrieval, the retrieval strategy includes record retrieval strategy and semantic retrieval strategy, such as... Figure 4 As shown, the record retrieval strategy is executed through the natural language to structured query module, the SQL to domain-specific language module, the validation module, and the generation module; the semantic retrieval strategy is executed through the open search module, the re-ranking module, and the generation module. The execution path of the first retrieval strategy is shown below. Figure 4 .
[0118] When the intent identification result characterizes the query as a rule-based statistical analysis query, the retrieval strategy includes analytical retrieval strategies, such as... Figure 5 As shown, the record retrieval strategy is executed through the natural language to structured query module, the SQL to domain-specific language module, the validation module, the summary module, and the generation module. The execution path of the first retrieval strategy is shown below. Figure 5 .
[0119] In the above technical solution, the corresponding retrieval strategy is determined based on whether the retrieval results of the three scenarios of NL2SQL retrieval can be integrated with the semantic retrieval results. NL2SQL retrieval and semantic retrieval can be executed in parallel, or NL2SQL retrieval and semantic retrieval can be executed separately. That is, NL2SQL technology is dynamically integrated in the semantic retrieval link to improve the accuracy of subsequent SQL generation and the adaptability of the system.
[0120] In some possible ways, obtaining the target table data for answering the query question based on the retrieval strategy, retrieval suggestions, and candidate table data may include:
[0121] When the retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, the retrieval prompt statement is converted into a first structured query language corresponding to the candidate table data, and a record query is performed in the candidate table of the corresponding candidate table data according to the first structured query language to obtain the first table data. The record retrieval strategy is used to count the table data in the candidate table data that is related to the query question, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question.
[0122] Semantic retrieval is performed based on the query question and candidate table data to obtain the second table data;
[0123] Based on the data in the first table and the data in the second table, determine the target table data to answer the query question.
[0124] It's worth noting that in the process of table-based question-and-answer retrieval using NL2SQL technology, the SQL is primarily generated based on the database schema's structure and naming, and then the retrieval is performed based on the SQL. However, in enterprise application scenarios, database schemas are often vague, incomplete, or even contain errors. This causes NL2SQL technology to fail to generate accurate SQL when faced with poorly named columns, complex business logic, or databases containing inaccurate documents, resulting in unreliable query results.
[0125] For example, such as Figure 6 As shown, in scenarios where NL2SQL search results and semantic search results can be directly merged, or where NL2SQL search results can be adjusted to merge with semantic search results:
[0126] I. Query and Plan:
[0127] a. The input module receives the user's query question in natural language.
[0128] b. The pre-retrieval module performs a pre-retrieval in the tabular database based on the query question, obtains candidate table data, and generates retrieval suggestion statements based on the query question and candidate table data.
[0129] c. The retrieval planning module performs intent recognition on the retrieval prompt statement, determines whether the query question tends to be a statistical scenario or a retrieval scenario, determines the retrieval strategy, and triggers one or two subsequent parallel processing paths.
[0130] II. The retrieval planning module, based on the retrieval strategy, retrieval suggestions, and candidate table data, obtains the target table data used to answer the query question:
[0131] Parallel execution of the NL2SQL path and the Search (i.e., semantic retrieval) path:
[0132] NL2SQL path: The Natural Language to Structured Query module converts the search prompts into preliminary SQL statements. The SQL to Domain-Specific Language module converts the preliminary SQL into an internal table query language, such as FxDB query language. The validation module performs syntax and logic validation on the internal table query language. The search module (i.e., the Search module) performs retrieval based on the validated internal query language to obtain the first table data, and inputs the first table data into the fusion module (i.e., the Merge module).
[0133] Semantic retrieval path: The open search module performs semantic retrieval from the candidate table data according to the query language to obtain the second table data, and then inputs the second table data into the fusion module.
[0134] The fusion module determines the target table data for generating the answer based on the data in the first table and the data in the second table.
[0135] In the above technical solution, the NL2SQL path and the semantic retrieval path are processed in parallel. In the NL2SQL path, reliable SQL is generated based on the search prompts and the search is performed based on the SQL, thereby improving the accuracy of the search results. The output results from the two different paths are merged into target table data, providing a reliable basis for the generation of subsequent answers.
[0136] In possible ways, determining the target table data for answering the query question based on the first table data and the second table data may include:
[0137] The first and second table data corresponding to each candidate table data are merged to obtain the merged table data.
[0138] Based on the relevance of each merged table data to the query question, the target table data for answering the query question is determined.
[0139] For example, such as Figure 6 As shown, when there is only one candidate table to which the candidate table data belongs, and the retrieval strategies include record retrieval and semantic retrieval, the first table data is obtained through the NL2SQL path, and the second table data is obtained through the semantic retrieval path. The fusion module performs fusion processing on the first table data from the NL2SQL path and the second table data from the semantic retrieval path to obtain fused table data.
[0140] In the above technical solution, when searching a candidate table, the fused table data obtained by fusing the search results of the two paths is used as the target table data to generate the answer.
[0141] In possible ways, determining the target table data for answering the query question based on the relevance of each merged table data to the query question may include:
[0142] The merged table data that is most relevant to the query question is selected as the target table data for answering the query question.
[0143] Each fused table data corresponds to a confidence value. The higher the confidence value, the greater the relevance of the fused table data corresponding to that confidence level to the query question.
[0144] For example, such as Figure 6 As shown, the filtering module (i.e., the Grounding module) identifies high-confidence fused table data from the fused table data and uses it as the target table data.
[0145] In the above technical solution, the target table data is determined based on the confidence level, and the fused table data with low confidence level can be removed, thereby reducing the impact of noise on the subsequent generated answers.
[0146] In one possible approach, determining the target table data for answering the query question based on the relevance of each merged table data to the query question may include:
[0147] For each candidate table to which the candidate table data belongs, determine the target fusion table data that is most relevant to the query question among the fusion table data corresponding to the candidate table;
[0148] The target fusion table data with the highest relevance among the target fusion data corresponding to each candidate table is determined as the target table data used to answer the query question.
[0149] For example, such as Figure 7As shown, when there are multiple candidate tables to which the candidate table data belongs, and the retrieval strategies include record retrieval and semantic retrieval, for each candidate table, the retrieval results from the NL2SQL path and semantic retrieval path are fused to obtain fused table data. The target fused table data with the highest relevance corresponding to that candidate table is then determined as the target table data used to answer the query question.
[0150] In the above technical solution, when searching multiple candidate tables, the target fusion data corresponding to each candidate table is first determined, and then the target fusion table data with the highest relevance among the target fusion data corresponding to multiple candidate tables is taken as the target table data for generating the answer.
[0151] In possible ways, based on the retrieval strategy, retrieval suggestions, and candidate table data, the target table data for answering the query can include:
[0152] When the retrieval strategy includes an analytical retrieval strategy, the retrieval suggestion statement is converted into a second structured query language corresponding to the candidate table data. The analytical retrieval strategy is used to analyze the table data in the candidate table data that is related to the query question.
[0153] The second structured query language is used to collect statistical table data related to the query question in the candidate table to which the candidate table data belongs, and the statistical table data is analyzed to obtain the target table data used to answer the query question.
[0154] For example, for example, such as Figure 6 As shown, in scenarios where NL2SQL search results and semantic search results cannot be merged, the following steps are performed:
[0155] I. Query and Plan:
[0156] a. The input module receives the user's query question in natural language.
[0157] b. The pre-retrieval module performs a pre-retrieval in the tabular database based on the query question, obtains candidate table data, and generates retrieval suggestion statements based on the query question and candidate table data.
[0158] c. The retrieval planning module performs intent recognition on the retrieval prompt statement, determines whether the query question tends to be a statistical scenario or a retrieval scenario, determines the retrieval strategy, and triggers one or two subsequent parallel processing paths.
[0159] II. The retrieval planning module, based on the retrieval strategy, retrieval suggestions, and candidate table data, obtains the target table data used to answer the query question:
[0160] Only execute NL2SQL path:
[0161] The NL2SQL module converts the search prompt statement into a preliminary SQL statement. The SQL2DSL module converts the preliminary SQL into a table query language, such as FxDB query language. The validation module performs syntax and logic validation on the table query language. The statistics module (i.e., the Statistic module) performs the search based on the validated table query language to obtain the third table data. The third table data is then input into the summary module, which generates an answer based on the third table data and the SQL.
[0162] In the above technical solution, the NL2SQL path converts natural language queries into precise SQL query statements, which can accurately retrieve data that meets the query conditions from the database. This allows users without professional SQL knowledge to interact with the tabular database through dialogue to obtain relevant data.
[0163] In some possible approaches, candidate table data includes metadata of the table to which the candidate table data belongs. Based on the retrieval strategy, retrieval suggestions, and candidate table data, target table data for answering the query is obtained, which may include:
[0164] When the retrieval strategy includes a semantic retrieval strategy, the subquery statement corresponding to the candidate table data is determined based on the query question and metadata;
[0165] Parallel semantic retrieval is performed in the candidate tables to which the corresponding candidate table data belongs based on the subquery statement to obtain the target table data.
[0166] For example, such as Figure 6 As shown, in a scenario where only semantic retrieval is performed, the following steps are executed:
[0167] I. Query and Plan:
[0168] a. The input module receives the user's query question in natural language.
[0169] b. The pre-retrieval module performs a pre-retrieval in the tabular database based on the query question, obtains candidate table data, and generates retrieval suggestion statements based on the query question and candidate table data.
[0170] c. The retrieval planning module performs intent recognition on the retrieval prompt statement, determines whether the query question tends to be a statistical scenario or a retrieval scenario, determines the retrieval strategy, and triggers one or two subsequent parallel processing paths.
[0171] II. The retrieval planning module, based on the retrieval strategy, retrieval suggestions, and candidate table data, obtains the target table data used to answer the query question:
[0172] Only the Search (i.e., semantic retrieval) path is executed:
[0173] Semantic retrieval path: The open search module performs semantic retrieval from the candidate table data according to the query language to obtain the fourth table data, and inputs the fourth table data to the fusion module. The fusion module determines the target table data to be used to generate the answer based on the fourth table data.
[0174] In the above technical solution, semantic retrieval is performed based on pre-retrieval, and each subquery task in semantic retrieval is searched within the context of a single table. This greatly narrows the search scope, thus avoiding semantic dilution caused by key information being surrounded by a large amount of irrelevant information. It can quickly and accurately locate specific row-level information in the table. On the other hand, because the candidate table data belonging to the same candidate table has a relatively uniform source, the same data structure, and small differences in record length, independent retrieval is performed in the candidate table to which the corresponding candidate table data belongs based on the subquery question. This can eliminate the document length bias inherent in traditional retrieval methods. Regardless of the table length, fair and accurate relevance evaluation can be performed, avoiding result distortion caused by score accumulation or semantic dilution, thereby improving retrieval efficiency.
[0175] Among possible approaches, determining the subquery corresponding to candidate table data based on the query question and metadata may include:
[0176] The query question and metadata are populated into the preset suggestion word template to obtain the target suggestion words. The target suggestion words are used to prompt the third model to rewrite the query statement based on the metadata.
[0177] The target prompt is input into the third model to obtain the subquery statement corresponding to the candidate table data output by the third model.
[0178] Metadata includes table name, column name, and table description.
[0179] In the above technical solution, by analyzing the query question and metadata, the query question is rewritten into a subquery question that is more suitable for execution on the candidate table to which the candidate table data belongs, thereby decomposing the global retrieval task into multiple independent intra-table retrieval tasks and preparing for semantic retrieval.
[0180] Among possible approaches, generating an answer to the query question using a second major model based on the target table data could include:
[0181] When the retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question and to retrieve the table data in the candidate table data that is semantically related to the query question, the second major model generates a first answer to the query question based on the target table data. The first answer includes the answer to the query question and the source data for generating the answer.
[0182] When the retrieval strategy is used to statistically analyze table data in candidate table data that is related to the query question or to retrieve table data in candidate table data that is semantically related to the query question, a second answer to the query question is generated based on the target table data through the second major model. The second answer includes the answer to the query question.
[0183] In this embodiment, by seamlessly integrating analytical and retrieval capabilities, users' broad information needs, ranging from macro-level statistics to micro-level tracing, can be met within a single interactive interface. By providing answers along with supporting evidence, the transparency, explainability, and user trust in the responses are greatly enhanced.
[0184] The following describes the characteristics of three retrieval scenarios in the table retrieval question-answering method provided in this disclosure:
[0185] 1. Scenario 1: NL2SQL search results and semantic search results can be directly merged:
[0186] The query explicitly targets specific, enumerable tabular data, such as "What feedback do customers give when they bring children to the supermarket?" The retrieval path includes NL2SQL (supporting path) and semantic search (primary path). Key activation modules include fusion, re-ranking, filtering, and generation modules. The output includes the answer and metadata about the generated answer.
[0187] 2. Scenario 2: Adjusted NL2SQL search results can be integrated with semantic search results:
[0188] The query question is about statistical extreme values (maximum or minimum values), but it can essentially be traced back to a single or small amount of tabular data, such as "Among transactions with a transaction value greater than 1 million, which transaction has the highest profit?" The retrieval path includes NL2SQL, and key activation modules include the fusion module, re-sorting module, filtering module, and generation module. The output answer includes the answer and metadata of the generated answer.
[0189] 3. Scenario 3: NL2SQL search results and semantic search results cannot be merged:
[0190] The query is for indivisible aggregate statistics, such as averages, counts, and sorting, for example, "transaction amounts related to office software, and calculate their average." The search path includes NL2SQL, and key activated modules include the statistics module, the summary module, and the generation module. The output only includes the answer.
[0191] In summary, the features of the table retrieval question-answering method provided in this disclosure compared to traditional NL2SQL and general LLM can be seen in the table below:
[0192]
[0193] Based on the same concept, this disclosure also provides a retrieval question-and-answer device for tables, such as... Figure 8 As shown, the retrieval and question-answering device 800 for tables includes:
[0194] The response module 801 is configured to respond to a user-input query by performing a pre-retrieval in a tabular database based on the query to obtain candidate tabular data for answering the query.
[0195] The first generation module 802 is configured to generate search suggestion statements based on candidate table data and query questions;
[0196] The retrieval planning module 803 is configured to perform retrieval planning based on the retrieval prompt statement through the first major model to obtain the retrieval strategy;
[0197] Execution module 804 is configured to obtain target table data for answering the query question based on the retrieval strategy, retrieval suggestion statement and candidate table data.
[0198] The second generation module 805 is configured to generate answers to the query questions based on the target table data using the second major model.
[0199] The above technical solution generates search suggestions based on the query question and pre-retrieved candidate table data. The candidate table data changes according to the search scenario, allowing for the generation of search suggestions tailored to different search scenarios. Subsequently, the first major model performs search planning based on these suggestions, determining corresponding search strategies for different table-based question-and-answer scenarios. This enables flexible switching between different search strategies in complex enterprise environments, meeting the table-based question-and-answer search needs in such environments. Furthermore, by determining the target table data based on the search strategy, search suggestions, and candidate table data, the system enables query backtracking of the target table data, improving the accuracy of the target table data in the search results and thus enhancing the accuracy of table-based question-and-answer searches in complex enterprise environments.
[0200] Furthermore, the first major model can be used for retrieval planning in the following way:
[0201] Perform intent recognition on the search prompt statements to obtain intent recognition results;
[0202] When the intent recognition result indicates that the query question belongs to a rule-based statistical scenario, the retrieval strategy is determined as the first retrieval strategy. The first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data, or the first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data and retrieve the table data in the candidate table data that is semantically related to the query question.
[0203] If the intent recognition result indicates that the query question belongs to a semantic-based retrieval scenario, the retrieval strategy is determined to be the second retrieval strategy. The second retrieval strategy is used to retrieve table data in the candidate table data that are semantically related to the query question.
[0204] Furthermore, if the first retrieval strategy includes an analytical retrieval strategy, or if the first retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, the analytical retrieval strategy is used to analyze the table data in the candidate table data that is related to the query question, the record retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question.
[0205] The first major model determines the retrieval strategy, including record retrieval strategy and semantic retrieval strategy, when the intent recognition result indicates that the query problem belongs to the extreme value query or rule-based record retrieval.
[0206] The first major model determines the retrieval strategy, including analyzing the retrieval strategy, when the intent recognition result indicates that the query problem belongs to rule-based statistical analysis query.
[0207] Furthermore, the execution module 804 is configured to, when the retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, convert the retrieval prompt statement into a first structured query language corresponding to the candidate table data, and perform a record query in the candidate table to which the corresponding candidate table data belongs according to the first structured query language to obtain the first table data. The record retrieval strategy is used to count the table data related to the query question in the candidate table data, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data whose semantics are related to the query question.
[0208] Semantic retrieval is performed based on the query question and candidate table data to obtain the second table data;
[0209] Based on the data in the first table and the data in the second table, determine the target table data to answer the query question.
[0210] Furthermore, the execution module 804 is configured to merge the first table data and the second table data corresponding to each candidate table data to obtain merged table data.
[0211] Based on the relevance of each merged table data to the query question, the target table data for answering the query question is determined.
[0212] Furthermore, the execution module 804 is configured to determine the fusion table data that is most relevant to the query question among the fusion table data as the target table data for answering the query question.
[0213] Furthermore, the execution module 804 is configured to determine, for each candidate table to which the candidate table data belongs, the target fusion table data that is most relevant to the query question among the fusion table data corresponding to the candidate table;
[0214] The target fusion table data with the highest relevance among the target fusion data corresponding to each candidate table is determined as the target table data used to answer the query question.
[0215] Furthermore, the execution module 804 is configured to convert the search suggestion statement into a second structured query language corresponding to the candidate table data when the search strategy includes an analysis search strategy, wherein the analysis search strategy is used to analyze the table data in the candidate table data that is related to the query question.
[0216] The second structured query language is used to collect statistical table data related to the query question in the candidate table to which the candidate table data belongs, and the statistical table data is analyzed to obtain the target table data used to answer the query question.
[0217] Furthermore, the candidate table data includes metadata of the table to which the candidate table data belongs. The execution module 804 is configured to determine the subquery statement corresponding to the candidate table data based on the query question and metadata, provided that the retrieval strategy includes a semantic retrieval strategy.
[0218] Parallel semantic retrieval is performed in the candidate tables to which the corresponding candidate table data belongs based on the subquery statement to obtain the target table data.
[0219] Furthermore, the execution module 804 is configured to populate the query question and metadata into a preset prompt word template to obtain target prompt words, wherein the target prompt words are used to prompt the third model to rewrite the query statement based on the metadata;
[0220] Input the target prompts into the third model to obtain the subquery statements corresponding to the candidate table data output by the third model.
[0221] Furthermore, the execution module 804 is configured to, when the retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question and to retrieve the table data in the candidate table data that is semantically related to the query question, generate a first answer for the query question based on the target table data through the second major model. The first answer includes the answer to the query question and the source data for generating the answer.
[0222] When the retrieval strategy is used to statistically analyze table data in candidate table data that is related to the query question or to retrieve table data in candidate table data that is semantically related to the query question, a second answer to the query question is generated based on the target table data through the second major model. The second answer includes the answer to the query question.
[0223] The specific manner in which each module performs its operation in the table retrieval question-and-answer device 800 in the above embodiments has been described in detail in the embodiments related to the method, and will not be elaborated here.
[0224] Based on the same concept, embodiments of this disclosure also provide a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements any of the above-described methods for searching and answering questions for tables.
[0225] Based on the same concept, this disclosure also provides an electronic device that may include:
[0226] A storage device on which computer programs are stored;
[0227] A processing device for executing the computer program in the storage device to implement any of the above-described methods for querying and answering questions for tables.
[0228] Based on the same concept, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements any of the above-described methods for searching and answering questions for tables.
[0229] The following is for reference. Figure 9 The diagram illustrates a structural schematic of an electronic device 900 suitable for implementing embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0230] like Figure 9 As shown, electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 901, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 902 or a program loaded from storage device 908 into random access memory (RAM) 903. RAM 903 also stores various programs and data required for the operation of electronic device 900. Processing device 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.
[0231] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0232] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of embodiments of this disclosure.
[0233] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0234] In some implementations, communication can be conducted using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol), and can be interconnected with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0235] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0236] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: respond to a query input by a user, perform a pre-retrieval in a tabular database based on the query to obtain candidate tabular data for answering the query;
[0237] Based on the candidate table data and the query question, generate a search suggestion statement;
[0238] The first major model is used to perform retrieval planning based on the retrieval prompts to obtain a retrieval strategy;
[0239] Based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data, target table data for answering the query question is obtained;
[0240] The second major model generates an answer to the query question based on the target table data.
[0241] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0242] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0243] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules are not, in some cases, intended to limit the functionality of the module itself.
[0244] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0245] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0246] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0247] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0248] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.
Claims
1. A retrieval question-and-answer method for tables, characterized in that, The retrieval and question-answering method for tables includes: In response to a user's input query, a pre-retrieval is performed in the tabular database based on the query to obtain candidate tabular data for answering the query. Based on the candidate table data and the query question, generate a search suggestion statement; The first major model is used to perform retrieval planning based on the retrieval prompts to obtain a retrieval strategy; Based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data, target table data for answering the query question is obtained; The second major model generates an answer to the query question based on the target table data. The first major model is used for retrieval planning in the following manner: The intent of the search prompt statement is identified to obtain the intent identification result; When the intent recognition result indicates that the query question belongs to a rule-based statistical scenario, the retrieval strategy is determined to be a first retrieval strategy. The first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data, or the first retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data and retrieve the table data in the candidate table data that is semantically related to the query question. If the intent recognition result indicates that the query question belongs to a semantic-based retrieval scenario, the retrieval strategy is determined to be a second retrieval strategy. The second retrieval strategy is used to retrieve table data in the candidate table data whose semantics are related to the query question. The step of obtaining target table data for answering the query question based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data includes: When the retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, the retrieval prompt statement is converted into a first structured query language corresponding to the candidate table data, and a record query is performed in the candidate table to which the corresponding candidate table data belongs according to the first structured query language to obtain the first table data. The record retrieval strategy is used to count the table data in the candidate table data that is related to the query question, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question. Based on the query question and the candidate table data, semantic retrieval is performed to obtain the second table data; Based on the data in the first table and the data in the second table, the target table data for answering the query question is determined.
2. The retrieval and question-answering method for tables according to claim 1, characterized in that, The first retrieval strategy includes an analytical retrieval strategy, or the first retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy. The analytical retrieval strategy is used to analyze the table data in the candidate table data that is related to the query question. The record retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question. The semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question. When the intent recognition result indicates that the query question belongs to a rule-based statistical scenario, the retrieval strategy is determined as the first retrieval strategy, including: If the intent recognition result indicates that the query question belongs to an extremum query or a rule-based record retrieval, the retrieval strategy is determined to include the record retrieval strategy and the semantic retrieval strategy; If the intent recognition result indicates that the query question belongs to a rule-based statistical analysis query, the retrieval strategy is determined to include the analytical retrieval strategy.
3. The retrieval and question-answering method for tables according to claim 1, characterized in that, The step of determining the target table data for answering the query question based on the first table data and the second table data includes: The first table data and the second table data corresponding to each candidate table data are respectively fused to obtain fused table data; Based on the relevance of each of the fused table data to the query question, the target table data for answering the query question is determined.
4. The retrieval and question-answering method for tables according to claim 3, characterized in that, The step of determining the target table data for answering the query question based on the relevance of each of the fused table data to the query question includes: The fusion table data that is most relevant to the query question among all the fusion table data is determined as the target table data for answering the query question.
5. The retrieval and question-answering method for tables according to claim 3, characterized in that, The step of determining the target table data for answering the query question based on the relevance of each of the fused table data to the query question includes: For each candidate table to which the candidate table data belongs, determine the target fusion table data that is most relevant to the query question among the fusion table data corresponding to the candidate table; The target fusion table data with the highest relevance among the target fusion data corresponding to each candidate table is determined as the target table data used to answer the query question.
6. The retrieval question-and-answer method for tables according to claim 1 or 2, characterized in that, The step of obtaining target table data for answering the query question based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data includes: When the retrieval strategy includes an analytical retrieval strategy, the retrieval suggestion statement is converted into a second structured query language corresponding to the candidate table data, wherein the analytical retrieval strategy is used to analyze the table data in the candidate table data that is related to the query question; According to the second structured query language, statistical table data related to the query question is collected in the candidate table to which the candidate table data belongs, and the statistical table data is analyzed to obtain target table data for answering the query question.
7. The retrieval and question-answering method for tables according to claim 1 or 2, characterized in that, The candidate table data includes metadata of the table to which the candidate table data belongs. The process of obtaining target table data for answering the query based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data includes: When the retrieval strategy includes a semantic retrieval strategy, the subquery statement corresponding to the candidate table data is determined based on the query question and the metadata; Parallel semantic retrieval is performed in the candidate tables to which the corresponding candidate table data belongs based on the subquery statement to obtain the target table data.
8. The retrieval question-and-answer method for tables according to claim 7, characterized in that, The query question and the metadata are used to determine the subquery statement corresponding to the candidate table data, including: The query question and the metadata are filled into a preset prompt word template to obtain target prompt words, wherein the target prompt words are used to prompt the third model to rewrite the query statement based on the metadata; The target prompt is input into the third model to obtain the subquery statement corresponding to the candidate table data output by the third model.
9. The retrieval and question-answering method for tables according to claim 1 or 2, characterized in that, The second major model generates an answer to the query based on the target table data, including... When the retrieval strategy is used to statistically analyze the table data related to the query question in the candidate table data and to retrieve the table data in the candidate table data that is semantically related to the query question, the second major model generates a first answer to the query question based on the target table data. The first answer includes the answer to the query question and the source data for generating the answer. When the retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question or to retrieve the table data in the candidate table data that is semantically related to the query question, the second large model generates a second answer to the query question based on the target table data. The second answer includes the answer to the query question.
10. A retrieval and question-answering device for tables, characterized in that, The table retrieval and question-answering device includes: The response module is configured to respond to a user-input query by performing a pre-retrieval in a tabular database based on the query to obtain candidate tabular data for answering the query. The first generation module is configured to generate search suggestion statements based on the candidate table data and the query question; The retrieval planning module is configured to perform retrieval planning based on the retrieval prompt statement using the first major model to obtain a retrieval strategy. The execution module is configured to obtain target table data for answering the query question based on the retrieval strategy, the retrieval suggestion statement, and the candidate table data. The second generation module is configured to generate an answer to the query question based on the target table data using the second major model; The first model can perform retrieval planning as follows: It performs intent recognition on the retrieval prompts to obtain intent recognition results; if the intent recognition results indicate that the query question belongs to a rule-based statistical scenario, it determines the retrieval strategy as a first retrieval strategy. The first retrieval strategy is used to statistically analyze table data related to the query question in the candidate table data, or it is used to statistically analyze table data related to the query question in the candidate table data and retrieve table data whose semantics are related to the query question from the candidate table data; if the intent recognition results indicate that the query question belongs to a semantic-based retrieval scenario, it determines the retrieval strategy as a second retrieval strategy. The second retrieval strategy is used to retrieve table data whose semantics are related to the query question from the candidate table data. The execution module is further configured to, when the retrieval strategy includes a record retrieval strategy and a semantic retrieval strategy, convert the retrieval prompt statement into a first structured query language corresponding to the candidate table data, and perform a record query in the candidate table to which the corresponding candidate table data belongs according to the first structured query language to obtain the first table data. The record retrieval strategy is used to statistically analyze the table data in the candidate table data that is related to the query question, and the semantic retrieval strategy is used to retrieve the table data in the candidate table data that is semantically related to the query question. Based on the query question and the candidate table data, a semantic retrieval is performed to obtain the second table data. Based on the first table data and the second table data, the target table data for answering the query question is determined.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processing device, it implements the method of any one of claims 1-9.
12. An electronic device, characterized in that, include: A storage device on which computer programs are stored; A processing device for executing the computer program in the storage device to implement the method of any one of claims 1-9.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-9.
Citation Information
Patent Citations
Question and answer method and device, equipment and storage medium
CN118897879A
Question-answer retrieval apparatus and method thereof
JP2012068985A