Table recall method, device, electronic device and medium

Through the dual-stage recall strategy and vector library similarity retrieval, combined with large model rearrangement, the problems of low table recall accuracy and too long context in the existing technology are solved, and high-precision table recall and SQL generation are achieved.

CN118312524BActive Publication Date: 2024-09-27LONGSHINE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410733522.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-09-27
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

When the existing table recall method handles multiple tables or wide tables, the context is too long, which affects the large model generation effect and SQL accuracy. Moreover, the accuracy of the tables returned by the retrieval is not high, which affects the overall performance of Text-to-SQL technology.

Method used

Adopting a two-stage recall strategy, by constructing a header and field vector library, first conduct a coarse-grained query at the header level, and then conduct a fine-grained query at the field level, and use a large model to sort the filtered tables to achieve high-precision tables recall.

Benefits of technology

It significantly improves table recall accuracy, solves the problem of too long context, improves the accuracy of SQL generation and the overall performance of Text-to-SQL technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312524B
    Figure CN118312524B
Patent Text Reader

Abstract

The present invention provides a table recall method, device, electronic device and medium, which relate to the field of artificial intelligence. The method comprises: constructing a first vector library for all tables in a database according to the table header; constructing a second vector library for all field cells of each table according to the fields of the table; querying multiple target tables similar to the query statement from the first vector library; querying at least one target field similar to the query statement from the second vector library corresponding to each target table; using the target field to perform field filtering on the corresponding target table to obtain a filter table corresponding to each target table; using a large model and multiple filter tables to sort multiple target tables to obtain a table recall result. The solution of the present invention can significantly improve the accuracy of table recall, and at the same time can solve the problem caused by too long context when calling a large model to recall a table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a table recall method, device, electronic equipment and medium. Background Art

[0002] Smart data query is designed to help users find data conveniently and quickly. It can usually meet basic smart data query needs based on the Text-to-SQL technology route in the AI ​​field. Text-to-SQL usually converts users' natural language query questions into SQL query statements based on the capabilities of large models, and returns results through automatic backend query. In this way, users can query massive databases conveniently and quickly without having to write complex and highly professional SQL statements. Text-to-SQL technical solutions usually include: Figure 1 Table recall is an important step. In actual application scenarios, there may be a large number of database tables in the background. If we input all the database table information into the big model, it will often exceed the context length limit and greatly affect the generation effect. Therefore, technical means are needed to recall the header information most relevant to the query problem, so that the big model can generate accurate SQL query statements based on a small amount of header information.

[0003] Currently, there are two main ways to recall tables: one is to pass all the information in the database table to the large model at one time. When there are many tables in the database, the context will be too long, affecting the generation effect of the large model and the accuracy of SQL. At the same time, the too long context may exceed the hardware resource limit and cannot run. The other way is to realize retrieval by converting the table header into a vector. However, the accuracy of the table returned by the retrieval cannot be very high. As a pre-processing link in the text-to-SQL technical link, the insufficient accuracy of table recall will have a greater impact on the subsequent process, reducing the accuracy of the final generated SQL. Summary of the invention

[0004] The present invention provides a table recall method, device, electronic device and medium, which are used to solve the defect of low precision of existing table recall, realize a two-stage recall strategy from coarse to fine, realize high-precision table recall effect in combination with table field filtering, and overcome the problem of too long context caused by multiple tables or wide tables.

[0005] According to a first aspect of the present invention, the present invention provides a table recall method, the method comprising:

[0006] Constructing a first vector library for all tables in the database according to the table headers, wherein the first vector library takes the entire database as an object, converts the data in each table header into a corresponding vector, and the vectors corresponding to all tables constitute the first vector library;

[0007] According to the fields of the table, a second vector library is constructed for all the field cells of each table, wherein the second vector library converts each field data of the table into a corresponding vector with each table object, and the vectors corresponding to all the fields constitute the second vector library, and each second vector library corresponds to a vector in the first vector library;

[0008] Querying multiple target tables similar to the query statement from the first vector library;

[0009] Querying at least one target field similar to the query statement from the second vector library corresponding to each target table;

[0010] Using the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table;

[0011] The large model and multiple filter tables are used to sort multiple target tables to obtain table recall results.

[0012] In some possible implementations, constructing a first vector library for all tables in the database according to table headers includes:

[0013] Get the header content and unique identifier of each table in the database;

[0014] Construct each header content into a first text string;

[0015] Using the embedding model to extract features from each first text string to obtain a feature vector corresponding to each table, and associating the feature vector with a table unique identifier of the corresponding table;

[0016] The feature vectors corresponding to all tables are extracted and summarized to obtain the first vector library.

[0017] In some possible implementations, the step of constructing a second vector library for all field cells of each table according to the fields of the table includes:

[0018] For each table in the database, perform the following operations:

[0019] Get the field content of each field in the table and the unique identifier of the table to which the field belongs;

[0020] constructing each field content into a second text string;

[0021] Use the embedding model to extract features from each second text string to obtain feature vectors corresponding to each field table, and associate each feature vector with the table unique identifier of the table to which the field belongs;

[0022] For each table, the feature vectors corresponding to all fields are summarized and extracted to obtain a second vector library corresponding to each table.

[0023] In some possible implementations, the step of searching the first vector library for a plurality of target tables that are similar to the query statement includes:

[0024] Obtaining a query statement input into the intelligent query service to obtain the query statement to be queried;

[0025] Use the embedding model to extract features from the query statement to obtain the query vector;

[0026] Calculating a first similarity between the query vector and each vector in the first vector library;

[0027] All tables whose first similarity is less than a first preset value are taken as target tables, or all tables are sorted from small to large based on the first similarity, and the tables that are ranked first by a first preset number are taken as target tables.

[0028] In some possible implementations, searching the second vector library corresponding to each target table for at least one target field similar to the query statement includes:

[0029] The following operations are performed on the second vector library corresponding to each target table:

[0030] Calculating a second similarity between the query vector and each vector in the second vector library;

[0031] All fields whose second similarity is less than a second preset value are taken as target fields, or all fields are sorted from small to large based on the second similarity, and the fields ranked in the front by a second preset number are taken as target fields.

[0032] In some possible implementations, the using the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table includes:

[0033] Get all target fields corresponding to each target table;

[0034] Delete all fields except the corresponding target fields in each target table to obtain a filter table corresponding to each target table.

[0035] In some possible implementations, the method of using the large model and the multiple filter tables to sort the multiple target tables to obtain the table recall result includes:

[0036] Combine each filter table with the query statement;

[0037] Use the large model to analyze each pair of combinations separately to obtain the correlation of each pair of combinations;

[0038] sorting the plurality of target tables from large to small based on the relevance;

[0039] Output multiple target tables in order, or output the target tables that are ranked first by a preset third number.

[0040] According to a second aspect of the present invention, the present invention further provides a table recall device, which is used to implement any of the table recall methods described above, and the device comprises:

[0041] A first construction module is used to construct a first vector library for all tables in the database according to the table headers, wherein the first vector library takes the entire database as an object, converts the data in each table header into a corresponding vector, and the vectors corresponding to all tables constitute the first vector library;

[0042] A second construction module is used to construct a second vector library for all field cells of each table according to the fields of the table, wherein the second vector library converts each field data of the table into a corresponding vector with each table object, and the vectors corresponding to all fields constitute the second vector library, and each second vector library corresponds to a vector in the first vector library;

[0043] A first query module, used for querying a plurality of target tables similar to the query statement from the first vector library;

[0044] A second query module, used for querying at least one target field similar to the query statement from the second vector library corresponding to each target table;

[0045] A filtering module, used for performing field filtering on the corresponding target table using the target field to obtain a filtering table corresponding to each target table;

[0046] The sorting module is used to sort multiple target tables using a large model and multiple filter tables to obtain table recall results.

[0047] According to a third aspect of the present invention, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the table recall method described above is implemented.

[0048] According to a fourth aspect of the present invention, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the table recall method as described in any one of the above is implemented.

[0049] The present invention provides a table recall method, which constructs a first vector library and a second vector library corresponding to each table by using the table header and field of the table in advance, then performs a coarse-grained query at the table header level through the first vector library to obtain multiple target tables similar to the query statement, then performs a fine-grained query at the field level on each table through the second vector library corresponding to each table to obtain the target field, then uses the target field to filter the corresponding target table, thereby eliminating irrelevant data, and finally uses a large model and the filtered table to sort the target table, adopts a two-stage strategy to perform vector similarity retrieval to determine the recall table, and then uses the large model and the filtered table to rearrange the recall table, thereby significantly improving the table recall accuracy and solving the problem caused by too long context when calling the large model to recall the table.

[0050] In addition, a watch recall device, an electronic device and a non-transitory computer-readable storage medium provided by the present invention can also achieve the above-mentioned technical effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 It is a flowchart of using Text-to-SQL technology to implement intelligent query.

[0053] Figure 2 This is one of the flow charts of the table recall method provided by the present invention.

[0054] Figure 3 This is the second flow chart of the table recall method provided by the present invention.

[0055] Figure 4 It is a schematic diagram of database vector query provided by the present invention.

[0056] Figure 5 It is a structural schematic diagram of the watch recall device provided by the present invention.

[0057] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] Combine the following Figures 2 to 6 A table recall method, a table recall device, an electronic device and a non-transitory computer-readable storage medium of the present invention are described.

[0060] Figure 2 This is one of the flowcharts of the table recall method provided by the embodiment of the present invention. Please refer to Figure 2 As shown, this embodiment provides a table recall method, which can be implemented by steps S201 to S206. Each step will be described in detail below:

[0061] Step S201 : constructing a first vector library for all tables in the database according to table headers.

[0062] In this embodiment, the first vector library is constructed using the data in the header of each table in the database. Specifically, the database as a whole is taken as the object, and the data in the header of each table is converted into a corresponding vector, and the vectors corresponding to all tables constitute the first vector library. The data in the header refers to the data used to describe the data structure of the table. An exemplary header data is "Table name: Electricity index statistics table; Table description: Various indicators used to record the electricity of the electronic large screen; Fields include indicator value identifier, indicator code, indicator value, year-on-year value, month-on-month value, and the primary key is the indicator value identifier". The data in each header can be regarded as text data or a string. The way to convert the text data or string into a vector includes but is not limited to: text vectorization using word embedding, text vectorization using one-hot encoding, text vectorization based on the bag-of-words model, and text vectorization based on the term frequency-inverse document frequency model (TF-IDF (term frequency-inverse document frequency)).

[0063] Step S202: construct a second vector library for all field cells of each table according to the fields of the table.

[0064] In this embodiment, the second vector library is constructed using the data in all fields in each table. Specifically, each table is taken as an object, and each field data of the table is converted into a corresponding vector. The vectors corresponding to all fields constitute the second vector library. Each second vector library corresponds to a record in the first vector library one by one, that is, each second vector library corresponds to a vector in the first vector library. Through the correspondence between the two, the mutual mapping between the two can be achieved. Field refers to the data used to describe the field. An exemplary field data is "field name: year-on-year value; field explanation: year-on-year value refers to the year-on-year growth rate of electricity usage this year compared with the same period last year". The data of each field can be regarded as text data or a string. The method of converting the text data or string into a vector includes but is not limited to text vectorization using word embedding, text vectorization using unique hot encoding, text vectorization using a bag of words model, and text vectorization using a term frequency-inverse document frequency model (TF-IDF (term frequency-inverse document frequency)); in addition, it should be noted that each vector in the first vector library and the second vector library can be obtained by the same conversion method, or multiple conversion methods can be mixed when constructing any vector library.

[0065] Step S203: searching the first vector library for multiple target tables similar to the query statement.

[0066] In the specific implementation process, the query statement refers to the statement that needs to be queried. The query statement can be an inquiry statement or a communication statement input by the user or obtained from other applications. For example, the query statement is such as "What happened today in history" and "Which planet is closest to the earth"; the target table refers to the table corresponding to the vector similar to the query statement found in the first vector library. In the specific implementation process, whether the vector in the first vector library and the query statement are similar can be achieved by any existing indicator that can measure the similarity between the two, such as through keywords, distance or similarity. It should be noted that there should be multiple target tables found in the first vector library. In the specific implementation process, the table corresponding to the vector with relatively high similarity to the query statement in the first vector library is preferentially selected as the target vector. It should be noted that the number of target tables can be fixed or not fixed, as long as multiple tables are searched out.

[0067] Step S204: search the second vector library corresponding to each target table for at least one target field similar to the query statement.

[0068] In this embodiment, the target field refers to the field corresponding to the vector similar to the query statement found in each second vector library. It should be noted that the query of the target field corresponding to different tables is independent of each other. The method of querying the target field is the same as the principle of querying the target table. Specifically, the method of querying the target table can be referred to to realize the search of the target field. The difference from searching the target table is that only at least one target field is required.

[0069] Step S205: Use the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table.

[0070] In this embodiment, since the target fields correspond to the respective target tables, when filtering the target tables, each target table should be filtered using its corresponding target field, and field filtering of different target tables does not affect each other.

[0071] Step S206, using the large model and multiple filter tables to sort multiple target tables to obtain table recall results.

[0072] The table recall method of this embodiment constructs a first vector library and a second vector library corresponding to each table by using the table header and field of the table in advance, then performs a coarse-grained query at the header level through the first vector library to obtain multiple target tables similar to the query statement, then performs a fine-grained query at the field level for each table through the second vector library corresponding to each table to obtain the target field, then uses the target field to filter the corresponding target table, thereby eliminating irrelevant data, and finally uses the large model and the filtered table to sort the target table, adopts a two-stage strategy to perform vector similarity retrieval to determine the recall table, and then uses the large model and the filtered table to rearrange the recall table, which significantly improves the table recall accuracy and can solve the problem caused by too long context when calling the large model to recall the table.

[0073] In some possible implementations, the aforementioned step S201, constructing a first vector library for all tables in the database according to the table headers, specifically includes:

[0074] Get the header content and unique identifier of each table in the database;

[0075] Construct each header content into a first text string;

[0076] Using the embedding model to extract features from each first text string to obtain a feature vector corresponding to each table, and associating the feature vector with a table unique identifier of the corresponding table;

[0077] The feature vectors corresponding to all tables are extracted and summarized to obtain the first vector library.

[0078] The table recall method of this embodiment uses the embeddin model to convert the header information of the table into a vector, and uses the table unique identifier of the table to distinguish the vectors corresponding to each table. The first vector library takes the header of each table as the object, which can effectively distinguish different tables. The constructed first vector library can be used for coarse-grained retrieval of tables related to the query statement, which helps to improve query efficiency.

[0079] In some possible implementations, the aforementioned step S202, constructing a second vector library for all field cells of each table according to the fields of the table, specifically includes:

[0080] For each table in the database, perform the following operations:

[0081] Get the field content of each field in the table and the unique identifier of the table to which the field belongs;

[0082] constructing each field content into a second text string;

[0083] Use the embedding model to extract features from each second text string to obtain feature vectors corresponding to each field table, and associate each feature vector with the table unique identifier of the table to which the field belongs;

[0084] For each table, the feature vectors corresponding to all fields are summarized and extracted to obtain a second vector library corresponding to each table.

[0085] The table recall method of this embodiment uses the embeddin model to convert table field information into vectors for each table, and uses the table unique identifier of the table to distinguish the vectors corresponding to each table. The second vector library takes the fields of each table as objects, and can effectively distinguish different fields. The constructed second vector library can be used for fine-grained retrieval of fields related to the query statement to be queried, and can avoid processing irrelevant fields in the table.

[0086] In some possible implementations, the aforementioned step S203, searching the first vector library for multiple target tables similar to the query statement, specifically includes:

[0087] Obtaining a query statement input into the intelligent query service to obtain the query statement to be queried;

[0088] Use the embedding model to extract features from the query statement to obtain the query vector;

[0089] Calculating a first similarity between the query vector and each vector in the first vector library;

[0090] All tables whose first similarity is less than a first preset value are taken as target tables, or all tables are sorted from small to large based on the first similarity, and the tables that are ranked first by a first preset number are taken as target tables.

[0091] The table recall method of this embodiment, with the help of the created first vector library, realizes a rough query in the database for the query statement input to the intelligent query service, with a relatively high query speed, and can flexibly set the method for determining the target table to be queried according to the query accuracy and actual needs.

[0092] In some possible implementations, the aforementioned step S204, searching the second vector library corresponding to each target table for at least one target field similar to the query statement, specifically includes:

[0093] The following operations are performed on the second vector library corresponding to each target table:

[0094] Calculating a second similarity between the query vector and each vector in the second vector library;

[0095] All fields whose second similarity is less than a second preset value are taken as target fields, or all fields are sorted from small to large based on the second similarity, and the fields ranked in the front by a second preset number are taken as target fields.

[0096] The table recall method of this embodiment, for each target table, uses the created second vector library to implement detailed query in each table for the query statement input into the intelligent query service, has high query accuracy, and can flexibly set the method for determining the target field to be queried according to the query accuracy and actual needs.

[0097] In some possible implementations, the aforementioned step S205, using the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table, specifically includes:

[0098] Get all target fields corresponding to each target table;

[0099] Delete all fields except the corresponding target fields in each target table to obtain a filter table corresponding to each target table.

[0100] The table recall method of this embodiment uses the queried target fields to filter the corresponding table fields for each target table, filtering out most of the irrelevant table fields while returning some table fields that may be related to the query statement, significantly reducing the number of table fields processed by the large model.

[0101] In some possible implementations, the aforementioned step S206, using the large model and multiple filter tables to sort multiple target tables to obtain table recall results, specifically includes:

[0102] Combine each filter table with the query statement;

[0103] Use the large model to analyze each pair of combinations separately to obtain the correlation of each pair of combinations;

[0104] sorting the plurality of target tables from large to small based on the relevance;

[0105] Output multiple target tables in order, or output the target tables that are ranked first by a third preset number. In a specific implementation, the third preset number should be smaller than the first preset number.

[0106] In another embodiment, in order to facilitate understanding of the solution of the present invention, the following uses the intelligent number service as a specific application scenario, please refer to Figure 3 As shown, this embodiment provides a table recall method applied to this scenario, and the specific implementation process is as follows:

[0107] First, construct a table vector library;

[0108] Specifically, the process of building a table vector library is as follows: Get the table header information in the database, including table name, table definition, field name and its definition, primary and foreign keys, etc. Organize the header information into a text string and input it into the embedding model to extract features. One table corresponds to a high-dimensional feature vector (512 or 768 dimensions). Organize the feature vectors of all tables into a vector library, which can be used in the Chroma vector database or other similar tools. Each data in the vector library includes table vectors, table meta information (table name, table definition, etc.), table index, etc.

[0109] Next, build a field vector library;

[0110] Specifically, in a similar way to building a table vector library, each field in each table is used as a unit to build the corresponding field feature vector, and the feature vectors of all fields are organized into a vector library. Each data in the vector library includes a field vector and field meta information (the table name to which the field belongs, field type, field definition, etc.).

[0111] Next, query the Top K similar tables;

[0112] Please refer to Figure 4As shown in the figure, the specific query process is: obtain the query question entered by the user, use the embedding model to extract its vector query, search the table vector library based on the query, and return the Top K most similar tables. Here, the value of K can be slightly larger. This step of retrieval is equivalent to a rough sorting, filtering out most irrelevant tables while returning some tables that may be related to the query.

[0113] Next, query and filter irrelevant table fields;

[0114] Specifically, the process of querying and filtering irrelevant table fields is as follows: After returning the top M tables, you can search for fields in the top M tables that are similar to the query based on conditional query (only search for fields whose table information belongs to the top M tables). Get the similarity ranking of all fields and the query. You can filter out most of the irrelevant fields with low similarity to the query, and only keep the relevant fields in the top M tables.

[0115] In actual business scenarios, there are often wide tables, that is, a table contains dozens or hundreds of fields, while the table fields designed for a user query are often limited, which means that a large number of table-irrelevant fields will be fed to the large model as context, which will lead to a decrease in the accuracy of the large model and abnormalities caused by too long context. The above field filtering method can effectively filter out most of the irrelevant fields, which plays a role in streamlining the table. The context length of the TopK tables after streamlining is significantly reduced, effectively solving the problem of too long context.

[0116] Next, re-arrange the top K similar tables based on the large model;

[0117] After streamlining the table fields in the previous step, the context of each table's information is significantly reduced. At this point, the capabilities of the large model are used to analyze the relevance between the query and the Top K tables, so as to re-rank the Top K tables to obtain more accurate ranking and recall results.

[0118] Specifically, the role of re-ranking is to use the capabilities of the large model to accurately sort the returned Top K tables, so as to obtain more accurate recall results. And there is no need for the large model to process all the tables in the library; this two-stage recall strategy makes good use of and combines the capabilities of the embedding model and the large model, effectively improving the recall accuracy.

[0119] Finally, the recall result is returned;

[0120] After rearranging the top K tables, a new table sequence is obtained. The earlier a table appears in the sequence, the greater its relevance to the query. The top N (N < K) tables can be selected as the final retrieved tables for subsequent text-to-sql processes.

[0121] For comparison, take the self-built table retrieval test set as an example. For this test set, the conventional vector retrieval method and the method of the present invention are respectively used for testing. For the three test objects Recall@1, Recall@2, and Recall@3, the comparison results of the recall rates of the two methods are shown in Table 1.

[0122] Table 1 Comparison of recall rates of different table retrieval methods

[0123]

[0124] The table retrieval method of this embodiment has at least the following beneficial effects: It realizes a two-stage retrieval strategy from coarse to fine and a table field filtering method. The two-stage strategy recalls more accurate results through similarity retrieval in the vector library and large model rearrangement; the table field filtering well overcomes the problem of too long context when multiple tables or wide tables are input into the large model; in addition, compared with the existing table retrieval methods, the method of the present invention has higher table retrieval accuracy, which is beneficial to generating higher-quality sql statements in subsequent text-to-sql processes.

[0125] Next, the table retrieval device provided by the present invention will be described. The table retrieval device described below can be correspondingly referred to the table retrieval method described above.

[0126] Please refer to Figure 5 As shown, this embodiment provides a table retrieval device for implementing the table retrieval method described in any of the above. Specifically, the device includes: a first construction module 510, a second construction module 520, a first query module 530, a second query module 540, a filtering module 550, and a sorting module 560. Each of the above modules will be described in detail below:

[0127] The first construction module 510 is used to construct a first vector library for all tables in the database according to the table headers. Among them, the first vector library takes the entire database as an object, converts the data of each table header into a corresponding vector, and the vectors corresponding to all tables constitute the first vector library;

[0128] The second construction module 520 is used to construct a second vector library for all fields of each table according to the fields of the table. Among them, the second vector library takes each table as an object, converts the data of each field of the table into a corresponding vector, and the vectors corresponding to all fields constitute the second vector library. Each second vector library corresponds to a vector in the first vector library;

[0129] A first query module 530, configured to query a plurality of target tables similar to the query statement from the first vector library;

[0130] A second query module 540 is used to query at least one target field similar to the query statement from the second vector library corresponding to each target table;

[0131] A filtering module 550, configured to use the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table;

[0132] Sorting module 560, used to sort multiple target tables using the large model and multiple filter tables to obtain table recall results

[0133] The table recall device of this embodiment constructs a first vector library and a second vector library corresponding to each table by using the table header and field of the table in advance, then performs a coarse-grained query at the header level through the first vector library to obtain multiple target tables similar to the query statement, then performs a fine-grained query at the field level for each table through the second vector library corresponding to each table to obtain the target field, then uses the target field to filter the corresponding target table, thereby eliminating irrelevant data, and finally uses the large model and the filtered table to sort the target table, adopts a two-stage strategy to perform vector similarity retrieval to determine the recall table, and then uses the large model and the filtered table to rearrange the recall table, thereby significantly improving the table recall accuracy and solving the problem caused by too long context when calling the large model to recall the table.

[0134] The first building module 510 is further used for:

[0135] Get the header content and unique identifier of each table in the database;

[0136] Construct each header content into a first text string;

[0137] Using the embedding model to extract features from each first text string to obtain a feature vector corresponding to each table, and associating the feature vector with a table unique identifier of the corresponding table;

[0138] The feature vectors corresponding to all tables are extracted and summarized to obtain the first vector library.

[0139] The second building module 520 is further used for:

[0140] For each table in the database, perform the following operations:

[0141] Get the field content of each field in the table and the unique identifier of the table to which the field belongs;

[0142] constructing each field content into a second text string;

[0143] Use the embedding model to extract features from each second text string to obtain feature vectors corresponding to each field table, and associate each feature vector with the table unique identifier of the table to which the field belongs;

[0144] For each table, the feature vectors corresponding to all fields are summarized and extracted to obtain a second vector library corresponding to each table.

[0145] The first query module 530 is further used for:

[0146] Obtaining a query statement input into the intelligent query service to obtain the query statement to be queried;

[0147] Use the embedding model to extract features from the query statement to obtain the query vector;

[0148] Calculating a first similarity between the query vector and each vector in the first vector library;

[0149] All tables whose first similarity is less than a first preset value are taken as target tables, or all tables are sorted from small to large based on the first similarity, and the tables that are ranked first by a first preset number are taken as target tables.

[0150] The second query module 540 is further used for:

[0151] The following operations are performed on the second vector library corresponding to each target table:

[0152] Calculating a second similarity between the query vector and each vector in the second vector library;

[0153] All fields whose second similarity is less than a second preset value are taken as target fields, or all fields are sorted from small to large based on the second similarity, and the fields ranked in the front by a second preset number are taken as target fields.

[0154] The filtering module 550 is further used for:

[0155] Get all target fields corresponding to each target table;

[0156] Delete all fields except the corresponding target fields in each target table to obtain a filter table corresponding to each target table.

[0157] The sorting module 560 is further configured to:

[0158] Combine each filter table with the query statement;

[0159] Use the large model to analyze each pair of combinations separately to obtain the correlation of each pair of combinations;

[0160] sorting the plurality of target tables from large to small based on the relevance;

[0161] Output multiple target tables in order, or output the top third preset number of target tables.

[0162] It should be noted that each module in the above table recall device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in a memory in an electronic device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0163] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610 (processor), a communication interface 620 (Communications Interface), a memory 630 (memory) and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the table recall method, which includes: constructing a first vector library for all tables in the database according to the table header; constructing a second vector library for all field cells of each table according to the fields of the table; querying multiple target tables similar to the query statement from the first vector library; querying at least one target field similar to the query statement from the second vector library corresponding to each target table; using the target field to filter the corresponding target table to obtain a filter table corresponding to each target table; and sorting multiple target tables using a large model and multiple filter tables to obtain a table recall result.

[0164] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0165] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the table recall method provided by the above methods, which includes: constructing a first vector library for all tables in the database according to the table header; constructing a second vector library for all field cells of each table according to the fields of the table; querying multiple target tables similar to the query statement from the first vector library; querying at least one target field similar to the query statement from the second vector library corresponding to each target table; using the target field to perform field filtering on the corresponding target table to obtain a filtered table corresponding to each target table; and sorting multiple target tables using a large model and multiple filtered tables to obtain a table recall result.

[0166] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented by a processor to execute the table recall method provided by the above methods, the method comprising: constructing a first vector library for all tables in the database according to the table headers; constructing a second vector library for all field cells of each table according to the fields of the table; querying multiple target tables similar to the query statement from the first vector library; querying at least one target field similar to the query statement from the second vector library corresponding to each target table; using the target field to perform field filtering on the corresponding target table to obtain a filtered table corresponding to each target table; and sorting multiple target tables using a large model and multiple filtered tables to obtain a table recall result.

[0167] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0168] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A table recall method, characterized in that: The method comprises: Building a first vector library for all tables in the database according to table headers; According to the fields of the table, a second vector library is constructed for all the fields of each table; Querying multiple target tables similar to the query statement from the first vector library; Querying at least one target field similar to the query statement from the second vector library corresponding to each target table; Using the target field to perform field filtering on the corresponding target table to obtain a filtering table corresponding to each target table; Use a large model and multiple filter tables to sort multiple target tables to obtain table recall results; The step of constructing a first vector library for all tables in the database according to the table headers includes: Get the header content and unique identifier of each table in the database; Construct each header content into a first text string; Using the embedding model to extract features from each first text string to obtain a feature vector corresponding to each table, and associating the feature vector with a table unique identifier of the corresponding table; Summarize and extract the feature vectors corresponding to all tables to obtain a first vector library; The second vector library is constructed for all fields of each table according to the fields of the table, including: For each table in the database, perform the following operations: Get the field content of each field in the table and the unique identifier of the table to which the field belongs; constructing each field content into a second text string; Use the embedding model to extract features from each second text string to obtain feature vectors corresponding to each field table, and associate each feature vector with the table unique identifier of the table to which the field belongs; For each table, the feature vectors corresponding to all fields are respectively extracted and summarized to obtain a second vector library corresponding to each table; The step of searching the first vector library for a plurality of target tables similar to the query statement includes: Obtaining a query statement input into the intelligent query service to obtain the query statement to be queried; Use the embedding model to extract features from the query statement to obtain the query vector; Calculating a first similarity between the query vector and each vector in the first vector library; All tables whose first similarity is less than a first preset value are taken as target tables, or all tables are sorted from small to large based on the first similarity, and the tables that are ranked first by a first preset number are taken as target tables; The step of searching the second vector library corresponding to each target table for at least one target field similar to the query statement includes: The following operations are performed on the second vector library corresponding to each target table: Calculating a second similarity between the query vector and each vector in the second vector library; All fields whose second similarity is less than a second preset value are taken as target fields, or all fields are sorted from small to large based on the second similarity, and the fields that are ranked first by a second preset number are taken as target fields; The using the target field to filter the corresponding target table to obtain a filter table corresponding to each target table includes: Get all target fields corresponding to each target table; Delete all fields except the corresponding target fields in each target table to obtain a filter table corresponding to each target table; The method of using a large model and multiple filter tables to sort multiple target tables to obtain table recall results includes: Combine each filter table with the query statement; Use the large model to analyze each pair of combinations separately to obtain the correlation of each pair of combinations; sorting the plurality of target tables from large to small based on the relevance; Output multiple target tables in order, or output the top third preset number of target tables.

2. A table recall device, characterized in that: The device comprises: A first construction module, used for constructing a first vector library for all tables in the database according to table headers; The second construction module is used to construct a second vector library for all fields of each table according to the fields of the table; A first query module, used for querying a plurality of target tables similar to the query statement from the first vector library; A second query module, used for querying at least one target field similar to the query statement from the second vector library corresponding to each target table; A filtering module, used for performing field filtering on the corresponding target table using the target field to obtain a filtering table corresponding to each target table; The sorting module is used to sort multiple target tables using a large model and multiple filter tables to obtain table recall results; The first building block is further used for: Get the header content and unique identifier of each table in the database; Construct each header content into a first text string; Using the embedding model to extract features from each first text string to obtain a feature vector corresponding to each table, and associating the feature vector with a table unique identifier of the corresponding table; Summarize and extract the feature vectors corresponding to all tables to obtain a first vector library; The second building block is further used for: For each table in the database, perform the following operations: Get the field content of each field in the table and the unique identifier of the table to which the field belongs; constructing each field content into a second text string; Use the embedding model to extract features from each second text string to obtain feature vectors corresponding to each field table, and associate each feature vector with the table unique identifier of the table to which the field belongs; For each table, the feature vectors corresponding to all fields are respectively extracted and summarized to obtain a second vector library corresponding to each table; The first query module is further used for: Obtaining a query statement input into the intelligent query service to obtain the query statement to be queried; Use the embedding model to extract features from the query statement to obtain the query vector; Calculating a first similarity between the query vector and each vector in the first vector library; All tables whose first similarity is less than a first preset value are taken as target tables, or all tables are sorted from small to large based on the first similarity, and the tables that are ranked first by a first preset number are taken as target tables; The second query module is further used for: The following operations are performed on the second vector library corresponding to each target table: Calculating a second similarity between the query vector and each vector in the second vector library; All fields whose second similarity is less than a second preset value are taken as target fields, or all fields are sorted from small to large based on the second similarity, and the fields that are ranked first by a second preset number are taken as target fields; The filtering module is further used for: Get all target fields corresponding to each target table; Delete all fields except the corresponding target fields in each target table to obtain a filter table corresponding to each target table; The sorting module is further used for: Combine each filter table with the query statement; Use the large model to analyze each pair of combinations separately to obtain the correlation of each pair of combinations; sorting the plurality of target tables from large to small based on the relevance; Output multiple target tables in order, or output the top third preset number of target tables.

3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the table recall method as claimed in claim 1 is implemented.

4. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the table recall method as claimed in claim 1 is implemented.