Data table recall method and device, storage medium and computer equipment
By training the data table recall model and fine-tuning the large language model for meta-learning processing, the problem of large SQL deviation in querying when the number of tables in the database is huge, and more accurate database query statement generation is achieved.
Patent Information
- Application Number
- CN202411675912.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-14
AI Technical Summary
When the number of tables in the database is huge, the query SQL generated by the large language model has a large deviation, making it difficult to capture contextual fragments related to user query problems, resulting in a degradation of model performance.
By training the data table recall model based on the preset instruction dataset, obtaining the pre-trained large language model and performing meta-learning processing, and generating instruction fine-tuning large language model. Then, the target matching data table is determined based on the data table recall model, and the instruction fine-tuning of the large language model generates database query statements corresponding to the user query problem.
When the number of data tables is huge, target matching data tables related to user query problems are recalled in a targeted manner, and more accurate database query statements are generated, which improves the accuracy of querying SQL.
Smart Images

Figure CN119621720A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data table recall method and device, a storage medium, and a computer device. Background Art
[0002] With the continuous development of computer technology, in the scenario of natural language generation query SQL, an important link is to determine the table related to the user query question in the database based on the user query question.
[0003] Currently, a large language model (LLM) method is used to capture context fragments related to user query questions. The existing method first directly splices all the table structures of the entire database as the context of the user query question, and then selects the relevant tables autonomously according to the semantics when the large language model generates the query SQL. The existing method can achieve good results when the number of database tables is small. However, in real business scenarios, databases with hundreds of tables are limited by the number of input tokens of the large language model LLM, and it is difficult to splice all the table structures in the database into the context; and as the number of context tokens increases, the large language model LLM is difficult to capture the context fragments related to the Question, and the model performance also decreases, resulting in a large deviation in the generated query SQL. Summary of the invention
[0004] In view of this, the present invention provides a data table recall method and device, a storage medium, and a computer device, the main purpose of which is to solve the problem of large deviation of query SQL generated by a large language model (LLM) when the number of data tables in the database is large.
[0005] According to one aspect of the present invention, a data table recall method is provided, comprising:
[0006] A data table recall model is trained based on a preset instruction data set to obtain a trained data table recall model;
[0007] Acquire a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model;
[0008] Acquire a user query question to be processed, and determine a target matching data table corresponding to the user query question to be processed based on the data table recall model;
[0009] The target matching data table is subjected to data table recall processing, and a database query statement corresponding to the user query question to be processed is generated based on the instruction fine-tuning of the large language model and the recalled target matching data table.
[0010] Furthermore, before training the data table recall model based on the preset instruction data set, the method further includes:
[0011] Obtaining user query questions from a historical user query question dataset, and performing word segmentation processing on the user query questions to obtain multiple query question word segments;
[0012] Matching the query word segmentation with each to-be-matched data table in the database to obtain a matching result;
[0013] The user query question is combined with the data table name of each data table to be matched to obtain a data pair including the user query question and the data table name; and a plurality of the data pairs are merged to obtain the instruction data set.
[0014] Furthermore, the query word segmentation is matched with each to-be-matched data table in the database to obtain a matching result, including:
[0015] Identify all entity names in the query question segmentation and determine entity aliases of the entity names;
[0016] Based on the entity name and the entity nickname, matching processing is performed on the entity names to be matched in each data table to be matched, so as to obtain matching results corresponding to each data table to be matched.
[0017] Furthermore, before training the data table recall model based on the preset instruction data set, the method further includes:
[0018] Determining the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table includes:
[0019] Determine the data pairs with a high matching degree in the matching results as positive samples in the instruction data set, and add a positive sample type identifier to the positive sample;
[0020] The data pairs with low matching degree in the matching results are determined as negative samples in the instruction data set, and a negative sample type identifier is added to the negative sample.
[0021] Furthermore, before the instruction data set is used to train the data table recall model to obtain the trained data table recall model, the method further includes:
[0022] Determine a negative sample data set based on the negative sample type identifier;
[0023] The negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model is trained based on the positive samples and the sampled negative samples.
[0024] Furthermore, the determining of the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table further includes:
[0025] Set the median range of matching degree;
[0026] The data pairs located within the median range of the matching degree are determined as enhanced samples in the instruction data set, so as to increase the training difficulty of the data table recall model.
[0027] Furthermore, performing meta-learning processing on the pre-trained large language model based on the instruction data set to obtain the instruction fine-tuning large language model includes:
[0028] Dividing different batches of meta-learning data pairs according to user query questions in the instruction dataset;
[0029] The meta-learner is trained in batches according to the order of the batches of meta-learning data pairs to obtain the instruction fine-tuning large language model.
[0030] According to another aspect of the present invention, a data table recall device is provided, comprising:
[0031] A recall model training module is used to train a data table recall model based on a preset instruction data set to obtain a trained data table recall model;
[0032] A meta-learning processing module, used to obtain a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model;
[0033] A target determination module, used for obtaining a user query question to be processed, and determining a target matching data table corresponding to the user query question to be processed based on the data table recall model;
[0034] The recall and generation module is used to perform data table recall processing on the target matching data table, and to generate a database query statement corresponding to the user query question to be processed based on the instruction fine-tuning the large language model and the recalled target matching data table.
[0035] Furthermore, the device also includes a data set creation module, which is used to:
[0036] Obtaining user query questions from a historical user query question dataset, and performing word segmentation processing on the user query questions to obtain multiple query question word segments;
[0037] Matching the query word segmentation with each to-be-matched data table in the database to obtain a matching result;
[0038] The user query question is combined with the data table name of each data table to be matched to obtain a data pair including the user query question and the data table name; and a plurality of the data pairs are merged to obtain the instruction data set.
[0039] Furthermore, the data set creation module is also used to:
[0040] Identify all entity names in the query question segmentation and determine entity aliases of the entity names;
[0041] Based on the entity name and the entity nickname, matching processing is performed on the entity names to be matched in each data table to be matched, so as to obtain matching results corresponding to each data table to be matched.
[0042] Furthermore, the device also includes a sample type determination module, which is used to:
[0043] Determining the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table includes:
[0044] Determine the data pairs with a high matching degree in the matching results as positive samples in the instruction data set, and add a positive sample type identifier to the positive sample;
[0045] The data pairs with low matching degree in the matching results are determined as negative samples in the instruction data set, and a negative sample type identifier is added to the negative sample.
[0046] Furthermore, the device also includes a sample sampling module, which is used to:
[0047] Determine a negative sample data set based on the negative sample type identifier;
[0048] The negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model is trained based on the positive samples and the sampled negative samples.
[0049] Furthermore, the sample type determination module is also used to:
[0050] Set the median range of matching degree;
[0051] The data pairs located within the median range of the matching degree are determined as enhanced samples in the instruction data set, so as to increase the training difficulty of the data table recall model.
[0052] Furthermore, the device also includes a model fine-tuning module, which is used to:
[0053] Dividing different batches of meta-learning data pairs according to user query questions in the instruction dataset;
[0054] The meta-learner is trained in batches according to the order of the batches of meta-learning data pairs to obtain the instruction fine-tuning large language model.
[0055] According to another aspect of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, wherein the executable instruction enables a processor to execute operations corresponding to the above-mentioned data table recall method.
[0056] According to another aspect of the present invention, there is provided a computer device, comprising a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0057] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned data table recall method.
[0058] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0059] The present invention provides a data table recall method and device, storage medium, and computer equipment. Compared with the prior art, the present invention obtains a trained data table recall model by training a data table recall model based on a preset instruction data set; obtains a pre-trained large language model, performs meta-learning processing on the pre-trained large language model based on the instruction data set, and obtains an instruction fine-tuning large language model; obtains a user query problem to be processed, and determines a target matching data table corresponding to the user query problem to be processed based on the data table recall model; performs data table recall processing on the target matching data table, and generates a database query statement corresponding to the user query problem to be processed based on the instruction fine-tuning large language model and the recalled target matching data table, and can recall the target matching data table closely related to the user query problem to be processed in a targeted manner when the number of data tables is large, thereby generating a database query statement related to the user query problem to be processed. In addition, the present invention also uses a preset instruction data set to fine-tune the pre-trained large language model, and the query SQL generated based on the context fragments closely related to the user query problem to be processed and the adjusted instruction fine-tuning large language model is more accurate.
[0060] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0062] Figure 1 A schematic diagram of a process flow of a data table recall method provided by an embodiment of the present invention is shown;
[0063] Figure 2 A schematic diagram of a process flow of another data table recall method provided by an embodiment of the present invention is shown;
[0064] Figure 3 A schematic diagram of another data table recall method provided by an embodiment of the present invention is shown;
[0065] Figure 4 A schematic diagram of the structure of a data table recall device provided by an embodiment of the present invention is shown;
[0066] Figure 5 A schematic diagram showing the structure of another data table recall device provided by an embodiment of the present invention is shown;
[0067] Figure 6 A schematic structural diagram of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0068] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0069] The embodiment of the present invention provides a data table recall method, such as Figure 1 As shown, the method includes:
[0070] 101. Training a data table recall model based on a preset instruction data set to obtain a trained data table recall model;
[0071] In an embodiment of the present invention, the current execution end trains a data table recall model based on a preset instruction data set to obtain a trained data table recall model. The instruction data set is a data set established based on the matching relationship between historical user query questions and data tables in a database. The data table recall model is used to characterize a type of model that uses deep learning to recall relevant valid data tables by introducing personalized user query questions, including YoutubeDNN model, dual tower model, etc., which are not specifically limited in the embodiment of the present invention.
[0072] 102. Obtain a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model;
[0073] In an embodiment of the present invention, the current execution end obtains a pre-trained large language model, wherein the large language model (LLM, Large Language Model) is also called a large language model, which is an artificial intelligence model designed to understand and generate human language. They are trained on a large amount of text data and can perform a wide range of tasks, including text summarization, translation, sentiment analysis, and the like. In an embodiment of the present invention, the pre-trained large language model is used to perform the task of generating query SQL based on user query questions. Compared with the currently open source commercially available large language models, Baichuan-7B has shown good results in language understanding, question and answer, dialogue, text generation, etc., so the embodiment of the invention preferentially selects Baichuan-7B as the base model.
[0074] It should be noted that, since there are already related applications in the prior art for generating query SQL based on a large language model, the present invention uses the large language model that has been used to generate query SQL as a pre-trained large language model, which can greatly improve the efficiency of model training without affecting the model generation capability.
[0075] In an embodiment of the present invention, after the current execution end obtains the pre-trained large language model, it performs meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuning large language model. Among them, meta-learning is used to characterize the learning process of learning an algorithm by automatically learning through a meta-learner. In simple terms, it is to learn how the algorithm learns (learning to learn) and master the method of algorithm learning. The meta-learning process integrates algorithms, models and features to learn. For example, given data, it is possible to derive the best algorithm based on the data, and then use this algorithm to derive the best model and features. In an embodiment of the present invention, the instruction fine-tuning large language model obtained by meta-learning processing can obtain the ability to generate query SQL through user query questions by learning the model learning process of generating query SQL through historical user query questions, thereby realizing the generation of query SQL for unprocessed user query questions. For example, the pre-trained large language model has learned, through meta-learning processing, the algorithm processing process of generating query SQL "SQL_A" from user query question A; the algorithm processing process of generating query SQL "SQL_B" from user query question B; the algorithm processing process of generating query SQL "SQL_C" from user query question C, etc. The resulting instruction fine-tuning large language model is considered to have the ability to generate query SQL based on user query questions. The instruction fine-tuning large language model can be used to automatically learn to generate query SQL "SQL_Z" based on unprocessed user query question Z, which is not specifically limited in the embodiments of the present invention.
[0076] 103. Obtain a user query question to be processed, and determine a target matching data table corresponding to the user query question to be processed based on the data table recall model;
[0077] In an embodiment of the present invention, the current execution end obtains a pending user query question, wherein the pending user query question is a query question determined based on the user's newly added query requirements, which is different from the historical user query question. After obtaining the pending user query question, the current execution end determines the target matching data table corresponding to the pending user query question from the database based on the trained data table recall model. For example, if the pending user query question is "Which fund managers have a master's degree as the highest degree and have been in office for less than 365 days?", the trained data table recall model can be used to determine the data tables "Public Fund Managers" and "Public Fund Management Personnel" from the database as target matching data tables, etc., which are not specifically limited in the embodiment of the present invention.
[0078] 104. Perform data table recall processing on the target matching data table, and generate a database query statement corresponding to the user query question to be processed based on the instruction fine-tuning large language model and the recalled target matching data table.
[0079] In an embodiment of the present invention, the current execution end performs data table recall processing on the target matching data table, and after the target matching data table is recalled, the target matching data table is spliced as the context of the user query problem to be processed, and then the large language model and the spliced context table are fine-tuned through instructions to generate a database query statement SQL corresponding to the user query problem to be processed.
[0080] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to reduce the annotation cost of manual data, enhance the generalization ability of the large language model LLM for different SQL tasks, and improve the versatility of the method of the present invention, another data table recall method is provided, such as Figure 2 As shown, before the step of training the data table recall model based on the preset instruction data set, the method further includes:
[0081] 201. Obtaining a user query question from a historical user query question data set, and performing word segmentation processing on the user query question to obtain a plurality of query question word segments;
[0082] In an embodiment of the present invention, the current execution end obtains user query questions from a historical user query question data set, and performs word segmentation processing on the user query questions to obtain multiple query question segmentations. Among them, the word segmentation processing is used to characterize the processing process of dividing a sentence into words, such as the user query question "Which fund managers have a master's degree and have less than 365 days in office?" can be divided into "fund", "manager", "most", "high", "education", "for", "master", "and", "in office", "days", "less than", "365 days", "of", "have", "which", that is, the words after the above division are query question segmentations, which are not specifically limited in the embodiment of the present invention.
[0083] 202. Match the query word segmentation with each to-be-matched data table in the database to obtain a matching result;
[0084] In the embodiment of the present invention, the current execution end matches the query question segmentation with each to-be-matched data table in the database to obtain a matching result. The matching process may be to select keywords for matching and obtain a matching result of a successful match or a failed match, or to match based on the features of the query question segmentation and obtain a matching result of a matching degree value, or to match based on the semantics of the query question segmentation and obtain a matching result of a matching degree value, etc., which is not specifically limited in the embodiment of the present invention.
[0085] In an embodiment of the present invention, when the current execution end uses the selected keywords for matching processing, it first identifies all the entity names in the query question segmentation, such as the query question segmentation "fund", "manager", "most", "high", "education", "for", "master", "and", "position", "number of days", "less than", "365 days", "of", "have", "which", and identifies that the entity names therein include "fund", "manager", "education", "master", which are not specifically limited in the embodiment of the present invention. After identifying the entity name, it is also necessary to determine the entity alias of the entity name; for example, the alias of "education" includes "diploma", and the alias of "manager" is "manager", "administrator", etc., which are not specifically limited in the embodiment of the present invention. The current execution end matches the entity names to be matched in each data table to be matched based on the entity name and the entity alias, and obtains matching results corresponding to each data table to be matched.
[0086] It should be noted that when the current execution end uses selected keywords for matching processing, in addition to the above-mentioned use of entity names as keywords for matching processing, words representing time, words representing logic, etc. can also be used, and the embodiment of the present invention does not make specific limitations.
[0087] 203. Combine the user query question with the data table name of each to-be-matched data table to obtain a data pair including the user query question and the data table name; and merge multiple data pairs to obtain the instruction data set.
[0088] In the embodiment of the present invention, the current execution end obtains the data table name of each data table to be matched, combines the user query question with the data table name to obtain a data pair including the user query question and the data table name, that is,<Question,Table> Data pairs. For example, the data pairs obtained by combining the user query question "Which fund managers have a master's degree and have been in office for less than 365 days" with the data table names of the data tables to be matched in the database are <Which fund managers have a master's degree and have been in office for less than 365 days, Table_1>, <Which fund managers have a master's degree and have been in office for less than 365 days, Table_2>, <Which fund managers have a master's degree and have been in office for less than 365 days, Table_3>, etc., which are not specifically limited in the embodiments of the present invention. The current execution end merges the multiple data pairs obtained to obtain the instruction data set.
[0089] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to facilitate the recall model to perform sampling or word segmentation processing on the data in the data set, another data table recall method is provided. Before the step of training the data table recall model based on the preset instruction data set, the method also includes:
[0090] The sample type of each data pair in the instruction data set is determined based on the matching result between the user query question in the instruction data set and the to-be-matched data table.
[0091] In an embodiment of the present invention, the current execution end determines the data pairs with a high degree of match in the matching results as positive samples in the instruction data set, and adds a positive sample type identifier to the positive samples; determines the data pairs with a low degree of match in the matching results as negative samples in the instruction data set, and adds a negative sample type identifier to the negative samples. Among them, the degree of match can be judged by setting a matching degree threshold, and the data pairs corresponding to the matching degree values greater than the matching degree threshold can be determined as data pairs with a high degree of match, and the data pairs corresponding to the matching degree values less than the matching degree threshold can be determined as data pairs with a low degree of match, which is not specifically limited in the embodiment of the present invention. Among them, the positive sample type identifier and the negative sample type identifier are used to characterize the identifiers for distinguishing positive samples from negative samples, and can be expressed in the form of a combination of one or more selected from numbers, letters, symbols, etc., which is not specifically limited in the embodiment of the present invention.
[0092] It should be noted that, in addition to the above-mentioned division of data pairs into positive samples and negative samples, in an embodiment of the present invention, the current execution end determines the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the data table to be matched, and further includes: setting a median interval of matching degree; the median interval of matching degree is used to characterize the data interval composed of two intermediate values of the matching degree value, such as the range of the matching degree value is [0, 100%], then the median interval of matching degree can be set to [50%, 75%] or [45%, 65%] or [60%, 80%], etc., which is not specifically limited in the embodiment of the present invention. After setting the median interval of matching degree, the current execution end determines the data pairs located in the median interval of matching degree as enhanced samples in the instruction data set, and performs a training operation on the data table recall model based on the enhanced samples, so as to increase the training difficulty of the data table recall model.
[0093] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to improve the training efficiency of the data table recall model and the accuracy of recalling valid data tables, another data table recall method is provided, wherein the step of using the instruction data set to train the data table recall model, before obtaining the trained data table recall model, the method further includes:
[0094] Determine a negative sample data set based on the negative sample type identifier;
[0095] The negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model is trained based on the positive samples and the sampled negative samples.
[0096] In an embodiment of the present invention, the current execution end determines all negative samples from the instruction data set based on the negative sample type identifier to form a negative sample data set; then the negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model performs training operations based on positive samples and sampled negative samples. Since the data volume of the sampled negative samples obtained after random sampling is much smaller than the data volume of all negative samples in the instruction data set, the training efficiency of the data table recall model can be improved. In addition, since the data volume of negative samples is larger than the data volume of positive samples, it may cause the data table recall model to be difficult to learn the rules of positive samples, so that the data volume of the sampled negative samples obtained by random sampling is more coordinated with the data volume of the positive samples in proportion, so that the performance of the trained data table recall model is improved.
[0097] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to improve the accuracy of query SQL generated by the large language model, another data table recall method is provided, such as Figure 3 As shown, the step of performing meta-learning processing on the pre-trained large language model based on the instruction data set to obtain the instruction fine-tuning large language model includes:
[0098] 301. Divide different batches of meta-learning data pairs according to user query questions in the instruction data set;
[0099] In the embodiment of the present invention, the current execution end divides different batches of meta-learning data pairs according to the user query questions in the instruction data set, that is, multiple data pairs corresponding to each user query question are a batch, forming a batch of meta-learning data pairs with the same number of user query questions. For example, the instruction data set contains 600 data pairs, which are related to 20 user query questions. Then, according to these 20 user query questions, the 600 data pairs are divided into 20 batches. Since the user query questions are combined with each data table to be matched in the database to form a data pair, each of the above 20 batches of meta-learning data pairs contains 30 data pairs, which is not specifically limited in the embodiment of the present invention.
[0100] 302. Perform batch training operations on the meta-learner according to the order of the batches of each meta-learning data pair to obtain the instruction fine-tuning large language model.
[0101] In the embodiment of the present invention, the current execution end performs batch training operations on the meta-learner according to the order of the batches of each meta-learning data pair to obtain the instruction fine-tuning large language model. The meta-learner is also called an optimizer, which is used to optimize various data of the large language model, such as model structure, model parameters, loss function, objective function, etc., so that the instruction fine-tuning large language model obtained after optimization has autonomous learning ability, and after the data table recall model is recalled to the target matching data table, the corresponding database query statement is automatically generated based on the to-be-processed user query problem and the target matching data table.
[0102] The embodiment of the present invention provides a data table recall method. Compared with the prior art, the present invention obtains a trained data table recall model by training a data table recall model based on a preset instruction data set; obtains a pre-trained large language model, performs meta-learning processing on the pre-trained large language model based on the instruction data set, and obtains an instruction fine-tuning large language model; obtains a user query problem to be processed, and determines a target matching data table corresponding to the user query problem to be processed based on the data table recall model; performs data table recall processing on the target matching data table, and generates a database query statement corresponding to the user query problem to be processed based on the instruction fine-tuning large language model and the recalled target matching data table. In the case of a large number of data tables, the target matching data table closely related to the user query problem to be processed can be recalled in a targeted manner, thereby generating a context fragment closely related to the user query problem to be processed. In addition, the present invention also uses a preset instruction data set to fine-tune the pre-trained large language model, and the query SQL generated based on the context fragment closely related to the user query problem to be processed and the adjusted instruction fine-tuning large language model is more accurate.
[0103] As the above Figure 1 The implementation of the method shown in the figure, the embodiment of the present invention provides a data table recall device, such as Figure 4 As shown, the device comprises:
[0104] The recall model training module 41 is used to train the data table recall model based on the preset instruction data set to obtain a trained data table recall model;
[0105] A meta-learning processing module 42 is used to obtain a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model;
[0106] A target determination module 43 is used to obtain a user query question to be processed, and determine a target matching data table corresponding to the user query question to be processed based on the data table recall model;
[0107] The recall and generation module 44 is used to perform data table recall processing on the target matching data table, and generate a database query statement corresponding to the user query question to be processed based on the instruction fine-tuning large language model and the recalled target matching data table.
[0108] Further, such as Figure 5 As shown, the device further includes a data set creation module 45, which is used to:
[0109] Obtaining user query questions from a historical user query question dataset, and performing word segmentation processing on the user query questions to obtain multiple query question word segments;
[0110] Matching the query word segmentation with each to-be-matched data table in the database to obtain a matching result;
[0111] The user query question is combined with the data table name of each data table to be matched to obtain a data pair including the user query question and the data table name; and a plurality of the data pairs are merged to obtain the instruction data set.
[0112] Furthermore, the data set creation module 45 is also used for:
[0113] Identify all entity names in the query question segmentation and determine entity aliases of the entity names;
[0114] Based on the entity name and the entity nickname, matching processing is performed on the entity names to be matched in each data table to be matched, so as to obtain matching results corresponding to each data table to be matched.
[0115] Further, such as Figure 5 As shown, the apparatus further includes a sample type determination module 46, which is used to:
[0116] Determining the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table includes:
[0117] Determine the data pairs with a high matching degree in the matching results as positive samples in the instruction data set, and add a positive sample type identifier to the positive sample;
[0118] The data pairs with low matching degree in the matching results are determined as negative samples in the instruction data set, and a negative sample type identifier is added to the negative sample.
[0119] Further, such as Figure 5 As shown, the device further includes a sample sampling module 47, which is used for;
[0120] Determine a negative sample data set based on the negative sample type identifier;
[0121] The negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model is trained based on the positive samples and the sampled negative samples.
[0122] Furthermore, the sample type determination module 46 is further configured to:
[0123] Set the median range of matching degree;
[0124] The data pairs located within the median range of the matching degree are determined as enhanced samples in the instruction data set, so as to increase the training difficulty of the data table recall model.
[0125] Further, such as Figure 5 As shown, the device further includes a model fine-tuning module 47, which is used to:
[0126] Dividing different batches of meta-learning data pairs according to user query questions in the instruction dataset;
[0127] The meta-learner is trained in batches according to the order of the batches of meta-learning data pairs to obtain the instruction fine-tuning large language model.
[0128] The embodiment of the present invention provides a data table recall device. Compared with the prior art, the present invention obtains a trained data table recall model by training a data table recall model based on a preset instruction data set; obtains a pre-trained large language model, performs meta-learning processing on the pre-trained large language model based on the instruction data set, and obtains an instruction fine-tuning large language model; obtains a user query problem to be processed, and determines a target matching data table corresponding to the user query problem to be processed based on the data table recall model; performs data table recall processing on the target matching data table, and generates a database query statement corresponding to the user query problem to be processed based on the instruction fine-tuning large language model and the recalled target matching data table, and can recall the target matching data table closely related to the user query problem to be processed in a targeted manner when the number of data tables is large, thereby generating a context fragment closely related to the user query problem to be processed. In addition, the present invention also uses a preset instruction data set to fine-tune the pre-trained large language model, and the query SQL generated based on the context fragment closely related to the user query problem to be processed and the adjusted instruction fine-tuning large language model is more accurate.
[0129] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the data table recall method in any of the above method embodiments.
[0130] Figure 6A schematic diagram of the structure of a computer device provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the computer device.
[0131] like Figure 6 As shown, the computer device may include: a processor (processor) 602 , a communication interface (Communications Interface) 604 , a memory (memory) 606 , and a communication bus 608 .
[0132] The processor 602 , the communication interface 604 , and the memory 606 communicate with each other via a communication bus 608 .
[0133] The communication interface 604 is used to communicate with other devices such as clients or other servers.
[0134] The processor 602 is used to execute the program 610, and specifically can execute the relevant steps of the above-mentioned data table recall method.
[0135] Specifically, the program 610 may include program codes, which include computer operation instructions.
[0136] The processor 602 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the computer device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0137] The memory 606 is used to store the program 610. The memory 606 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0138] The program 610 may be specifically configured to enable the processor 602 to perform the following operations:
[0139] A data table recall model is trained based on a preset instruction data set to obtain a trained data table recall model;
[0140] Acquire a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model;
[0141] Acquire a user query question to be processed, and determine a target matching data table corresponding to the user query question to be processed based on the data table recall model;
[0142] The target matching data table is subjected to data table recall processing, and a database query statement corresponding to the user query question to be processed is generated based on the instruction fine-tuning of the large language model and the recalled target matching data table.
[0143] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0144] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data table recall method, characterized in that: include: A data table recall model is trained based on a preset instruction data set to obtain a trained data table recall model; Acquire a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model; Acquire a user query question to be processed, and determine a target matching data table corresponding to the user query question to be processed based on the data table recall model; The target matching data table is subjected to data table recall processing, and a database query statement corresponding to the user query question to be processed is generated based on the instruction fine-tuning of the large language model and the recalled target matching data table.
2. The method according to claim 1, characterized in that Before training the data table recall model based on the preset instruction data set, the method further includes: Obtaining user query questions from a historical user query question dataset, and performing word segmentation processing on the user query questions to obtain multiple query question word segments; Matching the query word segmentation with each to-be-matched data table in the database to obtain a matching result; The user query question is combined with the data table name of each data table to be matched to obtain a data pair including the user query question and the data table name; and a plurality of the data pairs are merged to obtain the instruction data set.
3. The method according to claim 2, characterized in that The matching process of the query word segmentation with each to-be-matched data table in the database to obtain the matching result includes: Identify all entity names in the query question segmentation and determine entity aliases of the entity names; Based on the entity name and the entity nickname, matching processing is performed on the entity names to be matched in each data table to be matched, so as to obtain matching results corresponding to each data table to be matched.
4. The method according to claim 1, characterized in that: Before training the data table recall model based on the preset instruction data set, the method further includes: Determining the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table includes: Determine the data pairs with a high matching degree in the matching results as positive samples in the instruction data set, and add a positive sample type identifier to the positive sample; The data pairs with low matching degree in the matching results are determined as negative samples in the instruction data set, and a negative sample type identifier is added to the negative sample.
5. The method according to claim 4, characterized in that Before the instruction data set is used to train the data table recall model to obtain the trained data table recall model, the method further includes: Determine a negative sample data set based on the negative sample type identifier; The negative sample data set is randomly sampled to obtain sampled negative samples, so that the data table recall model is trained based on the positive samples and the sampled negative samples.
6. The method according to claim 4, characterized in that The determining the sample type of each data pair in the instruction data set based on the matching result between the user query question in the instruction data set and the to-be-matched data table further comprises: Set the median range of matching degree; The data pairs located within the median range of the matching degree are determined as enhanced samples in the instruction data set, so as to increase the training difficulty of the data table recall model.
7. The method according to any one of claims 1 to 6, characterized in that: The performing meta-learning processing on the pre-trained large language model based on the instruction data set to obtain the instruction fine-tuning large language model comprises: Dividing different batches of meta-learning data pairs according to user query questions in the instruction dataset; The meta-learner is trained in batches according to the order of the batches of meta-learning data pairs to obtain the instruction fine-tuning large language model.
8. A data table recall device, characterized in that: include: A recall model training module is used to train a data table recall model based on a preset instruction data set to obtain a trained data table recall model; A meta-learning processing module, used to obtain a pre-trained large language model, and perform meta-learning processing on the pre-trained large language model based on the instruction data set to obtain an instruction fine-tuned large language model; A target determination module, used for obtaining a user query question to be processed, and determining a target matching data table corresponding to the user query question to be processed based on the data table recall model; The recall and generation module is used to perform data table recall processing on the target matching data table, and to generate a database query statement corresponding to the user query question to be processed based on the instruction fine-tuning the large language model and the recalled target matching data table.
9. A storage medium, characterized in that: The storage medium stores at least one executable instruction, and the executable instruction executes an operation corresponding to the data table recall method according to any one of claims 1 to 7.
10. A computer device, characterized in that: It includes a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the data table recall method according to any one of claims 1 to 7.