Question answering method based on multi-table association and large language model based on metadata features and thought chain

Through the method based on metadata features and thinking chains, the problem of table association and SQL statement generation in multi-table query scenarios is solved, and efficient processing and accurate results acquisition of multi-table query in complex database systems are realized.

CN118245591BActive Publication Date: 2024-11-29NO 15 INST OF CHINA ELECTRONICS TECH GRP

Patent Information

Application Number
CN202410687924.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-11-29
Estimated Expiration
2044-05-30

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively solve the problems of multi-table association and conditional value extraction in multi-table query scenarios, especially in complex database systems. Traditional methods cannot play a good role in multi-task and multi-relational type scenarios, resulting in query generation algorithms. Restricted.

Method used

Using the multi-table associated large language model question and answer method based on metadata features and thinking chains, through data table preprocessing, metadata document establishment, building a Q&A thinking chain and generating a propt prompt template, guide the large language model to generate SQL statements, and realize table filtering and connect.

Benefits of technology

It improves the accuracy of table filtering and the accuracy of SQL statement generation in multi-table scenarios, and can correctly establish table connections in multi-table queries to improve the accuracy of answering questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118245591B_ABST
    Figure CN118245591B_ABST
Patent Text Reader

Abstract

The present invention discloses a multi-table association large language model question-answering method based on metadata features and thought chains, which performs data normalization processing on multiple data tables and establishes associations between data tables; extracts metadata features of data tables to obtain metadata documents, including field information and key connection relationships; constructs a question-answering thought chain based on the association relationship between data table field information; constructs a choose-prompt selection prompt and a generate-prompt generation prompt based on the question-answering thought chain, guides the large language model to filter out relevant tables from a database according to user questions, and generates corresponding SQL statements, and returns results after execution. When facing a multi-table query situation, the present invention can fully explore the association between table data information, improve the accuracy of table screening, thereby guiding the model to generate corresponding SQL statements and improve the accuracy of answering questions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a multi-table association large language model question answering method based on metadata features and thought chains. Background Art

[0002] In the current overview of multi-table query models, traditional or advanced models mainly rely on models in the field of deep learning, such as graph neural network (GNN) models and IRNet models. Although these methods perform well in solving certain problems, they have to some extent ignored the clear connection between queries and database tables, as well as their shortcomings in dealing with areas such as conditional value extraction and database schema encoding. In addition, these strategies usually only focus on a single task or a single relationship type, and cannot work well in multi-task and multi-relationship type scenarios. Therefore, when faced with multi-table query situations, traditional methods are still subject to some limitations and challenges.

[0003] Text2SQL is a natural language processing (NLP) task that aims to convert natural language questions into structured query language (SQL) queries. The goal of this task is to enable the computer to understand the questions asked by users and generate corresponding SQL queries based on the questions to retrieve the required information from the database.

[0004] In the Text2SQL task, the input is a natural language question and the output is a SQL query that can be executed directly in the database to get the answer. This technology has a wide range of applications in areas such as information retrieval, database query, and dialogue systems.

[0005] In complex database systems, multi-table query scenarios refer to situations where multiple database tables need to be involved in a joint query in a query statement to obtain the required information. When dealing with multi-table queries, whether it involves multiple database connections or is limited to a single database environment, the problem can essentially be reduced to a connection problem between multiple database tables. In this way, researchers can study multi-table queries under a unified framework, thereby improving the versatility and scalability of query generation algorithms, thereby solving Text2SQL tasks to establish correct connections between multiple tables and obtain the required results.

[0006] Common Text2SQL methods include:

[0007] Rule-based approach: Use hand-designed rules and templates to convert natural language questions into SQL query statements.

[0008] Statistical-based methods: Utilize statistical models and machine learning algorithms to learn the mapping relationship between natural language questions and SQL queries.

[0009] Neural network-based approaches: Use deep learning models such as recurrent neural networks, attention mechanisms, and transformers to learn semantic mappings between natural language and SQL queries.

[0010] However, the above existing methods still have difficulties and challenges in applying multi-table queries in Text2SQL tasks.

[0011] Therefore, how to provide a multi-table related large language model question-answering method based on metadata features and thought chains to improve the performance of large models in multi-table scenarios is a technical problem that needs to be urgently solved by technical personnel in this field. Summary of the invention

[0012] In view of the above research status and existing problems, the present invention provides a multi-table associated large model question-answering method based on metadata features and thought chains to improve the performance of screening tables in large model related multi-table scenarios.

[0013] The present invention provides a multi-table association large language model question answering method based on metadata features and thought chains, comprising the following steps:

[0014] Data table preprocessing: normalize multiple data tables and establish associations between them;

[0015] Create metadata document: extract metadata features of data table to obtain metadata document, including field information and key connection relationship;

[0016] Build a thinking chain: build a question-and-answer thinking chain based on the relationship between the field information in the data table;

[0017] Construct a prompt template: construct a choose-prompt selection prompt and a generate-prompt generation prompt based on the question-answer thinking chain; wherein,

[0018] The choose-prompt prompt is used to filter out relevant tables based on user questions and metadata documents; the generate-prompt prompt is used to receive the metadata document content corresponding to the relevant table and generate a prompt prompt based on the user question;

[0019] Question and answer prediction: Receive user questions, generate prompts using prompt templates, input the prompts into the pre-trained large language model, and generate corresponding SQL statements.

[0020] Preferably, the data normalization process for the multiple data tables includes one or more combinations of the following steps:

[0021] Data cleaning: including normalization of one or more of missing values, duplicate values ​​and outliers;

[0022] Data integration: merge related data from different data tables;

[0023] Data transformation: unify the data formats of different data tables and perform standardization processing to extract features from the data tables.

[0024] Preferably, the field information includes: the name of the data table, the entity fields in the data table, and the attribute fields corresponding to the entity fields.

[0025] Preferably, the step of extracting metadata features of the data table further comprises the following steps:

[0026] Annotate the meaning of the extracted field information;

[0027] Identify and obtain the data type of field information, and standardize and unify the data type of field information of the same category;

[0028] Identify and obtain primary key-foreign key relationships between data tables;

[0029] The extracted field information, field meaning, data type and primary key-foreign key relationship are integrated to obtain a metadata document.

[0030] Preferably, the construction of the thought chain comprises the following steps:

[0031] Construct the entity field association reasoning process model between data tables;

[0032] Construct an attribute field association reasoning process model corresponding to entity fields between data tables;

[0033] Build business rules and logic, including integrating the rules and logical relationships under the set business domain, and integrating them into the entity field association reasoning process model and the attribute field association reasoning process model.

[0034] Preferably, the generate-prompt generates a prompt including a prompt field, an input card slot and an output card slot; and is used to perform the following steps:

[0035] By filling the input card slot with the filtered table information, converting the language format, and user questions, the large language model is guided to generate the corresponding SQL statements.

[0036] The multi-table association large language model question answering method based on metadata features and thought chain proposed in the present invention has the following beneficial effects compared with the prior art:

[0037] The present invention parses and understands the NLP task, determines the multiple tables involved in the problem and the relationship between them. Understanding each table involved and understanding the correlation between the tables is the key to solving multi-table queries. According to the relationship between the problem and the table, the table and the connection conditions that need to be connected are determined, and the table connection operation can be performed according to the primary key foreign key relationship or other common attributes. According to the database table question and answer thinking chain implementation process, the choose-prompt selection prompt and the generate-prompt generation prompt are constructed respectively, wherein the choose-prompt selection prompt guides the large model to filter out relevant tables from the database according to the user's question, and the generate-prompt generation prompt is intended to fill the card slot with the filtered table information, convert the language format, the question and other key information, and then guide the model to generate the corresponding SQL statement, and return the result after execution.

[0038] When faced with multi-table query situations, the present invention can fully explore the associations between table data information, improve the accuracy of table screening, and thus guide the model to generate corresponding SQL statements, thereby improving the accuracy of answering questions. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work.

[0040] Figure 1 It is a flow chart of a multi-table association large language model question answering method based on metadata features and thought chains provided by an embodiment of the present invention;

[0041] Figure 2 is a flowchart of table data preprocessing provided by an embodiment of the present invention;

[0042] Figure 3 is a metadata feature extraction flow chart provided by an embodiment of the present invention;

[0043] Figure 4 It is a principle diagram of a database table question-answer thinking chain provided by an embodiment of the present invention;

[0044] Figure 5 This is a schematic diagram of a prompt learning principle provided by an embodiment of the present invention;

[0045] Figure 6 It is a flowchart of constructing a prompt template provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0047] When facing multi-table query scenarios in Text2SQL tasks, the following issues need to be considered:

[0048] Table association: In multi-table query tasks, it is necessary to identify and understand the associations between different database tables, including inner joins, outer joins, etc., to ensure that the information of multiple tables is correctly integrated.

[0049] Join conditions: The model must be able to accurately identify join conditions in natural language questions and convert them into join clauses in SQL query statements, covering aspects such as join conditions in the ON clause and filter conditions in the WHERE clause.

[0050] Query complexity: SQL query statements involved in multi-table queries are usually more complex, containing more clauses, operations, and nested structures. The model needs to be able to effectively process these complex structures and generate accurate SQL query statements.

[0051] Semantic reasoning: Multi-table query tasks require the model to have strong semantic reasoning capabilities and be able to solve problems involving relationships and attributes between multiple tables, including identifying indirect associations and inferring relationships between attributes.

[0052] Data sparsity: Since multi-table queries involve multiple database tables, there may be data sparsity issues, that is, some associations in the input question appear less frequently in the training data. This makes it difficult for the model to learn enough information from the training data to accurately generate multi-table query statements.

[0053] like Figure 1 As shown, the overall question-answering method of multi-table association large model question-answering based on metadata features and thought chains provided by the embodiment of the present invention first pre-processes the local data, then extracts the metadata features of the processed table data, and generates a metadata document. By constructing a database question-answering thought chain, the large model is guided to perform the reasoning steps of table screening and SQL statement generation according to user questions. In the process of screening the table, the generation process of SQL statements is optimized by introducing metadata documents. After the database executes the SQL statement generated by the large model, it returns the question result and updates the metadata document according to the result. Specifically, it includes the following steps:

[0054] Data table preprocessing: normalize multiple data tables and establish associations between them;

[0055] Create metadata document: extract metadata features of data table to obtain metadata document, including field information and key connection relationship;

[0056] Build a thinking chain: build a question-and-answer thinking chain based on the relationship between the field information in the data table;

[0057] Construct prompt templates: construct choose-prompt and generate-prompt based on the question-answer thinking chain; choose-prompt is used to filter out relevant tables based on user questions and metadata documents; generate-prompt is used to receive metadata document content corresponding to relevant tables and generate prompts based on user questions;

[0058] Question and answer prediction: Receive user questions in subsequent operations, use choose-prompt to obtain the selection table structure information, inject generate-prompt to generate prompts, input prompts into the pre-trained large language model, call the database chain based on the candidate table to perform database questions and answers, and generate corresponding SQL statements.

[0059] In this embodiment, ChatGLM3-6B-32K is selected as the general large language model, and text2vec-base-chinese is selected as the embedding model. ChatGLM3 has the advantages of low deployment cost and smooth output. Compared with its basic model, ChatGLM3-6B-32K has a larger sequence of context learning and multi-round dialogue capabilities. Text2vec-base-chinese has been trained with a large amount of Chinese text and has good text matching performance for multiple languages, especially Chinese.

[0060] In one embodiment, Figure 1 As shown, tabular data has multiple representations and storage forms, such as spreadsheets in csv format, paged tables in html format, and table management systems in database format. From the perspective of actual engineering application and management, local original tabular data has problems such as missing data, inconsistent data types, and inconsistent measurements. We use a series of processes to pre-process tabular data in advance and establish connections between tables to facilitate multi-table Q&A. Data normalization for multiple data tables includes one or more of the following steps:

[0061] Data cleaning: including normalization of one or more of missing values, duplicate values ​​and outliers;

[0062] Data integration: Merge related data from different data tables, including integrating metadata information with the same name into one table, or integrating tables with the same or common content into one table to reduce duplication and the number of tables;

[0063] Data transformation: unify the data formats of different data tables and perform standardization processing to extract features from the data tables.

[0064] In specific implementation, the preprocessing steps are as follows:

[0065] (1) Data cleaning:

[0066] Missing value processing: Detect and process missing values ​​in the data table. You can choose to fill missing values, delete rows or columns containing missing values, etc.

[0067] Outlier processing: Identify and process outliers in the data table. Outliers can be detected through statistical methods or visualization means and processed according to specific circumstances.

[0068] Duplicate value processing: Find and remove duplicate records in the data table to ensure the uniqueness of the data.

[0069] (2) Data Integration:

[0070] Table merging: Merge related data from different data tables for subsequent analysis and modeling.

[0071] (3) Data transformation:

[0072] Data format conversion: Convert the data types in the data table to ensure data consistency and comparability.

[0073] Feature extraction: Extract the required features from the original data for analysis and modeling of the metadata feature extraction process of the subsequent data table.

[0074] Data normalization: Normalize or standardize data to eliminate dimensional differences between different data.

[0075] (4) Data association:

[0076] Link establishment: Establish connections between data tables based on the relationship between data (such as primary key-foreign key relationship) to achieve data integration and association, and facilitate multi-table query.

[0077] Establish associations between data based on common fields or key values ​​in the data table, including primary keys, foreign keys, string matching, time windows, or geographic locations; use SQL statements to perform association operations. For example, use the JOIN keyword to associate data in two tables; use programming languages ​​(such as Python) to perform association operations. Common libraries such as Pandas provide a wealth of functions to process and merge data. This facilitates subsequent multi-table queries or analysis.

[0078] Ensure data consistency: During the data association process, it is necessary to ensure data consistency and integrity to avoid data redundancy or incorrect association.

[0079] Through the above data preprocessing steps, the data of multiple data tables can be effectively cleaned, integrated and converted, laying a solid foundation for subsequent data analysis, mining and modeling work, and improving the accuracy and efficiency of data processing.

[0080] In one embodiment, the field information includes: the name of the data table, the entity fields in the data table, and the attribute fields corresponding to the entity fields.

[0081] In one embodiment, after the local table data is preprocessed, metadata feature extraction is performed. Metadata feature extraction is a very critical step in the data processing and analysis process, which can help better understand the structure, meaning and relationship of the data table and provide a basis for answering questions. Figure 2 As shown in the figure, a table with 7 fields and named employee information is used for metadata feature extraction. Parse and understand the NLP task to determine the multiple tables involved in the problem and the relationship between them. This requires identifying the keywords, entities, and possible connection methods in the problem. Understand each table involved, including table structure, column names, primary key and foreign key relationships, and other information. Based on the relationship between the problem and the table, determine the tables that need to be connected and the connection conditions. Table connection operations can be performed based on primary key and foreign key relationships or other common attributes. Extracting metadata features of data tables includes the following steps:

[0082] Annotate the meaning of the extracted field information;

[0083] Identify and obtain the data type of field information, and standardize and unify the data type of field information of the same category;

[0084] Identify and obtain primary key-foreign key relationships between data tables;

[0085] The extracted field information, field meaning, data type and primary key-foreign key relationship are integrated to obtain a metadata document.

[0086] In the specific implementation, first extract the structural information of the table. Get the name of the data table to understand the entity or subject represented by the table. Count the number of fields in the data table to understand the dimension of the data. Get the name of each field, and infer the meaning of the field by the field name. Identify the primary key and foreign key in the data table to establish the relationship between the data tables.

[0087] Then annotate the meaning of the extracted fields. Consult the data dictionary or metadata document to obtain a detailed description and meaning of each field. If the field is highly professional, you need to communicate with business experts in related fields to confirm the meaning and business logic of the field.

[0088] At the same time, standardize and unify the data types of the extracted data. Obtain the data type of each field, such as integer, string, date, etc., to ensure the accuracy and consistency of the data. Understand the value range of each field to help verify the integrity and legitimacy of the data.

[0089] Next, extract the associations between the data. Identify the primary key-foreign key relationships between data tables to help establish associations between data tables. Draw a relationship diagram between data tables to show the association paths and dependencies between data.

[0090] Finally, all the extracted metadata features are integrated. The extracted table structure information, field meanings, data types and associations are integrated into the metadata document for subsequent use by the question-answering system.

[0091] Through the above metadata feature extraction process, we can gain an in-depth understanding of the structure and meaning of the data table, clarify the relationship between the data, and provide the necessary metadata support for building a question-and-answer system, so as to more accurately answer questions raised by users.

[0092] In one embodiment, the function of constructing a thinking chain is to establish a logical relationship between various knowledge elements based on the content of the data table and business knowledge, so as to help the question-answering system better understand the question and provide accurate answers. Figure 3 As shown in the figure, building a thinking chain includes the following steps:

[0093] Construct the entity field association reasoning process model between data tables;

[0094] Construct an attribute field association reasoning process model corresponding to entity fields between data tables;

[0095] Build business rules and logic, including integrating the rules and logical relationships under the set business domain, and integrating them into the entity field association reasoning process model and the attribute field association reasoning process model.

[0096] When executing:

[0097] (1) Associations between entities: In any data table, there may be associations between different entity fields. Taking the table provided in 2 as an example, the employee ID in the employee information table may be associated with the employee ID in the salary information table, thereby establishing an association between employee and salary information. Another example is that the department ID in the department information table is associated with the department ID in the employee information table in order to obtain detailed information about the department to which the employee belongs.

[0098] (2) Dependence between attributes: There are influence and constraint relationships between different attributes in a data table. For example, an employee's position attribute may affect his or her salary level, and different positions correspond to different salary grades. An employee's date of employment can be used to calculate length of service, which may affect an employee's promotion opportunities and salary benefits. By establishing an attribute dependency model, the system can better understand the relationship between attributes and accurately answer questions raised by users.

[0099] (3) Business rules and logic: When building a thinking chain, it is necessary to integrate the rules and logical relationships in a specific business field and incorporate them into entity associations and attribute dependencies. This includes understanding business processes, rules, and constraints, and ensuring that the system can accurately understand and apply these rules to provide correct answers to questions. For example, employees of different genders may have specific needs or restrictions in certain positions, and the impact of gender factors in employee management needs to be considered.

[0100] In one embodiment, generate-prompt generates a prompt including a prompt field, an input slot, and an output slot.

[0101] The following is an explanation of the principle of prompt learning:

[0102] Prompt learning is a method of guiding language models to perform specific tasks by designing natural language prompts or instructions. The purpose of prompt learning is to convert downstream tasks into pre-trained tasks through prompt templates. "Prompt engineering" is one of the core theories of prompt learning, which emphasizes how to construct or design appropriate prompts to guide the model to perform specific tasks, so that downstream tasks are closer to pre-trained models. These prompts can be natural language questions, declarative instructions, example input-output pairs, or other forms of guidance.

[0103] Take sentiment classification task as an example, Figure 5 As shown in the figure. For the same natural language task, different prompts can be designed. Different prompts may produce different effects, where the input slot can be one or more. By properly designing prompts, the model can be effectively guided to perform specific tasks and improve the performance and generalization ability of the model on downstream tasks. In prompt engineering, designing appropriate prompts is crucial and can affect the effect of model learning and reasoning.

[0104] Prompt engineering is an important method to guide models to learn and perform tasks. It can improve the performance and adaptability of models by carefully designing prompts to guide models to learn tasks in specific fields. Effective prompt design can enable models to better understand task requirements, reduce errors, and improve overall learning effects.

[0105] In this embodiment, Figure 6 As shown in the figure, the choose-prompt selection prompt and generate-prompt generation prompt are realized through the database table question-answering thinking chain. The English part in the figure is the machine language execution process, which is used to illustrate the execution logic of the question-answering thinking chain. The choose-prompt selection prompt is used to guide the large model to filter out relevant tables from the database according to the questions raised by the user. An example is as follows: Figure 6 In the question, for the input vector query: Who has a salary of 10,000, it is impossible to directly give the name of the employee with a salary of 10,000 through a single table. When establishing the thought chain, by reading the metadata features, it is known that the employee ID in the employee information table may be associated with the employee ID in the salary information table, thereby establishing the association between the employee name and the salary information, so that the employee information table and the salary information table can be selected when the choose-prompt prompt is selected. The generate-prompt prompt is designed to guide the model to generate the corresponding SQL statement by filling the card slot with the filtered table information, converting the language format, the question and other key information. After executing the SQL statement, the model will return the corresponding result.

[0106] The above embodiments of constructing a generative large language model combine deep learning algorithms in the field of artificial intelligence, and utilize their automatic text understanding, text generation, and context-aware capabilities to automatically extract key functional point descriptions from each paragraph in the document by analyzing the grammar, semantics, and context of the text, and output them by category. The generative large language model fine-tuned by the present invention can output standardized functional point entries in a fixed format, and based on the prompt word learning strategy, it can achieve the refinement of functional points without changing the output format. Thereby achieving end-to-end generation of the content and number of functional point entries from a complete document to different categories.

[0107] In one embodiment, the present invention trains a text classification model for function point category recognition based on the true value part of the normalized function point entries in a pre-labeled data set, and obtains the final function point entry estimation result by fusing the output result of the generative large language model, which can be directly used for subsequent cost calculation. The function point recognition technology based on the bidirectional encoding representation Transformer attention model further recognizes the normalized entry output of the above model, and fuses the recognition result with the normalized output result to achieve more accurate function point recognition. The text classification model training and reasoning process is as follows: Figure 2 shown.

[0108] The input of the text classification training process is the function point items in the data set, and the output truth value is the category corresponding to each item. The input of the test process is the function point items extracted by the generative large language model.

[0109] For the function point entries input into the model, this embodiment first needs to divide the text data into words or sub-words, that is, perform a word segmentation process, further extract the embedded code for each word, and extract the text segmentation features from the code through a multi-layer stacked Transformer encoder module, and finally perform text classification in the function point classifier and calculate the cross entropy loss.

[0110] The function point classifier includes a feedforward neural network and a softmax layer, which can be used as a task-specific output layer after the encoder. When fine-tuning the text, only one output layer needs to be added without retraining the entire model. Therefore, the present invention only uses the function point classification loss to update the parameters of the classifier.

[0111] The above embodiment of the construction of the BERT model for text classification achieves accurate classification of function point entries by fine-tuning the BERT model, that is, the text classification technology of the bidirectional encoding representation Transformer attention network. The model uses large-scale pre-training and learns universal language representation. Compared with traditional machine learning, it has more advanced semantic feature expression and can adapt to specific classification tasks through fine-tuning. It is easier to converge and has higher generalization and accurate discrimination performance.

[0112] In one embodiment, during the testing phase, since the input function point entries come from the output results of the generative large language model, which also include category judgment results, if the two results are consistent, the consistent category judgment result is used as the output; if the two results are inconsistent, the present invention will output the confidence of the classification result based on the text classification model, and replace the first output with a high-confidence function point recognition category to achieve more accurate reasoning.

[0113] For the overall realization of end-to-end software function point extraction and identification of the present invention, the above two algorithms are integrated into a unified process to segment each text paragraph from the complete document, locate the function point description in the text paragraph related to the function point, extract the content and number of function point entries from it, and finally realize the classification and identification of function points. The overall technical roadmap is as follows: Figure 3 shown.

[0114] The above is a detailed introduction to the multi-table association large language model question and answer method based on metadata features and thought chains provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0115] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

Claims

1. A multi-table association large language model question answering method based on metadata features and thought chain, Features: The steps include: Data table preprocessing: normalize multiple data tables and establish associations between them; Create metadata document: extract metadata features of data table to obtain metadata document, including field information and key connection relationship; Constructing a thinking chain: Constructing a question-answer thinking chain based on the relationship between the field information in the data table; including the following steps: Construct the entity field association reasoning process model between data tables; Construct an attribute field association reasoning process model corresponding to entity fields between data tables; Build business rules and logic, including integrating the rules and logical relationships under the business domain, and integrating them into the entity field association reasoning process model and the attribute field association reasoning process model; Construct a prompt template: construct a selection prompt and a generation prompt based on the question-answer thinking chain; wherein, The selection prompt is used to filter out relevant tables according to the user's question and metadata document; the generation prompt is used to receive the metadata document content corresponding to the relevant table and generate a prompt in combination with the user's question; the generation prompt guides the model to generate corresponding SQL statements by filling in the card slot to filter out key information; the key information includes: table information, conversion language format and question; Question and answer prediction: Receive user questions, generate prompts using prompt templates, input the prompts into the pre-trained large language model, and generate corresponding SQL statements.

2. According to the method of claim 1, a multi-table association large language model question answering method based on metadata features and thought chain, It is characterized in that The data normalization process for the multiple data tables includes one or more combinations of the following steps: Data cleaning: including normalization of one or more of missing values, duplicate values ​​and outliers; Data integration: merge related data from different data tables; Data transformation: unify the data formats of different data tables and perform standardization processing to extract features from the data tables.

3. According to the method of claim 1, a multi-table association large language model question answering method based on metadata features and thought chain, It is characterized in that The field information includes: the name of the data table, the entity fields in the data table, and the attribute fields corresponding to the entity fields.

4. According to claim 1, a multi-table association large language model question answering method based on metadata features and thought chain, It is characterized in that The step of extracting metadata features of the data table further comprises the following steps: Annotate the meaning of the extracted field information; Identify and obtain the data type of field information, and standardize and unify the data type of field information of the same category; Identify and obtain primary key-foreign key relationships between data tables; The extracted field information, field meaning, data type and primary key-foreign key relationship are integrated to obtain a metadata document.

5. According to the method of claim 1, a multi-table association large language model question answering method based on metadata features and thought chain, It is characterized in that The generation prompt includes a prompt field, an input card slot and an output card slot; and is used to perform the following steps: By filling the input card slot with the filtered table information, converting the language format, and user questions, the large language model is guided to generate the corresponding SQL statements.

Citation Information

Patent Citations

  • Structured query language generation method and device, electronic equipment and storage medium

    CN118093621A

Cited By

  • A power marketing processing method based on a knowledge graph enhanced large model

    CN122760080A