Table lookup method, apparatus and device, computer readable storage medium and computer program product
By using preset prompt engineering templates and large language models to enhance user problems and searching in the multi-dimensional table information vector database, the accuracy and efficiency problems of table search in the NL2SQL scenario are solved, and more efficient and accurate table search is achieved.
Patent Information
- Application Number
- CN202411971004.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-27
AI Technical Summary
The accuracy and efficiency of table search in the NL2SQL scenario are low in the prior art. It is mainly due to the failure to effectively enhance the key information in the query statement, relying on a large amount of manual annotations, and only a small amount of information in the table is used for searching.
The user's original problems are enhanced by using preset prompt engineering templates and large language models, and the enhanced problems are generated, and the table information vector database of multiple dimensions is retrieved, and the feature vectors of multiple dimensions of each initial table are obtained, and the target table corresponding to the original problem is finally determined.
By enhancing problem processing and multi-dimensional table information retrieval, the accuracy and efficiency of table searches are improved, the table structure and information can be more comprehensively portrayed, and the user's original intention is enhanced.
Smart Images

Figure CN120045560A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data query, and in particular to a table lookup method, device, equipment, computer-readable storage medium, and computer program product. Background Art
[0002] NL2SQL (Natural Language to Structured Query Language) technology, as a bridge connecting natural language and structured data query, represents the forefront progress in the fields of data analysis and database interaction. This technology ingeniously converts intuitive natural language queries into powerful SQL instructions, thus greatly eliminating technical barriers, making data exploration unprecedentedly accessible, and deepening the affinity and efficiency of the human-computer interface. With the rapid evolution and iteration of large code generation models, the accuracy and efficiency of writing SQL code have become mature. Especially in the case of clear query intentions and providing accurate relevant table information, these models can almost perfectly write correct SQL.
[0003] However, the rapid development of technology has not completely eliminated the core obstacles in NL2SQL applications. The informal expressions and information omissions of users during query construction, combined with the physical limitations of the large model's processing ability due to the context length, jointly pose a severe test to the effectiveness of technical implementation. Among this series of challenges, how to efficiently and accurately screen and provide the least necessary and most relevant database table information has become a decisive factor in improving query accuracy and optimizing the user experience. This process not only concerns the accuracy of the final data retrieval but also is the key to ensuring the smoothness and satisfaction of user interaction. Therefore, accurately finding relevant tables is not only the focus of continuous breakthroughs in NL2SQL technology but also an important cornerstone for promoting the field of data analysis towards a higher level of intelligent interaction.
[0004] The existing table lookup solutions mainly have the following problems:
[0005] 1) The key information in the query statement is not effectively enhanced. Generally, the original question is directly used to find relevant table information, and the accuracy is limited.
[0006] 2) Rely on a large amount of manual annotation. For example, several themes are pre-divided for the tables in the database, and each theme only involves a few tables. When subsequent users ask questions, they first select a theme and then ask questions. This method results in a large amount of manual work, the granularity of theme division is difficult to evaluate, and cross-theme queries cannot be performed, with poor flexibility.
[0007] 3) Only a small amount of information about the table is used when finding the table with the question, resulting in low accuracy of the search results. Summary of the Invention
[0008] Embodiments of the present application provide a table lookup method, device, equipment, computer-readable storage medium, and computer program product to improve the accuracy and efficiency of table lookup in the NL2SQL scenario.
[0009] Embodiments of the present application adopt the following technical solutions:
[0010] In a first aspect, embodiments of the present application provide a table lookup method, and the table lookup method includes:
[0011] Obtain the user's original question;
[0012] Use a preset prompt engineering template and a large language model to perform enhancement processing on the original question to obtain an enhanced question;
[0013] According to the enhanced question, retrieve in the table information vector databases of multiple dimensions respectively to obtain initial table retrieval results of multiple dimensions. Each initial table retrieval result of each dimension includes at least one initial table;
[0014] Obtain the feature vectors of multiple dimensions of each initial table;
[0015] Determine the target table corresponding to the original question according to the enhanced question and the feature vectors of multiple dimensions of each initial table.
[0016] Optionally, the using a preset prompt engineering template and a large language model to perform enhancement processing on the original question to obtain an enhanced question includes:
[0017] Use a preset prompt engineering template and a large language model to perform slot recognition on the original question to obtain the key entity information corresponding to the original question;
[0018] Generate the enhanced question according to the original question and the corresponding key entity information.
[0019] Optionally, the table information vector databases of multiple dimensions include a vector database of table own information, a vector database of table field information, a vector database of table index information, and a vector database of table code value information. The retrieving in the table information vector databases of multiple dimensions respectively according to the enhanced question to obtain initial table retrieval results of multiple dimensions includes:
[0020] Perform vectorization processing on the enhanced question to obtain an enhanced question vector;
[0021] According to the enhanced question vector, retrieve in the vector database of table own information to obtain a first initial table retrieval result;
[0022] Retrieve in the vector database of the table field information according to the enhanced problem vector to obtain a second initial table retrieval result;
[0023] Retrieve in the vector database of the table index information according to the enhanced problem vector to obtain a third initial table retrieval result;
[0024] Retrieve in the vector database of the table code value information according to the enhanced problem vector to obtain a fourth initial table retrieval result.
[0025] Optionally, after retrieving in the vector databases of table information in multiple dimensions respectively according to the enhanced problem to obtain initial table retrieval results in multiple dimensions, the table lookup method further includes:
[0026] Perform a fusion process on the initial table retrieval results in multiple dimensions to obtain a fused initial table retrieval result;
[0027] The obtaining of the feature vectors in multiple dimensions of each initial table includes:
[0028] Obtain the feature vectors in multiple dimensions of each initial table in the fused initial table retrieval result.
[0029] Optionally, the obtaining of the feature vectors in multiple dimensions of each initial table includes:
[0030] Retrieve in the table feature vector database for each initial table respectively to obtain the feature vectors in multiple dimensions of each initial table;
[0031] Wherein, the table feature vector database is used to store the feature vectors in multiple dimensions of each table.
[0032] Optionally, the determining of the target table corresponding to the original problem according to the enhanced problem and the feature vectors in multiple dimensions of each initial table includes:
[0033] Perform a vectorization process on the enhanced problem to obtain an enhanced problem vector;
[0034] Calculate the similarity between the feature vectors in multiple dimensions of each initial table and the enhanced problem vector respectively to obtain the similarity scores in multiple dimensions of each initial table;
[0035] Determine the target table corresponding to the original problem according to the similarity scores in multiple dimensions of each initial table.
[0036] Optionally, the determining of the target table corresponding to the original problem according to the similarity scores in multiple dimensions of each initial table includes:
[0037] Calculate the comprehensive similarity score of each initial table according to the similarity scores of multiple dimensions of each initial table;
[0038] Determine the target table corresponding to the original problem according to the comprehensive similarity score of each initial table.
[0039] In a second aspect, an embodiment of the present application further provides a table lookup device, where the table lookup device includes:
[0040] A first acquisition unit, configured to acquire the original problem of the user;
[0041] An enhancement processing unit, configured to perform enhancement processing on the original problem by using a preset prompt engineering template and a large language model to obtain an enhanced problem;
[0042] A retrieval unit, configured to perform retrieval in a table information vector database of multiple dimensions respectively according to the enhanced problem to obtain initial table retrieval results of multiple dimensions, and each initial table retrieval result of each dimension includes at least one initial table;
[0043] A second acquisition unit, configured to acquire feature vectors of multiple dimensions of each initial table;
[0044] A determination unit, configured to determine the target table corresponding to the original problem according to the enhanced problem and the feature vectors of multiple dimensions of each initial table.
[0045] In a third aspect, an embodiment of the present application further provides a device, including:
[0046] A processor; and a memory arranged to store computer-executable instructions, and the executable instructions, when executed, cause the processor to execute any one of the foregoing table lookup methods.
[0047] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program / instructions are stored, and when the computer program / instructions are executed by a processor, any one of the foregoing table lookup methods is implemented.
[0048] In a fifth aspect, an embodiment of the present application further provides a computer program product, including computer program / instructions, and when the computer program / instructions are executed by a processor, any one of the foregoing table lookup methods is implemented.
[0049] The above at least one technical solution adopted in the embodiments of the present application can achieve the following beneficial effects: In the table lookup method of the embodiments of the present application, the original question of the user is first obtained; then the original question is enhanced by using a preset prompt engineering template and a large language model to obtain an enhanced question; then, according to the enhanced question, retrievals are respectively performed in the table information vector databases in multiple dimensions to obtain initial table retrieval results in multiple dimensions, and the initial table retrieval results in each dimension include at least one initial table; then the feature vectors in multiple dimensions of each initial table are obtained; finally, the target table corresponding to the original question is determined according to the enhanced question and the feature vectors in multiple dimensions of each initial table. On the one hand, the table lookup method of the embodiments of the present application enhances the original question of the user by using prompt engineering and a large language model, thereby strengthening the original intention of the user and improving the accuracy of table lookup. On the other hand, the initial screening of the table is realized through the constructed table information vector databases in multiple dimensions, improving the table lookup efficiency, and more comprehensively depicting the structure and information of the table from multiple dimensions, further improving the accuracy of table lookup. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0051] Figure 1 is a schematic flowchart of a table lookup method in an embodiment of the present application;
[0052] Figure 2 is a schematic flowchart of a table lookup process in an embodiment of the present application;
[0053] Figure 3 is a schematic structural diagram of a table lookup device in an embodiment of the present application;
[0054] Figure 4 is a schematic structural diagram of a device in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0055] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0056] The following will describe in detail the technical solutions provided by the embodiments of the present application with reference to the drawings.
[0057] The main technical terms involved in this application include:
[0058] (1) NL2SQL: That is, Natural Language to Structured Query Language, which is a key technology for modern data analysis and database interaction. It allows users to pose queries in natural language, and the system automatically converts them into SQL statements.
[0059] (2) Intent Recognition: It is an important concept in the field of Natural Language Processing (NLP), especially in application scenarios such as dialogue systems, voice assistants, chatbots, etc. It refers to the ability of a machine to understand and determine the intent or purpose expressed by a user through text or speech. Simply put, it is to parse the information input by the user and understand what the user wants to do or what kind of information the user wants to obtain.
[0060] (3) Ambiguity: It refers to the situation where a sentence, a word, or an expression has multiple reasonable interpretations without additional context.
[0061] (4) Slot Recognition: Slot Recognition refers to the process of automatically identifying and classifying specific types of information fragments (slots) in the user input during the process of Natural Language Understanding (NLU). These information fragments can be entities (such as person names, locations, times, etc.), attributes (such as colors, sizes, etc.), or other words or phrases with specific meanings. The goal of slot recognition is to map free-form text to predefined slot types, providing structured information for subsequent processing.
[0062] (5) Slot Filling: Slot Filling refers to further precisely filling or confirming the specific values of these slots after the slots are recognized. It involves validating and refining the results of slot recognition to ensure that each slot has a suitable and specific content. Slot filling may need to combine context information, additional inquiries, or default values to complete. Simply put, slot recognition is to find out which parts are important information (slots), while slot filling is to determine what the specific content of this information is.
[0063] (6) Embedding Model: It is a machine learning technology mainly used to convert high-dimensional, sparse input data (such as words, sentences in text, pixel points in images, or nodes in a network, etc.) into low-dimensional, dense vector representations, and these vectors are called embeddings. Embedding vectors capture the features and semantic information of the original data, making similar inputs closer in the embedding space and different inputs farther apart. This representation method not only reduces the dimension of the data, improves the processing efficiency, but also enhances the model's ability to understand the relationships between input data.
[0064] (7) Sentence-level embedding models (such as BERT, Sentence-BERT, Universal Sentence Encoder, etc.) are specifically designed to convert an entire sentence or short text into a fixed-length semantic vector. The input of a sentence-level embedding model is a piece of text, usually one or more complete sentences, and sometimes it can also be a paragraph or short text. The output of a sentence-level embedding model is a semantic vector, usually a one-dimensional real number vector with a fixed length, representing the overall semantic information of the input sentence. The dimension of this vector is usually related to a specific model. For example, the dimension of BERT-base is 768. The role of a sentence semantic embedding model is to convert a sentence into a semantic vector for tasks such as similarity judgment, sentiment analysis, semantic search, etc. It enables machines to understand language and has a wide range of applications.
[0065] (8) Semantic vector: A semantic vector is an array of numbers in a high-dimensional space. Each dimension represents an aspect of semantic features, and the entire vector comprehensively expresses the meaning and context information of a word or sentence, manifested as a series of continuous floating-point numbers in form.
[0066] (9) Vector database: A vector database is a database system designed specifically for storing, managing, and efficiently retrieving high-dimensional vector data. In many AI fields such as natural language processing (NLP), computer vision, and recommendation systems, data is often converted into vector form (for example, vectors obtained through methods such as extraction by an Embedding Model) for easy processing and analysis. The core ability of a vector database lies in handling the similarity search problem of such data, that is, given a query vector, quickly finding the most similar set of vectors in the database.
[0067] A vector database usually includes the following key components: 1) Vector storage: This is the core part of the vector database, responsible for storing high-dimensional vector data. Vector storage is usually optimized to support efficient vector insertion, update, and deletion operations. 2) Index structure: To accelerate vector retrieval, a vector database uses specific index structures such as KD-Tree, Ball-Tree, Locality-Sensitive Hashing (LSH), Approximate Nearest Neighbor (ANN) index, etc. These index structures are designed to quickly find the vector most similar to the query vector. 3) Query engine: The query engine of a vector database is responsible for processing user query requests and using the index structure to quickly find the most relevant vectors. 4) Metadata management: In addition to the vector data itself, a vector database also needs to manage related metadata, such as vector identifiers, creation times, tags, etc.
[0068] (10) Code Values: Generally refers to the numerical / enumeration value representation after encoding certain categorical variables or categorical data in the original data. This encoding converts non-numerical, descriptive data (such as text labels) into the form of numbers / enumerations for easy computer processing, storage, and analysis.
[0069] (11) Metrics: Refers to the key numerical values or statistical results used to quantify, evaluate, and display a specific business or operational situation. The metrics in the report help decision-makers, managers, and analysts quickly understand the organization's performance, trends, and key success factors. These metrics are usually closely linked to the enterprise's strategic goals and are used to measure aspects such as efficiency, effectiveness, growth, or compliance.
[0070] (11) Key Performance Indicators (KPIs): This is the most common type of metric, directly related to the enterprise's strategic goals. For example, sales growth rate, customer satisfaction score, market share, etc., which reflect whether the enterprise is moving towards the established goals.
[0071] (12) Financial Metrics: Include revenue, profit, cost, profit margin, cash flow, etc., used to evaluate the company's financial health and profitability.
[0072] (13) Operational Metrics: Such as production efficiency, inventory turnover rate, order processing time, etc., which focus on the daily operational efficiency and process improvement of the enterprise.
[0073] (14) Customer Metrics: Such as Customer Acquisition Cost (CAC), Customer Lifetime Value (CLV), customer retention rate, etc., which help understand customer behavior and optimize the customer experience.
[0074] (15) Marketing Metrics: Click-Through Rate (CTR), conversion rate, Return on Ad Spend (ROAS), etc., which evaluate the effectiveness of marketing activities and ROI (Return on Investment), etc.
[0075] (16) Schema: The Schema in a database is a logical concept used to organize and manage the object structure of the database. It defines a set of rules and templates that describe the layout of the database, including the structure, relationships, and constraints of the data. Specifically in this application, the Schema usually refers to the basic structure for storing data in Tables.
[0076] (17) Token Limit: Token Limit, in the context of large language models (LLMs), refers to the upper limit of the maximum number of tokens that a model can handle in the input or generate in the output. A token is the basic unit of text processing, which can be a word, sub-word, character, or text segment, depending on the tokenization strategy of the model. Each token is usually mapped to a numerical ID and is part of the model's input or output. When a user submits a request to the model, if the text in the request (after being converted into tokens) exceeds the model's Token Limit, the user may need to split the text and submit it in batches, or the model itself will automatically truncate the input to the allowed length before processing. Therefore, it is very important to understand and follow the Token Limit when using large models.
[0077] (18) NER: That is, "Named Entity Recognition", an abbreviation in the field of natural language processing (NLP). Named Entity Recognition is a type of information extraction task, aiming to identify entities with specific meanings in text, such as person names, place names, organization names, time, quantity, etc., and classify them into predefined categories.
[0078] (19) Semantic feature vector: It is a high-dimensional vector form used to represent the meaning of text (such as words, phrases, or sentences) in natural language processing (NLP). These vectors are learned from a large amount of text data through machine learning techniques and can capture the semantic and contextual relationships between words. Each word or phrase is mapped to a continuous real-number vector space, where similar vectors in the space correspond to semantically similar words. This representation makes it possible to calculate the similarity between words, perform semantic reasoning, or build complex semantic models, and is the basis for modern NLP tasks such as sentiment analysis, machine translation, and question-answering systems.
[0079] (20) Semantic Feature Vector of a Sentence: It is a high-dimensional vector representation used to express the meaning of an entire sentence. It is obtained by combining the word vectors of each word in the sentence or directly learning from the sentence text using a deep learning model to capture the global semantic information of the sentence. This vector can reflect the main idea, sentiment color, context-dependent meaning, etc. of the sentence and is crucial for natural language processing tasks such as text classification, sentiment analysis, semantic similarity calculation, and machine translation. In short, the semantic feature vector of a sentence is a compact, numerical, and formalized representation of the sentence meaning. Obtaining a semantic vector usually involves transforming the original data (such as text, images, or other types of data) into a vector representation in a high-dimensional space, which can capture the semantic features of the input data. The hidden layer output of a pre-trained language model (such as BERT, RoBERTa, T5, etc.) or the output processed by a Pooling layer is used as the semantic vector. Usually, the output of the last layer or a specific Pooling technique (such as the output of the CLS token, average pooling, or max pooling of all Token embeddings) is taken to represent the semantics of the entire text.
[0080] NL2SQL means enabling a large language model to understand the user's question / interrogative sentence and then generate SQL to query the required data from the database. To enable the large language model to generate the correct SQL, in addition to the user clearly stating the question, a very important step is to also tell the large language model the tables involved in the question. If there is only the question without table information, the large language model does not know the specific table names and field names and cannot generate the correct SQL. However, there are thousands of tables in the database, and the primary problem to be solved is how to determine which tables are relevant to the user's question.
[0081] Based on this, the embodiments of the present application provide a table lookup method, as Figure 1 shown, provides a flowchart of a table lookup method in the embodiments of the present application. The table lookup method at least includes the following steps S110 to step S150:
[0082] Step S110, obtain the user's original question.
[0083] Combined with Figure 2 , provides a flowchart of a table lookup process in the embodiments of the present application. In the process of looking up tables in the NL2SQL scenario, it is necessary to first obtain the original question input by the user. The embodiments of the present application support the user to input original question information in different formats. For example, the user can input a query text content in natural language form, such as "Please help me check what the balance of the loans with flexible repayment is for each branch of the Beijing Branch as of the end of 2023?", or can also input a piece of voice, and then convert it into text content through voice recognition and other technologies.
[0084] Step S120: Use a preset prompt engineering template and a large language model to enhance the original question, obtaining an enhanced question.
[0085] Considering that the information in the original query question input by the user is not focused enough, scattered, and may contain too much redundant and irrelevant information, the key information in the original question is further strengthened by combining a preset prompt engineering template and a large language model. By strengthening the key information, the user's query intention is clarified, facilitating the subsequent precise search for relevant tables.
[0086] The purpose of setting the prompt engineering template is to drive the large language model to extract key information of specific fields of interest from the original question, thereby strengthening the user's original question. Its specific structure and content can be flexibly designed according to the requirements of the actual application field. The type of large language model can also be flexibly selected from existing large language models according to the requirements of the actual application scenario, and no specific limitation is made here.
[0087] Step S130: According to the enhanced question, perform retrievals in the table information vector databases of multiple dimensions respectively, obtaining initial table retrieval results of multiple dimensions. Each initial table retrieval result of each dimension includes at least one initial table.
[0088] Existing table lookup schemes usually directly map the literal information of "table creation statements (DDL)" or "table names and table descriptions" to semantic vectors, that is, use the semantic vectors of table creation statements or table description information to represent table information. Although this method is simple, on the one hand, the semantic information of table creation statements is not strong, and the effect of directly converting them into vectors using a conventional semantic Embedding model is not good; on the other hand, "table names and table descriptions" only use the description information of the table, lacking the representation of information such as fields, metrics, and code values in the table, losing table features that are very helpful for finding tables, resulting in low accuracy of the lookup results.
[0089] Based on this, the embodiments of the present application propose a new method for representing and mapping table structure table information, that is, multiple-dimensional table information vector databases are constructed in advance based on the structure of the table and the information contained in the table. These dimensions can cover the basic information of the table itself such as table names and table description information, field information, metric information, and code value information contained in the table, etc. Different-dimensional table information vector databases are used to store the table information of all tables in different dimensions. For example, the vector database of table fields is used to store the field information contained in all tables, and the vector database of table metrics is used to store the metric information contained in all tables, thereby comprehensively depicting the table from multiple dimensions. Of course, which dimensions of table information vector databases are specifically set can be flexibly set by those skilled in the art according to the actual scenario requirements, and no specific limitation is made here.
[0090] Based on the table information vector database constructed in multiple dimensions above, use the enhanced questions to perform retrieval and matching in the table information vector database of each dimension respectively. Algorithms for retrieval and matching can be, for example, cosine similarity and other algorithms, so as to obtain the initial table retrieval results of each dimension. Each dimension can output at least one initial table related to the user input question. Of course, specifically how many initial tables are output for each dimension can be customized according to actual needs and will not be specifically limited here.
[0091] The above steps are to find tables in each dimension respectively, which can be regarded as the initial screening process of the tables. By the initial screening of the tables, most irrelevant tables can be filtered out, thus improving the subsequent query efficiency.
[0092] Step S140, obtain the feature vectors of multiple dimensions of each initial table.
[0093] In order to further improve the accuracy of table search, it is necessary to comprehensively consider the relevance between the feature information of each table in multiple dimensions and the user input question. Therefore, it is necessary to further obtain the feature vectors of multiple dimensions of each initial table obtained after the above steps of screening, which can include, for example, the feature vectors of the table's own information, the feature vectors of the table fields, the feature vectors of the table metrics, etc.
[0094] Step S150, determine the target table corresponding to the original question according to the enhanced question and the feature vectors of multiple dimensions of each initial table.
[0095] Based on the feature vectors of multiple dimensions of each initial table obtained through the above steps, the structure and information of each initial table can be more comprehensively characterized from multiple dimensions, and the relevance between each initial table and the enhanced question can be more accurately evaluated, so as to determine the final target table among multiple initial tables, further narrowing the subsequent data query range and serving as the basis for subsequent data query.
[0096] The table search method of the embodiments of the present application, on the one hand, uses prompt engineering and large language models to enhance the user's original question, thereby strengthening the user's original intention and improving the accuracy of table search. On the other hand, through the constructed table information vector database in multiple dimensions, the initial screening of tables is realized, the table search efficiency is improved, and the structure and information of tables are more comprehensively characterized from multiple dimensions, further improving the accuracy of table search.
[0097] In some embodiments of the present application, the using of the preset prompt engineering template and large language model to enhance the original question to obtain the enhanced question includes: using the preset prompt engineering template and large language model to perform slot recognition on the original question to obtain the key entity information corresponding to the original question; generating the enhanced question according to the original question and the corresponding key entity information.
[0098] In an actual scenario, the information in the original query question input by the user may not be focused enough, the information may be scattered, and there may be too much redundant and irrelevant information. For example, the user inputs: Please help me check what the balance of the loan with flexible borrowing and repayment is for each sub-branch of the Beijing Branch as of the end of 2023? The main information among them is time, institution, indicator, and the words describing and modifying the indicator. Therefore, the large language model can be enabled to identify slots in the original question by presetting a prompt engineering template, extract these words from the original question, and strengthen the user's query intention through these words.
[0099] Using the method of a prompt engineering template to drive the large language model to automatically extract information is simple and easy to implement. And by designing a customized prompt engineering template for a specific field, key information that meets the specific application scenario can be accurately extracted from the text.
[0100] To facilitate the understanding of the embodiments of the present application, the following is an example of a field-specific prompt engineering template, where {question} can be adjusted and filled according to actual business requirements:
[0101]
Provide engineering template
[0102] You are an ETL and data analysis expert in a bank. Please extract the entities in the question of the banking business user: time, specific institution, logical institution, indicator, indicator description.
[0103] Explanation:
[0104] 1) Institutions generally refer to sub-branches and outlets. Branches generally refer to provincial-level banks and municipal-level banks. Sub-branches generally refer to district- and county-level banks. Outlets / savings offices are the most front-end institutions of the bank.
[0105] 2) Institutions are divided into two categories: specific institutions and logical institutions. Specific and clear institutions are specific institutions, such as "Beijing Branch", "Shandong Branch", etc.; while general institutions like "each branch", "each sub-branch", "all secondary institutions", "the whole country", etc. are logical institutions.
[0106] 3) When the institution in the question is not clear, such as when it involves a geographical area, the institution level is determined according to the area. Branches generally refer to provincial-level regions and municipal-level regions, and sub-branches generally refer to district- and county-level regions.
[0107] Example:
[0108] Question: What is the number of sleeping merchants in each first sub-branch of the Beijing Branch?
[0109] Output: {"Time":[],"Specific institution":["Beijing Branch"],"Logical institution":["first sub-branch"],"Indicator":"number of merchants","Indicator description":"sleeping"}
[0110] Question: As of the end of 2023, what is the number of monthly active users of the JD Co-branded Card at the Hekou District Sub-branch of the Dongying Branch of Shandong Branch?
[0111] Output: {"Time": ["December 31, 2023"], "Specific Institution": ["Hekou District Sub-branch of the Dongying Branch of Shandong Branch"], "Logical Institution": [], "Indicator": "Number of Monthly Active Users", "Indicator Description": "JD Co-branded Card"}
[0112] Requirement: With full reference to the instructions and examples, first output the analysis logic, and then output the entity results. The overall output should be strictly in the following JSON format, with keys in Chinese.
[0113] {
[0114] "Analysis Logic": {...}, # Analysis and extraction logic
[0115] "Entity Results": {
[0116] "Time": [...], # List the time involved in the question
[0117] "Specific Institution": [...], # List the specific institutions involved in the question
[0118] "Logical Institution": [...], # List the logical institutions involved in the question
[0119] "Indicator": "...",
[0120] "Indicator Description": "...",
[0121] }
[0122] }
[0123] The user's question is: {Question}
[0124] The output is:
[0125]
Prompt Engineering Example
[0126] You are an ETL and data analysis expert in a bank. Please extract the entities in the user's question about banking business: Time, Specific Institution, Logical Institution, Indicator, Indicator Description.
[0127] Instructions:
[0128] 1) Institutions generally refer to sub-branches and outlets. Branches generally refer to provincial-level banks and municipal-level banks. Sub-branches generally refer to district- and county-level banks. Outlets / Savings Offices are the most front-end institutions of the bank.
[0129] 2) The institutions are divided into two categories: specific institutions and logical institutions. Specific and definite institutions are specific institutions, such as "Beijing Branch", "Shandong Branch", etc.; while general reference institutions are logical institutions, such as "each branch", "each sub-branch", "all secondary institutions", "the whole country", etc.
[0130] 3) When the institution in the question is not clear, such as when it involves geographical regions, determine the institution level according to the region. Generally, a branch refers to a provincial-level region or a municipal-level region, and a sub-branch generally refers to a district or county-level region.
[0131] Example:
[0132] Question: What is the number of sleeping merchant accounts in each first-level branch of Beijing Branch?
[0133] Output: {"Time":[],"Specific Institutions":["Beijing Branch"],"Logical Institutions":["first-level branch"],"Indicator":"Number of merchant accounts","Indicator Description":"Sleeping"}
[0134] Question: As of the end of 2023, what is the number of monthly active users of the JD co-branded card in Hekou District Sub-branch, Dongying City, Shandong Branch?
[0135] Output: {"Time":["December 31, 2023"],"Specific Institutions":["Hekou District Sub-branch, Dongying City, Shandong Branch"],"Logical Institutions":[],"Indicator":"Number of monthly active users","Indicator Description":"JD co-branded card"}
[0136] Requirement: Fully refer to the description and examples, first output the analysis logic, and then output the entity results. The overall output should be strictly in the following JSON format, with the key in Chinese
[0137] {
[0138] "Analysis Logic": {...}, # Analysis and extraction logic
[0139] "Entity Results": {
[0140] "Time": [...], # List the times involved in the question
[0141] "Specific Institutions": [...], # List the specific institutions involved in the question in a list
[0142] "Logical Institutions": [...], # List the logical institutions involved in the question in a list
[0143] "Indicator": "...",
[0144] "Indicator Description": "...",
[0145] }
[0146] }
[0147] The user's question is: "What is the balance of manufacturing loans of each tertiary institution of the Shandong Branch and the Hainan Branch at the end of 2023?"
[0148] The output is:
[0149]
Output result
[0150] "Analysis logic": {
[0151] "Time recognition": "The end of 2023 specifies a specific time point, that is, December 31, 2023.",
[0152] "Specific institution recognition": "The Shandong Branch and the Hainan Branch are two clear specific institutions.",
[0153] "Logical institution recognition": "Each tertiary institution is a logical institution, generally referring to all third-level institutions (usually referring to sub-branches or institutions at the corresponding level) under these two branches.
[0154] "Indicator and description recognition": "The loan balance is the indicator, and manufacturing is the description of this indicator, indicating the type of loan that needs to be analyzed.",
[0155] },
[0156] "Entity result": {
[0157] "Time": ["December 31, 2023"],
[0158] "Specific institution": ["Shandong Branch", "Hainan Branch"],
[0159] "Logical institution": ["Each tertiary institution"],
[0160] "Indicator": "Loan balance",
[0161] "Indicator description": "Manufacturing",
[0162] },
[0163] },
[0164] There are two major strategies in the design of the above prompt engineering template. One is to emphasize that the reason should be output first and then the result, and the other is to standardize the output format for convenient direct use of the model output result. The first strategy requires the large language model to forcefully give reasons through the prompt "Output the analysis logic first, and then the entity result", so as to let the large language model automatically trigger the thinking chain mechanism, and then let the large language model give more logical answers during reasoning. Inputting the above prompt to a large language model such as the open-source large model Qwen72B can obtain the above JSON format entity.
[0165] The key entity information: time, institution, indicator, and indicator result can be easily extracted from the returned results. Then, the original question (Query) and the extracted key information are concatenated, and the intention is strengthened by restating the key information, denoted as QueryA. The concatenation logic is to append the entity json information extracted by the large language model to the end of the original question sentence. For example, it can be represented in the form of Table 1 below:
[0166] Table 1
[0167]
[0168] Based on the above enhanced question, retrieve the tables related to the current question by means of semantic similarity or keyword fuzzy indexing, etc.
[0169] In some embodiments of the present application, the vector databases of table information in multiple dimensions include the vector database of table own information, the vector database of table field information, the vector database of table indicator information, and the vector database of table code value information. According to the enhanced question, retrieve respectively in the vector databases of table information in multiple dimensions, and the initial table retrieval results in multiple dimensions obtained include: performing vectorization processing on the enhanced question to obtain an enhanced question vector; retrieving in the vector database of table own information according to the enhanced question vector to obtain a first initial table retrieval result; retrieving in the vector database of table field information according to the enhanced question vector to obtain a second initial table retrieval result; retrieving in the vector database of table indicator information according to the enhanced question vector to obtain a third initial table retrieval result; retrieving in the vector database of table code value information according to the enhanced question vector to obtain a fourth initial table retrieval result.
[0170] Continue to refer to Figure 2 , the vector databases of table information in multiple dimensions constructed in the present application mainly include the vector database of table own information, the vector database of table field information, the vector database of table indicator information, and the vector database of table code value information. The vector database of table own information is the vector database of table information with a conventional structure, mainly including components such as PageContent, metadata, vector, and index. Among them, PageContent is the original text information, metadata is the label describing the text information, generally of dictionary type, the vector is the semantic vector obtained based on PageContent, generally a 1024*1 array, and the index is the fast retrieval structure generated based on the vector.
[0171] Therefore, the structure of the vector database of table own information can be represented in the form of Table 2 below:
[0172] Table 2
[0173]
[0174] When constructing a table information vector database with different dimensions, the following templates can be used to describe the table structure:
[0175] 1) Template for table itself description: The table name is..., and the description and purpose of the table are...
[0176] 2) Template for table field description: The fields included in the table are {(The meaning of field co1 is..., the data type is...[, whether it is a code value field, and the common code values are...]), (The meaning of field col2 is..., the data type is...[, whether it is a code value field, and the common code values are...])...(The meaning of field coln is..., the data type is...[, whether it is a code value field, and the common code values are...])}
[0177] 3) Template for table index description: The indexes included in table TableName are {(Index 1: The meaning is...), (Index 2: The meaning is...)...(Index n: The meaning is...)}
[0178] 4) Template for table code value description: The code values included in table TableName are {(Code value column 1: The meaning is..., and the common top N code values are [<Code value 1: Code value meaning>...<Code value N: Code value meaning>]),...Code value column: The meaning is..., and the common top N code values are [<Code value 1: Code value meaning>...<Code value N: Code value meaning>])}
[0179] Example: Suppose there is a table in the database with the following structure:
[0180] CREATE TABLE PublicLoanLedger(
[0181] CustomerID INT NOT NULL,-- Customer ID, not null
[0182] st_date DATE NOT NULL,-- Statistical date, not null, recording the specific date of data statistics
[0183] LoanBalance DECIMAL(15,2)NOT NULL,-- Loan balance, not null, accurate to two decimal places, used to record the current balance of the loan
[0184] LoanType VARCHAR(50) NOT NULL, -- Loan type, not null, a coded value column. For example, 'Working capital loan', etc. A corresponding coded value table is required to define these types in detail.
[0185] IndustryCategory VARCHAR(50) NOT NULL, -- Industry category to which the customer belongs, not null, a coded value column. For example, 'Manufacturing', 'Service', 'IT', etc. Similarly, a coded value table is required to define it. )
[0187] Table itself:
[0188] Table name: Corporate loan customer information table.
[0189] Table description: This table is used to record the loan ledger information of corporate customers and is a snapshot table. Its purpose is to query the loan balances of corporate loan customers and can be grouped and statistically analyzed by loan type and loan balance.
[0190] Table fields:
[0191] The fields included in the table are {The meaning of CustomerID is customer ID, and the data type is INT;
[0192] The meaning of st_date is statistical date, and the data type is DATE;
[0193] The meaning of LoanBalance is loan balance, and the data type is DECIMAL(15, 2);
[0194] The meaning of LoanType is loan type, and the data type is varchar. It is a coded value column, and common coded values include 'Working... loan', etc.;
[0195] The meaning of IndustryCategory is the industry category to which the customer belongs, and the data type is varchar. It is a coded value column, and common coded values include 'Manufacturing', etc.
[0196] }}
[0197] Table metrics:
[0198] The metrics included in the corporate loan customer information ledger table are {Loan balance: Corporate loan balance, which usually refers to the amount of loan principal that a borrower has not repaid to a financial institution (such as a bank, credit union, or other lending institution) at a certain point in time in the corporate loan business}
[0199] Table coded values:
[0200] The coded values included in the corporate loan customer information ledger table are {
[0201] The meaning of LoanType is loan type, and common code values include ["Current... Loan",
[0202] "Fixed... Loan",
[0203] "Mergers and Acquisitions... Loan",
[0204] "Green... Loan",
[0205] "Non - Fixed... Credit",...];
[0206] The meaning of IndustryCategory is the industry category to which the customer belongs, and common code values include ["Manufacturing",
[0207] "Wholesale and Retail",
[0208] "Real Estate",
[0209] "Construction",
[0210] "Culture, Sports and Entertainment",
[0211] "Public Management, Social Security and Social Organizations",...];
[0212] }
[0213] Describing the information in the data table using the above template can achieve the following effects:
[0214] 1) Make the whole description more natural - language - like. Since the text information will ultimately be converted into vectors, the embedding model is best at performing high - dimensional mapping on text that is more natural - language - like. The more natural the overall language, the more accurately it will be mapped.
[0215] 2) It includes information about the table itself, table fields, table indicators, and table code values. When there are too many code values and indicators to enumerate, the code values and indicator information with high usage frequencies can be listed first according to the usage frequency. Through the above description, the table structure and table information can be represented from multiple perspectives of the table itself, fields, code values, and indicators. The representation ability is stronger, more comprehensive, and more targeted.
[0216] Convert the above information into vectors through a conventional semantic Embedding model and store them in four vector databases respectively. The advantage of the vector database is that it can quickly find several vectors in the database that are most similar to the target vector relying on the index.
[0217] Conventional semantic Embedding models usually have a Token Limit, that is, there is a certain limit on the maximum input length. For example, the maximum Token Limit of the BGE-M3 model is 8196, which means it supports input texts with a maximum length of 8192. The BGE-M3 model is a general semantic vector model that accepts a text segment as input and outputs a 1*1024 semantic vector.
[0218] Use a conventional semantic Embedding model (such as BGE-M3) to vectorize the table itself, fields, code values, and metric information of each table respectively, and obtain the vector of the table itself information as VT self and the vector of the field information in the table is VT col and the vector of the code value information in the table is VT code and the vector of the metric information in the table is VT index That is, the above four feature vectors are used to characterize the table structure and table information.
[0219] With the relationship between the feature vectors of the previous four dimensions and the table, four table information vector databases can be further constructed in advance to facilitate the subsequent preliminary screening of tables using the vector database, that is, first screen out a small number of initial tables from a large number of data tables, thereby improving the subsequent search efficiency.
[0220] Since the user-enhanced question is in text format, the above Embedding model can also be used to vectorize the enhanced intention (QueryA) first to obtain the question vector VectorQ, and then use algorithms such as cosine similarity to find the N vectors most similar to the question vector VectorQ from the four vector databases respectively, and thus obtain the N most similar tables from the four dimensions as the initial table retrieval results.
[0221] In some embodiments of the present application, after retrieving in the table information vector databases of multiple dimensions according to the enhanced question and obtaining the initial table retrieval results of multiple dimensions, the table lookup method further includes: performing a fusion process on the initial table retrieval results of multiple dimensions to obtain a fused initial table retrieval result; the obtaining of the multiple-dimensional feature vectors of each initial table includes: obtaining the multiple-dimensional feature vectors of each initial table in the fused initial table retrieval result.
[0222] Continue to refer to Figure 2, in the foregoing embodiments, the enhanced questions are retrieved and matched in the vector databases of each dimension respectively, and multiple initial tables matched in each dimension will be obtained. There may be overlapping situations among the initial tables of these multiple dimensions. Therefore, in the embodiments of the present application, the intersection of the initial tables of multiple dimensions can be taken to obtain the deduplicated initial tables, and the target table can be further searched in the deduplicated initial tables, which can avoid repeated processing and improve the table search efficiency.
[0223] In some embodiments of the present application, the obtaining of the feature vectors of multiple dimensions of each initial table includes: retrieving each initial table in the table feature vector database respectively to obtain the feature vectors of multiple dimensions of each initial table; wherein, the table feature vector database is used to store the feature vectors of multiple dimensions of each table.
[0224] Continue to refer to Figure 2 , based on the feature vectors of the table information of multiple dimensions generated in the foregoing embodiments, a table feature vector database can also be constructed in the dimension of the table. The structure of the table feature vector database can be represented in the form of Table 3 below, for example:
[0225] Table 3
[0226] Table Name Table Itself Feature Vector Table Field Feature Vector Table Index Feature Vector Table Code Value Feature Vector
[0227] As shown in Table 3 above, the table feature vector database stores the feature vector data of each table in each dimension, and establishes a mapping relationship between the table and the feature vectors of multiple dimensions. An index can be constructed in the table name column, so that during the retrieval process, the corresponding feature vectors of multiple dimensions can be quickly retrieved through the table name.
[0228] In the embodiments of the present application, through a separately constructed table feature vector database, the feature vector data of all dimensions of each table is aggregated. Subsequently, the retrieval only needs to be performed in this one table feature vector database, instead of separately obtaining the corresponding feature vectors from the four vector databases, which greatly improves the retrieval efficiency.
[0229] In some embodiments of the present application, the determining of the target table corresponding to the original question according to the enhanced question and the feature vectors of multiple dimensions of each initial table includes: performing vectorization processing on the enhanced question to obtain an enhanced question vector; calculating the similarity between the feature vectors of multiple dimensions of each initial table and the enhanced question vector respectively to obtain the similarity scores of multiple dimensions of each initial table; determining the target table corresponding to the original question according to the similarity scores of multiple dimensions of each initial table.
[0230] Continue to refer to Figure 2, after obtaining the feature vectors of multiple dimensions of each initial table, the similarity degree between the enhanced problem vector and the feature vectors of each dimension of each initial table can be calculated respectively. For example, it can also be achieved by calculating the cosine similarity score. Finally, combining the similarity score sizes of each initial table in multiple dimensions, the final target table can be determined from the initial tables.
[0231] For example, the cosine similarity between the enhanced problem vector VectorQ and the vector VT of the table's own information, the vector VT of the field information in the table, the vector VT of the code value information in the table, and the vector VT of the index information in the table can be calculated respectively to obtain the corresponding similarity scores: Score self , Score col , Score code , and Score index respectively. self , Score col , Score code , Score index .
[0232] In some embodiments of the present application, determining the target table corresponding to the original problem according to the similarity scores of multiple dimensions of each initial table includes: calculating the comprehensive similarity score of each initial table according to the similarity scores of multiple dimensions of each initial table; determining the target table corresponding to the original problem according to the comprehensive similarity score of each initial table.
[0233] Continuing to refer to Figure 2 , with the four key similarity scores, the four scores can be weighted and combined into an overall score Score total to measure the relevance between the problem and the table. For example, it can be expressed in the following form:
[0234] Score total = a * Score self + b * Score col + c * Score code + d * Score index
[0235] where a, b, c, and d are the weights corresponding to the similarity scores of the table's own information, table sub - fields, table code values, and table indicators respectively.
[0236] Based on this, the correlation scores between the user's problem and all initial tables can be calculated. Finally, the initial table with a larger correlation score can be taken as the finally found target table to participate in the subsequent link of the large - language model generating SQL statements.
[0237] The above focus is on obtaining the similarity scores between the problem vector and the feature vectors in multiple dimensions. As for the weighting method for the similarity scores in multiple dimensions, it is relatively flexible and simple, and the weights can be set by business experts. With the development of machine learning and artificial intelligence, the task of finding the optimal weights can also be handed over to the model to complete. For example, a conventional classification model can be trained, taking the above similarity scores in multiple dimensions as four features and inputting them into the model, and using whether the problem is related to the table as the classification label. Furthermore, the problem of finding the optimal weights can be transformed into the problem of training a binary classifier.
[0238] An embodiment of this application also provides a table lookup device 300, as Figure 3 shown, which provides a structural schematic diagram of a table lookup device in an embodiment of this application. The table lookup device 300 includes: a first acquisition unit 310, an enhancement processing unit 320, an enhancement processing unit 320, a retrieval unit 330, a second acquisition unit 340, and a determination unit 350, where:
[0239] The first acquisition unit 310 is configured to acquire the user's original problem;
[0240] The enhancement processing unit 320 is configured to perform enhancement processing on the original problem by using a preset prompt engineering template and a large language model to obtain an enhanced problem;
[0241] The retrieval unit 330 is configured to perform retrieval in the table information vector databases in multiple dimensions respectively according to the enhanced problem to obtain initial table retrieval results in multiple dimensions, and each initial table retrieval result in each dimension includes at least one initial table;
[0242] The second acquisition unit 340 is configured to acquire the feature vectors in multiple dimensions of each initial table;
[0243] The determination unit 350 is configured to determine the target table corresponding to the original problem according to the enhanced problem and the feature vectors in multiple dimensions of each initial table.
[0244] In some embodiments of this application, the enhancement processing unit 320 is specifically configured to: perform slot recognition on the original problem by using a preset prompt engineering template and a large language model to obtain the key entity information corresponding to the original problem; generate the enhanced problem according to the original problem and the corresponding key entity information.
[0245] In some embodiments of the present application, the vector databases of table information in multiple dimensions include the vector database of table self-information, the vector database of table field information, the vector database of table index information, and the vector database of table code value information. The retrieval unit 330 is specifically configured to: perform vectorization processing on the enhanced question to obtain an enhanced question vector; retrieve in the vector database of table self-information according to the enhanced question vector to obtain a first initial table retrieval result; retrieve in the vector database of table field information according to the enhanced question vector to obtain a second initial table retrieval result; retrieve in the vector database of table index information according to the enhanced question vector to obtain a third initial table retrieval result; retrieve in the vector database of table code value information according to the enhanced question vector to obtain a fourth initial table retrieval result.
[0246] In some embodiments of the present application, the table lookup device 300 further includes: a fusion unit, configured to perform fusion processing on the initial table retrieval results in multiple dimensions after retrieving in the vector databases of table information in multiple dimensions respectively according to the enhanced question to obtain a fused initial table retrieval result; the second obtaining unit is specifically configured to: obtain the feature vectors in multiple dimensions of each initial table in the fused initial table retrieval result.
[0247] In some embodiments of the present application, the second obtaining unit 340 is specifically configured to: retrieve in the table feature vector database for each initial table respectively to obtain the feature vectors in multiple dimensions of each initial table; wherein, the table feature vector database is used to store the feature vectors in multiple dimensions of each table.
[0248] In some embodiments of the present application, the determining unit 350 is specifically configured to: perform vectorization processing on the enhanced question to obtain an enhanced question vector; calculate the similarity scores in multiple dimensions between the feature vectors in multiple dimensions of each initial table and the enhanced question vector respectively to obtain the similarity scores in multiple dimensions of each initial table; determine the target table corresponding to the original question according to the similarity scores in multiple dimensions of each initial table.
[0249] In some embodiments of the present application, the determining unit 350 is specifically configured to: calculate the comprehensive similarity score of each initial table according to the similarity scores in multiple dimensions of each initial table; determine the target table corresponding to the original question according to the comprehensive similarity score of each initial table.
[0250] It can be understood that the above table lookup device can implement each step of the table lookup method provided in the foregoing embodiments. The relevant explanations regarding the table lookup method are applicable to the table lookup device and will not be elaborated herein.
[0251] Figure 4 is a schematic structural diagram of a device in an embodiment of the present application. As Figure 4 shown, the device includes one or more processors (or processing units), and may further include one or more memories coupled to the processors, and may further include a communication module coupled to the processors.
[0252] The communication module can be used to communicate with other devices or apparatuses, such as sending or receiving data and / or signals. The communication module may have at least one communication module for communication. The communication module may include any interface necessary for communicating with other devices. Exemplarily, the communication module may be a transceiver, a circuit, a bus, a module, or other types of communication modules.
[0253] The processor may include, but is not limited to, at least one of the following: a general-purpose computer, a special-purpose computer, a microcontroller, a digital signal controller (Digital Signal Processor, DSP), or one or more in a multi-core controller architecture based on a controller. The device may have multiple processors, such as an application-specific integrated circuit chip, which is subordinate to a clock synchronized with the main processor in time.
[0254] The memory may include one or more non-volatile memories and one or more volatile memories. Examples of non-volatile memories include, but are not limited to, at least one of the following: read-only memory (Read-Only-Memory, ROM), erasable programmable read-only memory (Electrically Programmable Read-Only-Memory, EPROM), flash memory, hard disk, compact disc (Compact Disc, CD), digital video disc (Digital Video Disk, DVD), or other magnetic storage and / or optical storage. Examples of volatile memories include, but are not limited to, at least one of the following: random access memory (Random Access Memory, RAM), or other volatile memories that do not persist during a power outage duration.
[0255] The computer program includes computer-executable instructions executed by an associated processor. The program may be stored in the ROM. The processor may perform any appropriate actions and processes by loading the program into the RAM.
[0256] The possible implementation manners of the present application can be realized by means of the program, such that the communication device can execute any process discussed in the foregoing embodiments. The possible implementation manners of the present application can also be realized by hardware or by a combination of software and hardware.
[0257] In some embodiments, the program may be tangibly embodied in a computer-readable storage medium, which may be included in the device (such as in the memory) or other storage devices accessible by the device. The program can be loaded from the computer-readable storage medium into the RAM for execution. The computer-readable storage medium may include any type of tangible non-volatile memory, such as ROM, EPROM, flash memory, hard disk, CD, DVD, etc.
[0258] The embodiments of the present application also provide a computer-readable storage medium, on which computer instructions or program codes are stored. When the processor runs the instructions or the program codes, the processor is caused to execute the methods and functions involved in any of the above embodiments. The computer-readable medium may be any tangible medium that contains or stores a program for or relating to an instruction execution system, apparatus, or device. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. The computer-readable storage medium may be any available medium accessible by a computer or a data storage device such as a server, a data center, etc. that incorporates one or more available media. More detailed examples of the computer-readable storage medium include electrical connections with one or more wires, magnetic media (such as disks, floppy disks, hard disks, magnetic tapes, magnetic storage devices), optical media (such as optical storage devices, DVDs), semiconductor media (such as solid state drives), random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), or any suitable combination thereof, etc.
[0259] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. Embodiments of the present application also provide at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes one or more computer-executable instructions, such as instructions included in program modules, which are executed in a device on a target real or virtual processor to perform the processes, methods, and functions involved in any one of the above embodiments. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line) or wirelessly (such as infrared, wireless, microwave, etc.).
[0260] Embodiments of the present application also propose a computer program product, including a computer program or instructions. When the computer program or instructions run on a computer, the computer is caused to perform the processes, methods, and functions in the above embodiments. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functions of program modules can be combined or divided as needed among program modules. Machine-executable instructions for program modules can be executed within local or distributed devices. In a distributed device, program modules can be located in local and remote storage media.
[0261] Generally, various embodiments of the present application can be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects can be implemented in hardware, while other aspects can be implemented in firmware or software, which can be executed by a controller, microprocessor, or other computing device. Although aspects of the embodiments of the present disclosure are shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that the blocks, devices, systems, techniques, or methods described herein can be implemented as, by way of non-limiting example, hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0262] It should be noted that although the embodiments of the present application have been described above in conjunction with the accompanying drawings respectively, the above embodiments are not independent of each other, and they can also be combined to obtain other embodiments. The manners, situations, categories, and the division of embodiments in the embodiments of the present application are only for the convenience of description and should not constitute a special limitation. The features in various manners, categories, situations, and embodiments can be combined with each other under logical circumstances. The various embodiments of the present application can be combined arbitrarily to achieve different technical effects. The embodiments of the present application will no longer list various combinations.
[0263] In addition, although the operations of the method of the present disclosure are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart may be changed in the order of execution. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution. It should also be noted that the features and functions of two or more devices according to the present disclosure may be embodied in one device. Conversely, the features and functions of one device described above may be further divided and embodied by multiple devices.
[0264] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, commodity or device comprising the said element.
[0265] The above are only the embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A table search method, characterized in that: The table search method includes: Get the user's original question; The original question is enhanced by using a preset prompt engineering template and a large language model to obtain an enhanced question; According to the enhanced question, searching is performed in table information vector databases of multiple dimensions respectively to obtain initial table search results of multiple dimensions, wherein the initial table search results of each dimension include at least one initial table; Obtain feature vectors of multiple dimensions for each initial table; The target table corresponding to the original question is determined according to the enhanced question and the feature vectors of multiple dimensions of each initial table.
2. The table search method according to claim 1, characterized in that: The original question is enhanced by using the preset prompt engineering template and the large language model, and the enhanced question includes: Using a preset prompt engineering template and a large language model to perform slot identification on the original question, and obtain key entity information corresponding to the original question; The enhanced question is generated according to the original question and the corresponding key entity information.
3. The table search method according to claim 1, characterized in that: The table information vector databases of multiple dimensions include a vector database of table information, a vector database of table field information, a vector database of table index information, and a vector database of table code value information. According to the enhanced question, the table information vector databases of multiple dimensions are searched respectively, and the initial table search results of multiple dimensions are obtained, including: Performing vectorization processing on the enhanced problem to obtain an enhanced problem vector; According to the enhanced question vector, a search is performed in a vector database of the table's own information to obtain a first initial table search result; According to the enhanced question vector, a search is performed in the vector database of the table field information to obtain a second initial table search result; According to the enhanced question vector, a search is performed in the vector database of the table indicator information to obtain a third initial table search result; According to the enhanced question vector, a search is performed in the vector database of the table code value information to obtain a fourth initial table search result.
4. The table search method according to claim 1, characterized in that: After searching in the table information vector databases of multiple dimensions respectively according to the enhanced question to obtain initial table search results of multiple dimensions, the table search method further includes: The initial table search results of multiple dimensions are fused to obtain fused initial table search results; The step of obtaining feature vectors of multiple dimensions of each initial table includes: Obtain feature vectors of multiple dimensions of each initial table in the fused initial table retrieval result.
5. The table search method according to claim 1, characterized in that: The step of obtaining feature vectors of multiple dimensions of each initial table includes: Search each initial table in the table feature vector database to obtain feature vectors of multiple dimensions of each initial table; The table feature vector database is used to store feature vectors of multiple dimensions of each table.
6. The table search method according to claim 1, characterized in that: Determining the target table corresponding to the original question according to the enhanced question and the feature vectors of multiple dimensions of each initial table includes: Performing vectorization processing on the enhanced problem to obtain an enhanced problem vector; Calculating similarity between the feature vectors of multiple dimensions of each initial table and the enhanced question vector respectively, to obtain similarity scores of the multiple dimensions of each initial table; The target table corresponding to the original question is determined according to the similarity scores of multiple dimensions of each initial table.
7. The table search method according to claim 6, characterized in that: Determining the target table corresponding to the original question according to the similarity scores of multiple dimensions of each initial table includes: Calculate a comprehensive similarity score of each initial table according to the similarity scores of multiple dimensions of each initial table; The target table corresponding to the original question is determined according to the comprehensive similarity score of each initial table.
8. A table search device, characterized in that: The table search device comprises: A first acquisition unit, used to acquire the original question of the user; An enhancement processing unit, used to enhance the original question by using a preset prompt engineering template and a large language model to obtain an enhanced question; A retrieval unit, configured to search in the table information vector databases of multiple dimensions respectively according to the enhanced question, to obtain initial table retrieval results of multiple dimensions, wherein the initial table retrieval results of each dimension include at least one initial table; A second acquisition unit is used to acquire feature vectors of multiple dimensions of each initial table; A determination unit is used to determine a target table corresponding to the original question according to the enhanced question and the feature vectors of multiple dimensions of each initial table.
9. A device comprising: processor; and a memory arranged to store computer executable instructions, which, when executed, cause the processor to perform the table search method of any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the table search method according to any one of claims 1 to 7 is implemented.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the table search method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
SQL generation method based on large language model and storage medium
CN120950527A