Table query method, apparatus and device, storage medium and computer program product

By performing scene recognition and similarity calculation on the input text, and combining it with the Text2SQL model to generate query statements, it solves the problem of low prediction accuracy of the Text2SQL model and does not support fuzzy queries, and achieves higher table query accuracy.

CN118779334APending Publication Date: 2024-10-15PICC INFORMATION TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410793021.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

The existing Text2SQL model has low prediction accuracy for converting text to SQL, and does not support the generation of fuzzy query statements, resulting in empty table query results.

Method used

By performing scene recognition on the input text, query statements are generated and text similarity is calculated, and the two-way query results are combined for sorting to support fuzzy queries and improve query accuracy.

Benefits of technology

It improves the accuracy of table queries, avoids the problem of empty query results caused by not supporting fuzzy queries, and achieves higher query accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779334A_ABST
    Figure CN118779334A_ABST
Patent Text Reader

Abstract

The invention provides a table query method and device, equipment, a storage medium and a computer program product. The method comprises the steps of performing scene recognition on an input text, and obtaining a first target problem text representing a table retrieval scene category; generating a first query statement based on the first target question text and the table data, and querying the table data based on the first query statement to obtain a first query result; calculating a text similarity between the first target problem text and each table content in the table data, and determining a second query result based on the text similarity; and taking the first query result and the second query result as table query results of the first target problem. According to the method, the accuracy of table query can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a table query method, device, equipment, storage medium and computer program product. Background Art

[0002] TableQA query is based on NLP (Natural Language Processing) technology. Through the table structure and table data pre-stored in the database, based on the Text2SQL (Text-to-SQL, text to SQL query) model, the natural language form of the question is converted into the corresponding SQL query statement, and the query is performed through the SQL query statement to obtain the query results.

[0003] However, the Text2SQL model has low prediction accuracy for text-to-SQL conversion, and the input text needs to be completely consistent with the query indicators in the table. It does not support the generation of fuzzy query statements, resulting in the query results of the final generated SQL query statement being empty and the table query failing. Summary of the invention

[0004] The present application provides a table query method, apparatus, device, storage medium and computer program product to solve the problem of low table query accuracy.

[0005] In a first aspect, the present application provides a table query method, comprising:

[0006] Performing scene recognition on the input text to obtain the first target question text representing the table retrieval scene category;

[0007] Based on the first target question text and the table data, a first query statement is generated to query the table data based on the first query statement to obtain a first query result;

[0008] Calculating the text similarity between the first target question text and the contents of each table in the table data, so as to determine a second query result based on the text similarity;

[0009] The first query result and the second query result are used as a table query result of the first target question.

[0010] In an implementable manner, the calculating the text similarity between the first target question text and the contents of each table in the table data includes:

[0011] Convert at least one table content in the table data into a natural language to obtain at least one table text; wherein the table content represents the data corresponding to the row in the table data;

[0012] The similarity between each table text in the at least one table text and the first target question text is calculated to obtain the text similarity corresponding to each table text.

[0013] In an implementable manner, calculating the similarity between each table text in the at least one table text and the first target question text to obtain the text similarity corresponding to each table text includes:

[0014] Convert the at least one tabular text into corresponding vector representations respectively;

[0015] Based on the vector representation corresponding to each table text and the first target question text, the text similarity corresponding to each table text is calculated.

[0016] In an implementable manner, the first query result includes at least one table content, and the second query result includes at least one table content, wherein the table content represents data corresponding to a row in the table data; and using the first query result and the second query result as the table query result of the first target question includes:

[0017] Assigning a first weight to each table content in the first query result, and assigning a second weight to each table content in the second query result;

[0018] Based on the first weight corresponding to each table content in the first query result and the second weight corresponding to each table content in the second query result, sort the table contents in the first query result and the table content in the second query result to obtain a table content sequence, so as to use the table content sequence as the table query result of the first target question.

[0019] In one possible implementation, the method further includes:

[0020] Performing scene recognition on the input text to obtain a second target question text; wherein the second target question text represents a text of a table question-answering scene category;

[0021] Based on the second target question text and the table data, a second query statement is generated to query the table data based on the second query statement to obtain a third query result;

[0022] The third query result and the second target question text are input as examples into the large language model to obtain a query result text of the second target question text; wherein the example is used to instruct the large language model to convert the query result text into the query result text according to the second target question text, and the query result text is a natural language representation of the natural language corresponding to the third query result.

[0023] In one possible implementation, performing scene recognition on the input text includes:

[0024] The input text is input into a scene classification model to obtain a scene category corresponding to the input text; wherein the scene classification model is trained based on training text with scene category labels.

[0025] In an implementable manner, determining the second query result based on the text similarity includes:

[0026] The table contents whose text similarity values ​​are greater than a preset value are taken as the second query results.

[0027] In a second aspect, the present application provides a table query device, comprising: a scene recognition module, configured to perform scene recognition on input text and obtain a first target question text representing a table retrieval scene category;

[0028] A first query result acquisition module, used to generate a first query statement based on the first target question text and the table data, so as to query the table data based on the first query statement to obtain a first query result;

[0029] A second query result acquisition module, used for calculating the text similarity between the first target question text and the contents of each table in the table data, so as to determine a second query result based on the text similarity;

[0030] A table query result acquisition module is used to use the first query result and the second query result as the table query result of the first target question.

[0031] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory; the memory is used to store instructions; the processor is used to execute the instructions in the memory, so that the electronic device executes the method described in the first aspect.

[0032] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.

[0033] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.

[0034] The table query method, apparatus, device, storage medium and computer program product provided by the present application, for question text in the table retrieval scenario category, on the one hand, generate a query statement to query the table through the query statement to obtain a query result; on the other hand, obtain a second query result in the table with high similarity to the question text through similarity calculation, thereby performing a question text table query through two paths, and the similarity calculation can perform a fuzzy question text query, avoiding the situation where the query statement does not support fuzzy query and resulting in an empty query result, and the query result has high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0036] Figure 1 This is an implementation scenario diagram shown for an exemplary embodiment;

[0037] Figure 2 A flowchart of a table query method is shown as an exemplary embodiment;

[0038] Figure 3 A flowchart of a table query method shown as another exemplary embodiment;

[0039] Figure 4 A structural diagram of a table query device is shown as an exemplary embodiment;

[0040] Figure 5 The present invention is a block diagram of an electronic device showing an exemplary embodiment.

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

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

[0043] It should be noted that the texts, data tables, examples and other data involved in this application (including but not limited to data used for analysis, stored data, displayed data, etc.) are all information and data understood and authorized by the relevant users or fully authorized by all parties, and the collection, use, processing, transmission, provision, disclosure and application of the relevant data comply with the laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and comply with the principles of legality, legitimacy and necessity.

[0044] First, the terms involved in this application are explained:

[0045] NLP: Natural Language Processing, translated as natural language processing, refers to a type of artificial intelligence technology that enables computers to process and understand human language by interacting with computers through the natural language used by humans.

[0046] Text2SQL: Text-to-SQL, translated as text to SQL, refers to converting the natural language used for human communication into executable SQL query statements.

[0047] Table2Text: Table-to-Text, translated as table to text, refers to converting a row of content in a table into a descriptive text in natural language form.

[0048] Text2Vec: Text-to-Vector, translated as text-to-vector, refers to converting text in natural language form into corresponding vector representation.

[0049] TableQA: Table Question Answering, translated as table question answering, refers to generating corresponding answers to questions related to the table content based on a given table.

[0050] LLM: Large Language Model, translated as large language model, refers to an artificial neural network with a massive number of parameters (usually billions of weights or more). Large language models have "human-like" language understanding, knowledge memory and logical reasoning capabilities.

[0051] Table Question and Answer is based on NLP technology. By pre-designing the table structure and table data stored in the database, user questions in natural language are converted into corresponding SQL query statements (this process is called Text-to-SQL). After the query is executed, the corresponding reply is generated according to the query results.

[0052] According to the query results, table query scenarios can be mainly divided into two categories, including retrieval and question-answering. Retrieval scenarios involve filtering table content to find relevant rows that meet the query requirements, while question-answering scenarios usually involve calculation, analysis, and interpretation of query results. Retrieval usually only requires a single step or a single SQL statement to complete the query, usually through the WHERE (the key part of the SQL query used to filter records) keyword to constrain conditions; while question-answering involves multi-step, complex calculation logic, and requires a combination of different SQL keywords including GROUP BY (the key part of the SQL query used to aggregate groups) and ORDER BY (the key part of the SQL query used to sort). When querying two different categories of tables, the same model is used for processing, resulting in a low overall response accuracy.

[0053] On the other hand, the Text2SQL model has low prediction accuracy for text column values ​​and generally does not support the generation of fuzzy query statements (i.e., query statements containing fuzzy keywords such as LIKE); for example, if the question is "What is the company's revenue?", the Text2SQL model can determine the indicator name of the query column and determine the prediction condition in the query statement as "indicator name = 'revenue'", but in some tables, the actual value of the column in the table may not be exactly "revenue", but a text containing "revenue" or similar semantics, such as "comprehensive income" or "yield of return". The query statement generated by Text2SQL cannot retrieve the column containing "revenue" or similar semantics, resulting in retrieval failure.

[0054] Based on this, a table query method, apparatus, device, storage medium and computer program product are proposed in this embodiment, aiming to solve the problem of low table query accuracy and inability to perform fuzzy table query.

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

[0056] The table query method provided in the present application can be implemented in any electronic device with data processing capabilities, or in a table query system. It should be noted that the table query system can be deployed separately on an electronic device in any environment (for example, deployed separately on an edge server in an edge environment), or can be deployed entirely in a cloud environment, or can be deployed in a distributed manner in different environments.

[0057] For example, the table query system can be logically divided into multiple parts, each with different functions. The various parts in the table query system can be deployed in any two or three of the electronic device (located on the user side, such as the client), the edge environment, and the cloud environment. The edge environment is an environment that includes a collection of edge electronic devices that are close to the electronic device. The edge electronic devices include: edge servers, edge stations with computing power, etc. The various parts of the table query system deployed in different environments or devices work together to realize the functions of the data processing platform.

[0058] It should be understood that this application does not restrictively divide which parts of the table query system are deployed in what specific environment. In actual application, it can be adaptively deployed according to the computing power of the electronic device, the resource usage of the edge environment and the cloud environment, or the specific application requirements.

[0059] like Figure 1 This is an implementation scenario diagram showing an exemplary embodiment. The table query system corresponding to the implementation scenario includes a client 10 and a server 11. The client 10 and the server 11 are connected via network communication.

[0060] The executor of the method of the embodiment of the present application is the server 11, and the client 10 can receive text. The client 10 sends the text to the server 11 through the network. The server 11 performs a table query to obtain the table query result of the input text, and can feed back the table query result to the client 10 through the network. The client 10 has a graphic user interface, and the table query result can be displayed on the graphic user interface.

[0061] In some embodiments, after receiving the text, the server 11 performs scene recognition on the input text to obtain a first target question text that represents the table retrieval scene category; generates a first query statement based on the first target question text and the table data to query the table data based on the first query statement to obtain a first query result; calculates the text similarity between the first target question text and the contents of each table in the table data to determine a second query result based on the text similarity; and uses the first query result and the second query result as the table query result of the first target question.

[0062] It is understandable that the table query device can be arranged at Figure 1 In the server 11, but the example shown in this embodiment Figure 1 The implementation environment shown is only exemplary. In other embodiments, the table query method may also be applied to other implementation environments, and the table query device may also be set in other structures in other implementation environments, which is not specifically limited here.

[0063] In this embodiment, the client 10 is an electronic device on the user side, which can be a wired terminal with a visualization structure or a wireless terminal. In other embodiments, the terminal can be an electronic device with a visualization structure such as a mobile phone, a computer, a tablet, and a vehicle-mounted device.

[0064] The server 11 can be an edge environment and a cloud environment, such as a physical server, a server cluster, and a cloud server, etc., and no specific limitations are made here.

[0065] It is understandable that the table query device can be arranged at Figure 1 In the server 11, but the example shown in this embodiment Figure 1 The implementation environment shown is only exemplary. In other embodiments, the table query method may also be applied to other implementation environments, and the table query device may also be set in other structures in other implementation environments, which is not specifically limited here.

[0066] Figure 2 is a flowchart of a table query method shown in an exemplary embodiment, which is applied to Figure 1 The server 11 in Figure 2 As shown, the method includes steps S210 to S270, which are described in detail as follows:

[0067] Step S210: Perform scene recognition on the input text to obtain a first target question text representing a table retrieval scene category.

[0068] In this embodiment, the input text is a query question for table data. The input text can be first subjected to scene recognition. If it is determined that the input text is a text of a table retrieval scene type, the text is used as the first target question text for subsequent table query processing.

[0069] In this embodiment, scene recognition can be implemented in a scene classification model, which can predefine two scene categories, namely, table retrieval category and table question and answer category. It can be understood that the text of the table retrieval category only needs to query the corresponding rows that meet the query conditions in the table data, while the table question and answer text needs to calculate and analyze the feature values ​​in the table and needs to be replied in natural language, such as querying the corresponding rows in the table data and performing relevant processing and analysis based on the corresponding rows to obtain the final query result. For example, "What is the company's revenue" is a text of the table retrieval category, and "Which month has the highest company revenue" is a text of the table question and answer category, which needs to query the company's revenue for each month and compare the revenue of each month. The month with the highest revenue is the query result corresponding to the text of the table question and answer category.

[0070] In this embodiment, the scene classification model may be a text classification model, which is obtained by training with training texts having scene category labels, wherein the scene category labels include table retrieval category labels and table question and answer category labels.

[0071] Step S230: Generate a first query statement based on the first target question text and the table data, and query the table data based on the first query statement to obtain a first query result.

[0072] In this embodiment, for the first target question text, the first target question text and table data are input into the Text2SQL model to generate a first query statement. The Text2SQL model can be a model such as IGSQL, R2SQL, etc., and no specific limitation is made here.

[0073] The table data is a table, and the table data includes corresponding column values ​​and corresponding row values.

[0074] The first query statement can be used to query the table data to obtain corresponding rows in the table data that meet the query conditions in the first query statement. The corresponding rows are the first query results.

[0075] For example, in one embodiment, the text of the first target question is "Give examples of revenue indicators for subsidiary No. 1", and the corresponding table name in the table data is the indicator table. The column names include the indicator name (text type), the company to which it belongs (text type), the statistical frequency (text type), the indicator definition (text type), etc. The first query statement finally generated can be SELECT FROM indicator WHERE the company to which it belongs = "subsidiary No. 1" AND indicator name = "revenue", where SELECT FROM, WHERE and AND are keywords in the SQL statement. Through the first query statement, you can query in the table data whose table name is the indicator table to get the first query result.

[0076] It can be understood that if the actual value of the indicator name in the table data of the table named indicator table is "comprehensive income", then the indicator name = "income" in the first query statement will cause the query result data in the table data through the first query statement to be zero. When generating query statements through the Text2SQL model, it is necessary to ensure that the query indicator in the input text is exactly the same as the actual value of the column in the table data in order to obtain accurate query results.

[0077] Step S250: Calculate the text similarity between the first target question text and the contents of each table in the table data to determine the second query result based on the text similarity.

[0078] Therefore, in this embodiment, for the first target question text, the text similarity between the first target question text and the contents of each table in the table data is calculated to determine the second query result based on the text similarity, so as to avoid the situation where the first query result is empty, resulting in the final query result of the first target question text query being empty.

[0079] In some embodiments, at least one table content in the table data is converted into natural language to obtain at least one table text; wherein the table content represents the data corresponding to the row in the table data; and the similarity between each table text in the at least one table text and the first target question text is calculated to obtain the text similarity corresponding to each table text.

[0080] The table content is the data of each row in the table data. By converting the table content into natural speech, the similarity between the natural language corresponding to the table content and the first target question text is calculated.

[0081] The table contents are converted into natural language respectively, and the obtained table text can be converted through a preset template. For example, the table content of the row is converted into a natural language description through a preset template, that is, the table text corresponding to the row is obtained. This process can be regarded as Table-to-Text.

[0082] In some embodiments, after obtaining the table text corresponding to each row, at least one table text is converted into a corresponding vector representation; based on the vector representation corresponding to each table text and the first target question text, the text similarity corresponding to each table text is calculated.

[0083] In this embodiment, the vector representation corresponding to each table text is obtained through the Text2Vec model, and the vector representation of the first target question text can also be obtained, so as to calculate the text similarity corresponding to each table text through the vector representation corresponding to each table text and the vector representation of the first target question text.

[0084] In some embodiments, the vector representation corresponding to each table text is calculated when calculating the text similarity, or it can be calculated in advance before calculating the text similarity, and the calculated vector representation corresponding to each table text is stored in a database. When the text similarity needs to be calculated, the corresponding vector representation is taken out from the database to calculate the corresponding text similarity. In this way, there is no need to calculate the vector representation corresponding to each table text every time when the text similarity between the same table data and different first target question texts is displayed, thereby reducing the calculation cost.

[0085] The text similarity calculation may be the cosine similarity between the vector representation corresponding to each table text and the vector representation of the first target question text, or may be the feature distance similarity, which is not specifically limited here.

[0086] In this embodiment, the table contents whose text similarity values ​​are greater than a preset value are taken as the second query results.

[0087] The preset value can be set according to demand or based on empirical parameters, and no specific limitation is made here.

[0088] Step S270: Use the first query result and the second query result as the table query result of the first target question.

[0089] In this embodiment, two query results of the first target question can be obtained through step S230 and step S250. The first query result and the second query result are merged and sorted to obtain the final table query result of the first target question.

[0090] In some embodiments, the first query result includes at least one table content, and the second query result includes at least one table content, the table content represents the data corresponding to the row in the table data, a first weight is assigned to each table content in the first query result, and a second weight is assigned to each table content in the second query result; based on the first weight corresponding to each table content in the first query result and the second weight corresponding to each table content in the second query result, each table content in the first query result and each table content in the second query result are sorted to obtain a table content sequence, so as to use the table content sequence as the table query result of the first target question.

[0091] In this embodiment, it is assumed that both the first query result and the second query result are not empty, the first query result includes at least one row of table content, and the second query result also includes at least one row of table content. The first query result and the second query result may or may not be a union. At this time, through the fusion sorting strategy, each table content in the first query result and the second query result is reordered to obtain the final table content sequence, that is, the table query result.

[0092] In some embodiments, the fusion sorting strategy adopts a weighted average method, that is, by assigning different weights to the table content in the first query result and the second query result, the assigned weight is the new score of the table content in the first query result and the second query result, so that the new score is used as the basis for re-sorting, such as sorting from large to small according to the new score to obtain a table content sequence.

[0093] The first weight and the second weight are determined through a weight allocation model, and a grid search strategy is adopted here to exhaustively find the optimal weight allocation strategy according to different scenarios.

[0094] In some embodiments, Figure 3Another exemplary embodiment is shown as a flowchart of a table query method, S301: scene recognition is performed on the input text, S302: if the input text is a table retrieval scene category, the input text is used as the first target question, and then processed as in the above steps S230 to S270, S303: if the input text is a table question and answer scene category, the input text is used as the second target question text, and steps S310 to S330 are processed.

[0095] In some embodiments, the processing of the second target question text includes:

[0096] Step S310: Generate a second query statement based on the second target question text and the table data, and query the table data based on the second query statement to obtain a third query result.

[0097] The method of generating the second query statement may refer to the method of generating the first query statement, and will not be described in detail here.

[0098] It can be understood that the second target question text is a text of the table question and answer scenario category. Therefore, the third query result obtained by the query is not necessarily a row or multiple rows in the table data, but the result obtained after analyzing the query processed data.

[0099] It should be noted that the table data corresponding to the second target question text may be the same as or different from the table data corresponding to the first target question text. It is set according to the table corresponding to the query of different target question texts and is not specifically limited here.

[0100] Step S330: input the third query result and the second target question text as examples into the large language model to obtain the query result text of the second target question text.

[0101] Among them, the example is used to instruct the large language model to convert the query result text into the query result text according to the second target question text. The query result text is a natural language representation of the natural language corresponding to the third query result. This example is the prompt in the large language model and can also be regarded as prompt information.

[0102] By inputting the example into the large language model, the large language model translates the third query result into natural language based on the third query result and the second target question text, and the natural sentence is the query result text of the second target question text.

[0103] In this solution, scene recognition is performed on the input text. For the question text of the table retrieval scene category, on the one hand, a query statement is generated to query the table through the query statement to obtain the query result; on the other hand, a second query result with high similarity to the question text in the table is obtained through similarity calculation, thereby performing a question text table query through two channels, and the similarity calculation can perform a fuzzy question text query to avoid the situation where the query statement does not support fuzzy query and the query result is empty. This method has low cost and high accuracy.

[0104] At the same time, for the question text in the table question and answer scenario category, since it requires data processing and analysis to obtain the query results, it is impossible to obtain other query results through similarity calculation. Instead, a prompt input large language model can be constructed based on the query results retrieved by the generated query statement to obtain the query result text of the question text in the table question and answer scenario category, thereby improving the readability of the query results of the question text in the table question and answer scenario category.

[0105] Figure 4 4 is a structural diagram of a table query device shown in an exemplary embodiment. The table query device 400 includes:

[0106] A scene recognition module 410 is used to perform scene recognition on the input text to obtain a first target question text representing a table retrieval scene category;

[0107] A first query result acquisition module 430 is used to generate a first query statement based on the first target question text and the table data, so as to query the table data based on the first query statement to obtain a first query result;

[0108] A second query result acquisition module 450 is used to calculate the text similarity between the first target question text and the contents of each table in the table data, so as to determine the second query result based on the text similarity;

[0109] The table query result acquisition module 470 is used to use the first query result and the second query result as the table query result of the first target question.

[0110] In one implementable manner, the second query result acquisition module includes:

[0111] A table text acquisition unit, used to convert at least one table content in the table data into natural language to obtain at least one table text; wherein the table content represents data corresponding to a row in the table data;

[0112] The text similarity acquisition unit is used to calculate the similarity between each table text in at least one table text and the first target question text to obtain the text similarity corresponding to each table text.

[0113] In one possible implementation, the text similarity obtaining unit includes:

[0114] A vector representation acquisition section is used to convert at least one table text into a corresponding vector representation;

[0115] The text similarity acquisition section is used to calculate the text similarity corresponding to each table text based on the vector representation corresponding to each table text and the first target question text.

[0116] In an implementable manner, the first query result includes at least one table content, and the second query result includes at least one table content, and the table content represents data corresponding to a row in the table data; the table query result acquisition module includes:

[0117] A weight allocation unit, configured to allocate a first weight to each table content in the first query result, and allocate a second weight to each table content in the second query result;

[0118] A table query result acquisition unit is used to sort the table contents in the first query result and the table contents in the second query result based on the first weight corresponding to the table contents in the first query result and the second weight corresponding to the table contents in the second query result to obtain a table content sequence, so as to use the table content sequence as the table query result of the first target question.

[0119] In one possible implementation, the table query device further includes:

[0120] A second target question text acquisition module is used to perform scene recognition on the input text to acquire a second target question text; wherein the second target question text represents a text of a table question-answering scene category;

[0121] A third query result acquisition module is used to generate a second query statement based on the second target question text and the table data, and query the table data based on the second query statement to obtain a third query result;

[0122] A query result text acquisition module is used to input the third query result and the second target question text as examples into the large language model to obtain the query result text of the second target question text; wherein the example is used to instruct the large language model to convert the query result text into the query result text according to the second target question text, and the query result text is a natural language representation of the natural language corresponding to the third query result.

[0123] In one possible implementation, the scene recognition module includes:

[0124] The scene recognition unit is used to input the input text into the scene classification model to obtain the scene category corresponding to the input text; wherein the scene classification model is trained based on the training text with scene category labels.

[0125] In one possible implementation, the second query result acquisition module includes:

[0126] The second query result obtaining unit is used to take the table content whose text similarity value is greater than a preset value as the second query result.

[0127] The table query device provided in this embodiment can be used to execute the above-mentioned table query method. Its implementation principle and technical effects are similar, and this embodiment will not be repeated here.

[0128] Figure 5 is a block diagram of an electronic device according to an exemplary embodiment. Figure 5 The electronic device 500 may include: a processor 51 and a memory 52, wherein the processor 51 and the memory 52 can communicate; illustratively, the processor 51 and the memory 52 communicate via a communication bus 53, the memory 52 is used to store computer execution instructions, and the processor 51 is used to call the computer execution instructions in the memory to execute the table query method shown in any of the above method embodiments.

[0129] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the present application may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0130] The present application provides a computer-readable storage medium, on which computer-executable instructions are stored; when the computer-executable instructions are executed by a processor, they are used to implement a table query method as in any of the above embodiments.

[0131] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned table query method is implemented.

[0132] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0133] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A table query method, characterized in that: include: Performing scene recognition on the input text to obtain the first target question text representing the table retrieval scene category; Based on the first target question text and the table data, a first query statement is generated to query the table data based on the first query statement to obtain a first query result; Calculating the text similarity between the first target question text and the contents of each table in the table data, so as to determine a second query result based on the text similarity; The first query result and the second query result are used as a table query result of the first target question.

2. The method according to claim 1, characterized in that The calculating the text similarity between the first target question text and the contents of each table in the table data includes: Convert at least one table content in the table data into a natural language to obtain at least one table text; wherein the table content represents the data corresponding to the row in the table data; The similarity between each table text in the at least one table text and the first target question text is calculated to obtain the text similarity corresponding to each table text.

3. The method according to claim 2, characterized in that The calculating the similarity between each table text in the at least one table text and the first target question text to obtain the text similarity corresponding to each table text includes: Convert the at least one tabular text into a corresponding vector representation respectively; Based on the vector representation corresponding to each table text and the first target question text, the text similarity corresponding to each table text is calculated.

4. The method according to claim 1, characterized in that The first query result includes at least one table content, and the second query result includes at least one table content, wherein the table content represents data corresponding to a row in the table data; The step of using the first query result and the second query result as a table query result of the first target question includes: Assigning a first weight to each table content in the first query result, and assigning a second weight to each table content in the second query result; Based on the first weight corresponding to each table content in the first query result and the second weight corresponding to each table content in the second query result, sort the table contents in the first query result and the table content in the second query result to obtain a table content sequence, so as to use the table content sequence as the table query result of the first target question.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Performing scene recognition on the input text to obtain a second target question text; wherein the second target question text represents a text of a table question-answering scene category; Based on the second target question text and the table data, a second query statement is generated to query the table data based on the second query statement to obtain a third query result; The third query result and the second target question text are input as examples into the large language model to obtain a query result text of the second target question text; wherein the example is used to instruct the large language model to convert the query result text into the query result text according to the second target question text, and the query result text is a natural language representation of the natural language corresponding to the third query result.

6. The method according to claim 1, characterized in that The performing scene recognition on the input text includes: The input text is input into a scene classification model to obtain a scene category corresponding to the input text; wherein the scene classification model is trained based on training text with scene category labels.

7. The method according to claim 1, characterized in that The determining a second query result based on the text similarity includes: The table contents whose text similarity values ​​are greater than a preset value are taken as the second query results.

8. A table query device, characterized in that: include: A scene recognition module is used to perform scene recognition on the input text and obtain a first target question text representing the table retrieval scene category; A first query result acquisition module, configured to generate a first query statement based on the first target question text and the table data, and query the table data based on the first query statement to obtain a first query result; A second query result acquisition module, used for calculating the text similarity between the first target question text and the contents of each table in the table data, so as to determine a second query result based on the text similarity; A table query result acquisition module is used to use the first query result and the second query result as the table query result of the first target question.

9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; the memory is used to store instructions; the processor is used to execute the instructions in the memory, so that the electronic device executes the method as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.

11. A computer program product, characterized in that The method comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.

Citation Information

Cited By

  • Data query method and device, electronic equipment, storage medium and program product

    CN118277632A

  • Knowledge question-answering method and device based on large model, medium, equipment and product

    CN121524314A

  • Knowledge-based question answering methods, devices, media, equipment, and products based on large models

    CN121524314B