EP4473420A1 - In-context text-to-sql with reduced labeled data - Google Patents
In-context text-to-sql with reduced labeled dataInfo
- Publication number
- EP4473420A1 EP4473420A1 EP23813911.7A EP23813911A EP4473420A1 EP 4473420 A1 EP4473420 A1 EP 4473420A1 EP 23813911 A EP23813911 A EP 23813911A EP 4473420 A1 EP4473420 A1 EP 4473420A1
- Authority
- EP
- European Patent Office
- Prior art keywords
- database
- language query
- query
- natural language
- potential
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2423—Interactive query statement specification based on a database schema
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/243—Natural language query formulation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
- G06N3/0455—Auto-encoder networks; Encoder-decoder networks
Definitions
- Text-to-standard query language aims to automate the process of generating SQL queries on a database from natural language text.
- Text-to-SQL can enable natural language interfaces for SQL query generation in order to enhance database accessibility without requiring expertise in SQL as well as enable development of conversational agents with advanced data analytics.
- text-to-SQL is typically trained on large amounts of data, e.g., thousands of samples, requiring significant processing power and consumption of memory.
- aspects of the disclosure are directed to automatically generating SQL queries or other database language queries from natural language text using in-context learning to leverage zeroshot and few-shot adaptation capabilities of large language models (LLMs).
- the queries can be automatically generated by considering database information, employing execution based consistency decoding, and employing a mixture of prompts and/or LLMs.
- aspects of the disclosure can outperform in-context learning without labeled data by a large margin and can close the gap with fine tuning learning with thousands of labeled data.
- aspects of the disclosure allow for automatically generating queries with significantly less processing power and memory consumption.
- An aspect of the disclosure provides for a method for processing queries, the method including: receiving, by one or more processors, a natural language query; converting, by the one or more processors, the natural language query into a database language query using database information; and executing, by the one or more processors, the database language query to generate a result for the natural language query.
- the database information includes database schema, database content, primary keys that uniquely identify rows of each table of the database schema, and foreign keys that join one or more tables of the data schema.
- converting the natural language query into a database language query includes: generating various database description prompts; sampling one or more large language models (LLMs) multiple times with the various database description prompts to generate a plurality of potential database language queries; executing the plurality of potential database language queries to generate a plurality of potential results; and selecting the database language query that provides a result consistent with a threshold amount of the plurality of potential results.
- the various database description prompts include a concise prompt and a verbose prompt.
- converting the natural language query into a database language query includes removing errors from the plurality of potential results. In yet another example, converting the natural language query into a database language query includes concatenating the plurality of potential results. In yet another example, the threshold amount includes a majority of the plurality of potential results.
- the database language query includes at least one of standard query language (SQL) or graph query language (GraphQL).
- SQL standard query language
- GraphQL graph query language
- Another aspect of the disclosure provides for a system including: one or more processors; and one or more storage devices coupled to the one or more processors and storing instructions that, when executed by the one or more processors, cause the one or more processors to perform operations for processing queries, the operations including: receiving a natural language query; converting the natural language query into a database language query using database information; and executing the database language query to generate a result for the natural language query.
- the database information includes database schema, database content, primary keys that uniquely identify rows of each table of the database schema, and foreign keys that join one or more tables of the data schema.
- converting the natural language query into a database language query includes: generating various database description prompts; sampling one or more large language models (LLMs) multiple times with the various database description prompts to generate a plurality of potential database language queries; executing the plurality of potential database language queries to generate a plurality of potential results; and selecting the database language query that provides a result consistent with a threshold amount of the plurality of potential results.
- the various database description prompts include a concise prompt and a verbose prompt.
- converting the natural language query into a database language query includes removing errors from the plurality of potential results.
- converting the natural language query into a database language query includes concatenating the plurality of potential results.
- the threshold amount includes a majority of the plurality of potential results.
- the database language query includes at least one of standard query language (SQL) or graph query language (GraphQL).
- Yet another aspect of the disclosure provides for a non-transitory computer readable medium for storing instructions that, when executed by one or more processors, cause the one or more processors to perform operations for processing queries, the operations including: receiving a natural language query; converting the natural language query into a database language query using database information; and executing the database language query to generate a result for the natural language query.
- converting the natural language query into a database language query includes: generating various database description prompts; sampling one or more large language models (LLMs) multiple times with the various database description prompts to generate a plurality of potential database language queries; executing the plurality of potential database language queries to generate a plurality of potential results; and selecting the database language query that provides a result consistent with a threshold amount of the plurality of potential results.
- converting the natural language query into a database language query includes removing errors from the plurality of potential results.
- converting the natural language query into a database language query includes concatenating the plurality of potential results.
- FIG. 1 depicts a block diagram of an example query conversion system for converting natural language queries into database language queries according to aspects of the disclosure.
- FIG. 2 depicts a block diagram of example database description prompts according to aspects of the disclosure.
- FIG. 3 depicts a block diagram of an example query conversion sub-system for generating potential SQLs according to aspects of the disclosure.
- FIG. 4 depicts a block diagram of an example query conversion sub-system for selecting an SQL according to aspects of the disclosure.
- FIG. 5 depicts a block diagram of an example environment for implementing a query conversion system according to aspects of the disclosure.
- FIG. 6 depicts a block diagram illustrating one or more large language model architectures according to aspects of the disclosure.
- FIG. 7 depicts a flow diagram of an example process for processing queries according to aspects of the disclosure.
- FIG. 8 depicts a flow diagram of an example process for converting a natural language query into a database language query according to aspects of the disclosure.
- aspects of the disclosure are directed to methods, systems, and non-transitory computer readable media for automatically generating queries on a database from natural language text using in-context learning to leverage zero-shot and few-shot adaptation capabilities of large language models (LLMs).
- LLMs large language models
- the methods, systems, and non-transitory computer readable media can consider database information, employ execution-based consistency decoding, and employ a mixture of prompts and/or LLMs.
- the technology generally relates to systems, methods, and non-transitory computer readable media for processing natural language queries, which can include prompt design with database content, execution-based consistency decoding, and a mixture of prompts and LLMs.
- the systems, methods, and non-transitory computer readable media can process queries by receiving a natural language query, converting the natural language query into SQL or other database language query using database information, and executing the SQL to generate a result for the natural language query.
- the database information can include database schema, database content, primary keys, and foreign keys.
- the database schema can include multiple tables, where each table contain a table name, column name, and column data type.
- the primary keys can uniquely identify rows of each table of the database schema and the foreign keys can join one or more tables of the multiple tables.
- the systems, method, and non-transitory computer readable media can convert the natural language query into SQL by generating various database description prompts.
- Various database description prompts are, for example, a plurality of different database description prompts.
- the various database description prompts can include concise prompts that linearizes information to describe table structure and verbose prompts that describe the database information with natural language, emphasizing need to know information for the LLMs.
- the systems, methods, and non-transitory computer readable media can sample one or more LLMs multiple times with the various database description prompts to generate a plurality of potential SQLs.
- the systems, methods, and non-transitory computer readable media can execute the plurality of potential SQLs using an execution engine to generate a plurality of potential results. After removing errors from the plurality of potential results, the systems, methods, and non-transitory computer readable media can concatenate the plurality of potential results and select the SQL that provides a result consistent with a threshold amount of the plurality of potential results.
- the threshold amount can be a majority of the plurality of potential results.
- a model such as an LLM, can select the SQL.
- the systems, methods, and non-transitory computer readable media can input the plurality of potential SQLs and plurality of potential results into a prompt for an LLM, where the LLM can select the SQL.
- FIG. 1 depicts a block diagram of an example query conversion system 100 for converting natural language queries into database language queries.
- Database language queries can include standard query language (SQL) or graphical query language (GraphQL), as examples.
- the query conversion system 100 can be implemented on one or more computing devices in one or more locations.
- the query conversion system 100 can be configured to receive inference data 102 and/or training data 104 for use in converting natural language queries into database language queries.
- the query conversion system 100 can receive the inference data 102 and/or training data 104 as part of a call to an application programming interface (API) exposing the query conversion system 100 to one or more computing devices.
- API application programming interface
- the inference data 102 and/or training data 104 can also be provided to the query conversion system 100 through a storage medium, such as remote storage connected to the one or more computing devices over a network.
- the inference data 102 and/or training data 104 can further be provided as input through a user interface on a client computing device coupled to the query conversion system 100.
- the inference data 102 can include data associated with converting a natural language query into a database language query.
- the data associated with converting a natural language query into a database language query can include the natural language query and database information.
- Database information can include database schema, primary keys, and/or foreign keys.
- Database schema can include multiple tables, each with a table name, column name, and column data type. Primary keys can uniquely identify rows of each table and foreign keys can join multiple tables.
- the training data 104 can correspond to a machine learning task for converting natural language queries to database language queries, such as a task performed by a large language model (LLM).
- LLM large language model
- the training data can be split into a training set, a validation set, and/or a testing set.
- An example training/validation/testing split can be an 80/10/10 split, although any other split may be possible.
- the training data 104 can include examples for converting natural language queries into database language queries.
- the training data 104 can be in any form suitable for training a model, according to one of a variety of different learning techniques.
- Learning techniques for training a model can include supervised learning, unsupervised learning, semi-supervised learning techniques, parameterefficient techniques and reinforcement learning techniques.
- Training the model can further include priming the model using zero- or few-shot prompting to output higher-quality responses.
- the training data 104 can include multiple training examples that can be received as input by a model.
- the training examples can be labeled with a desired output for the model when processing the labeled training examples.
- the label and the model output can be evaluated through a loss function to determine an error, which can be back propagated through the model to update weights for the model.
- a supervised learning technique can be applied to calculate an error between outputs, with a ground-truth label of a training example processed by the model.
- Any of a variety of loss or error functions appropriate for the type of the task the model is being trained for can be utilized, such as cross-entropy loss for classification tasks, or mean square error for regression tasks.
- the gradient of the error with respect to the different weights of the candidate model on candidate hardware can be calculated, for example using a backpropagation algorithm, and the weights for the model can be updated.
- the model can be trained until stopping criteria are met, such as a number of iterations for training, a maximum period of time, a convergence, or when a minimum accuracy threshold is met.
- the query conversion system 100 can be configured to output one or more results related to converting natural language queries into database language queries, generated as output data 106.
- the output data 106 can include a database language query converted from a natural language query and/or instructions associated with the database language query.
- the query conversion system 100 can be configured to send the output data 106 for display on a client or user display.
- the query conversion system 100 can be configured to provide the output data 106 as a set of computer-readable instructions, such as one or more computer programs.
- the computer programs can be written in any type of programming language, and according to any programming paradigm, e.g., declarative, procedural, assembly, object-oriented, data-oriented, functional, or imperative.
- the computer programs can be written to perform one or more different functions and to operate within a computing environment, e.g., on a physical device, virtual machine, or across multiple devices.
- the computer programs can also implement functionality described herein, for example, as performed by a system, engine, module, or model.
- the query conversion system 100 can further be configured to forward the output data 106 to one or more other devices configured for translating the output data into an executable program written in a computer programming language.
- the query conversion system 100 can also be configured to send the output data 106 to a storage device for storage and later retrieval.
- the query conversion system 100 can include a prompt generation engine 108, a database language query generation engine 110, an execution engine 112, and a selection engine 114.
- the prompt generation engine 108, database language query generation engine 110, execution engine 112, and/or selection engine 114 can be implemented as one or more computer programs, specially configured electronic circuitry, or any combination thereof.
- the prompt generation engine 108 can be configured to generate various database description prompts based on the database information.
- the database description prompts can include database schema as well as primary keys, foreign keys, and/or database content. The primary keys, foreign keys, and/or database content allow the prompt generation engine 108 to understand the database schema, such as by linking tables and selecting appropriate columns.
- the database description prompts can include one or more concise prompts and one or more verbose prompts. Concise database description prompts can linearize information in a table, such as “Tablel name: column name 1, column name 2 (relevant database content)
- example database description prompts 200 depicts a block diagram of example database description prompts 200, including a concise prompt 202 for the query “How many French singers?”.
- Verbose database description prompts can describe the database information with natural language while emphasizing higher priority information, such as “Table CarNames contains three columns. The column names and their types are: MakelD (number), Model (string), . . . Foreign keys are . . . use foreign keys to join Tables”.
- the example database description prompts 200 of FIG. 2 include a verbose prompt 204 for the query “How many French singers?”.
- the database language query generation engine 110 can be configured to sample one or more LLMs multiple times with the various database description prompts to generate corresponding potential database query languages.
- the database language query generation engine 110 can query the LLMs multiple times to generate the potential database query languages.
- the database language query generation engine 110 can query the LLMs multiple times with the same database description prompt and with differing database description prompts.
- the execution engine 112 can be configured to execute the potential database query languages to generate corresponding potential results.
- the execution engine 112 can be further configured to remove errors from the corresponding results.
- the execution engine 112 can also be configured to concatenate the corresponding results.
- the selection engine 114 can be configured to select a database query language of the potential database query languages that provides a corresponding result consistent with a threshold amount of the corresponding results.
- the threshold amount can be a majority of the corresponding results.
- the selection engine 114 can further be configured to select a database query language using a machine learning model, such as an LLM.
- the selection engine 114 can input the potential database query languages and corresponding results into a prompt for an LLM and the LLM can select the database query language.
- FIG. 3 depicts a block diagram of an example query conversion sub-system 300 for generating potential SQLs for the natural language query “How many French singers?”.
- the example sub-system 300 can correspond to the prompt generation engine 108 and database language query generation engine 110 as depicted in FIG. 1.
- a concise prompt 302 and a verbose prompt 304 are generated from the natural language query and database information 306.
- the database information 306 includes a table of singers and information about the singers, including name, country, and age.
- the concise prompt 302 and the verbose prompt 304 can respectively correspond to the concise prompt 202 and verbose prompt 204 as depicted in FIG. 2.
- the concise prompt 302 and verbose prompt 304 are input to an LLM 308 multiple times, which generates a plurality of potential SQLs 310.
- FIG. 4 depicts a block diagram of an example query conversion sub-system 400 for selecting an SQL for converting the natural language query “How many French singers?”.
- the example sub-system 400 can correspond to the execution engine 112 and selection engine 114 as depicted in FIG. 1.
- a LLM 402 can generate a plurality of potential SQLs 404.
- the LLM 402 and the plurality of potential SQLs 404 can respectively correspond to the LLM 308 and the plurality of potential SQLs 310 as depicted in FIG. 3.
- the plurality of potential SQLs 404 can include generated SQLs from a concise prompt and generated SQLs from a verbose prompt.
- each prompt generated two potential SQLs based on inputting each prompt into the LLM 402 twice, though any number of potential SQLs can be generated by inputting each prompt into the LLM 402 any number of times.
- the potential SQLs 404 can be executed to generate outcomes or results 406.
- the first generated SQL from the concise prompt resulted in a value of 2
- the second generated SQL from the concise prompt resulted in a value of 1
- the first generated SQL from the verbose prompt resulted in a value of N/A
- the second generated SQL from the verbose prompt resulted in a value of 2.
- the outcomes or results 406 can be filtered to remove errors to generate filtered outcomes or results 408.
- the value of N/A and the corresponding generated SQL is removed as an invalid output.
- An SQL can be selected that provides consistency 410 based on the filtered outcomes or results 408.
- the selected SQL 412 can be the second generated SQL from the concise prompt or the second generated SQL from the verbose prompt.
- the generated SQL is the same, though in other examples, the generated SQL may differ but result in the same outcome.
- FIG. 5 depicts a block diagram of an example environment 500 for implementing a query conversion system 518.
- the query conversion system 518 can be implemented on one or more devices having one or more processors in one or more locations, such as in server computing device 502.
- Client computing device 504 and the server computing device 502 can be communicatively coupled to one or more storage devices 506 over a network 508.
- the storage devices 506 can be a combination of volatile and non-volatile memory and can be at the same or different physical locations than the computing devices 502, 504.
- the storage devices 506 can include any type of non-transitory computer readable medium capable of storing information, such as a hard-drive, solid state drive, tape drive, optical storage, memory card, ROM, RAM, DVD, CD-ROM, write-capable, and read-only memories.
- the server computing device 502 can include one or more processors 510 and memory 512.
- the memory 512 can store information accessible by the processors 510, including instructions 514 that can be executed by the processors 510.
- the memory 512 can also include data 516 that can be retrieved, manipulated, or stored by the processors 510.
- the memory 512 can be a type of transitory or non-transitory computer readable medium capable of storing information accessible by the processors 510, such as volatile and non-volatile memory.
- the processors 510 can include one or more central processing units (CPUs), graphic processing units (GPUs), field- programmable gate arrays (FPGAs), and/or application-specific integrated circuits (ASICs), such as tensor processing units (TPUs).
- CPUs central processing units
- GPUs graphic processing units
- FPGAs field- programmable gate arrays
- ASICs application-specific integrated circuits
- TPUs tensor processing units
- the instructions 514 can include one or more instructions that, when executed by the processors 510, cause the one or more processors 510 to perform actions defined by the instructions 514.
- the instructions 514 can be stored in object code format for direct processing by the processors 510, or in other formats including interpretable scripts or collections of independent source code modules that are interpreted on demand or compiled in advance.
- the instructions 514 can include instructions for implementing a query conversion system 518, which can correspond to the query conversion system 100 of FIG. 1.
- the query conversion system 518 can be executed using the processors 510, and/or using other processors remotely located from the server computing device 502.
- the data 516 can be retrieved, stored, or modified by the processors 510 in accordance with the instructions 514.
- the data 516 can be stored in computer registers, in a relational or nonrelational database as a table having a plurality of different fields and records, or as JSON, YAML, proto, or XML documents.
- the data 516 can also be formatted in a computer-readable format such as, but not limited to, binary values, ASCII, or Unicode.
- the data 516 can include information sufficient to identify relevant information, such as numbers, descriptive text, proprietary codes, pointers, references to data stored in other memories, including other network locations, or information that is used by a function to calculate relevant data.
- the client computing device 504 can also be configured similarly to the server computing device 502, with one or more processors 520, memory 522, instructions 524, and data 526.
- the client computing device 504 can also include a user input 528 and a user output 530.
- the user input 528 can include any appropriate mechanism or technique for receiving input from a user, such as keyboard, mouse, mechanical actuators, soft actuators, touchscreens, microphones, and sensors.
- the server computing device 502 can be configured to transmit data to the client computing device 504, and the client computing device 504 can be configured to display at least a portion of the received data on a display implemented as part of the user output 530.
- the user output 530 can also be used for displaying an interface between the client computing device 504 and the server computing device 502.
- the user output 530 can alternatively or additionally include one or more speakers, transducers or other audio outputs, a haptic interface or other tactile feedback that provides non- visual and non-audible information to the platform user of the client computing device 504.
- FIG. 5 illustrates the processors 510, 520 and the memories 512, 522 as being within the respective computing devices 502, 504, components described herein can include multiple processors and memories that can operate in different physical locations and not within the same computing device.
- some of the instructions 514, 524 and the data 516, 526 can be stored on a removable SD card and others within a read-only computer chip.
- Some or all of the instructions 514, 524 and data 516, 526 can be stored in a location physically remote from, yet still accessible by, the processors 510, 520.
- the processors 510, 520 can include a collection of processors that can perform concurrent and/or sequential operation.
- the computing devices 502, 504 can each include one or more internal clocks providing timing information, which can be used for time measurement for operations and programs run by the computing devices 502, 504.
- the server computing device 502 can be connected over the network 508 to a data center 532 housing any number of hardware accelerators 532A-N.
- the data center 532 can be one of multiple data centers or other facilities in which various types of computing devices, such as hardware accelerators, are located.
- Computing resources housed in the data center 532 can be specified for deploying models related to processing natural language queries by converting the natural language query to a database language query, as described herein.
- the server computing device 502 can be configured to receive requests to process data from the client computing device 504 on computing resources in the data center 532.
- the environment 500 can be part of a computing platform configured to provide a variety of services to users, through various user interfaces and/or application programming interfaces (APIs) exposing the platform services.
- the variety of services can include processing queries by converting natural language queries into database language queries.
- the client computing device 504 can transmit input data associated with converting natural language queries into database language queries.
- the query conversion system 518 can receive the input data, and in response, generate output data including a result for a query and/or a database language query.
- the server computing device 502 can maintain a variety of models in accordance with different constraints available at the data center 532.
- the server computing device 502 can maintain different families for deploying models on various types of TPUs and/or GPUs housed in the data center 532 or otherwise available for processing.
- FIG. 6 depicts a block diagram 600 illustrating one or more LLM architectures 602, more specifically 602A-N for each architecture, for deployment in a datacenter 604 housing a hardware accelerator 606 on which the deployed LLMs 602 will execute, such as for providing natural language query processing.
- the hardware accelerator 606 can be any type of processor, such as a CPU, GPU, FPGA, or ASIC such as a TPU.
- An architecture 602 of a LLM can refer to characteristics defining the LLM, such as characteristics of layers for the LLM, how the layers process input, or how the layers interact with one another.
- the architecture 602 of the LLM can also define types of operations performed within each layer.
- One or more LLM architectures 602 can be generated that can output results, such as for natural language query processing.
- Example LLM architectures 602 can correspond to pathway language models, such as PaLM-62B, PaLM-540B, or GPT-3.
- the devices 502, 504 and the data center 532 can be capable of direct and indirect communication over the network 508.
- the client computing device 504 can connect to a service operating in the data center 532 through an Internet protocol.
- the devices 502, 504 can set up listening sockets that may accept an initiating connection for sending and receiving information.
- the network 508 can include various configurations and protocols including the Internet, World Wide Web, intranets, virtual private networks, wide area networks, local networks, and private networks using communication protocols proprietary to one or more companies.
- the network 508 can support a variety of short- and long-range connections.
- the short- and long-range connections may be made over different bandwidths, such as 2.402 GHz to 2.480 GHz, commonly associated with the Bluetooth® standard, 2.4 GHz and 5 GHz, commonly associated with the Wi-Fi® communication protocol; or with a variety of communication standards, such as the LTE® standard for wireless broadband communication.
- the network 508, in addition or alternatively, can also support wired connections between the devices 502, 504 and the data center 532, including over various types of Ethernet connection.
- FIG. 5 Although a single server computing device 502, client computing device 504, and data center 532 are shown in FIG. 5, it is understood that the aspects of the disclosure can be implemented according to a variety of different configurations and quantities of computing devices, including in paradigms for sequential or parallel processing, or over a distributed network of multiple devices. In some implementations, aspects of the disclosure can be performed on a single device connected to hardware accelerators configured for processing optimization models, and any combination thereof.
- FIG. 7 depicts a flow diagram of an example process 700 for processing queries.
- the example process 700 can be performed on a system of one or more processors in one or more locations, such as the query conversion system 100 as depicted in FIG. 1.
- the query conversion system 100 can receive a natural language query.
- the query conversion system 100 can further receive database information, which can include database schema, primary keys, and/or foreign keys.
- database information can include database schema, primary keys, and/or foreign keys.
- q can be the natural language query and D q can be the database information.
- the database D q ⁇ S, K p , K ⁇ can include database schema 5, primary keys K p , and foreign keys Kf.
- the database schema S can contain multiple tables T t S — ⁇ T , T 2 , ... , T t , ... ⁇ .
- Each table T t can include a table name N t , column names and column data types t .
- T k ⁇ N k , (c kl , t kl ), (c k2 , t k2 ), ... , (c k j, t k ), ... ⁇ .
- the primary keys K p can uniquely identify rows of each table T t and the foreign keys K can join multiple tables.
- the query conversion system 100 can convert the natural language query into a database language query using the database information.
- the query conversion system 100 can convert the natural language query q into SQL with the database information D q .
- the query conversion system 100 can generate various database description prompts, sample one or more LLMs multiple times with the various database description prompts to generate a plurality of potential database language queries, execute the plurality of potential database language queries to generate a plurality of potential results, and select the database language query that provides a consistent result.
- FIG. 8 depicts a flow diagram of an example process 800 for converting a natural language query into a database language query.
- the example process 800 can be performed on a system of one or more processors in one or more locations, such as the query conversion system 100 as depicted in FIG. 1.
- the query conversion system 100 can generate various database description prompts.
- the database description prompts can include one or more concise prompts and one or more verbose prompts.
- Concise database description prompts can linearize information in a table, and verbose database description prompts can describe the database information with natural language while emphasizing higher priority information.
- F f 2 , ... ⁇ can be a collection of different design functions, where j is verbose and f 2 is concise.
- the query conversion system 100 can generate prompts using the database information Dq and the query q.
- the query conversion system 100 can sample one or more LLMs multiple times with the various database description prompts to generate a plurality of potential database language queries.
- prediction objectives can be represented as: [0066] p(sqZ
- LLM, q) J ⁇ p(sqZ
- the query conversion system 100 can sample B times from the LLM with the same prompt Promptq to get sql collections:
- the query conversion system 100 can execute the plurality potential database language queries to generate a plurality of potential results.
- the query conversion system 100 can execute the SQL collections using an SQL database engine to yield outputs O as the execution result of SQL on the provided database:
- the query conversion system 100 can remove errors from the plurality of potential results. For example, the query conversion system 100 can exclude outputs Oqf that yield errors such that only the valid outputs remain.
- the query conversion system 100 can repeat blocks 830 and 840 for each prompt design function/.
- the query conversion system 100 can concatenate the plurality of potential results.
- Mq [M ql , ... , Mq f , ... , M nF ] (6)
- the query conversion system 100 can select the database language query that provides a consistent result.
- the query conversion system 100 can select a database language query that provides a result consistent with a threshold amount of the plurality of potential results.
- the threshold amount can be a majority amount, e.g., 50% or more, or a plurality amount, e.g., 40% or more.
- the query conversion system 100 can select the SQL that gives an execution outcome consistent with a majority of execution outcomes O q generated by all M q
- query conversion system 100 can select a database query language using a machine learning model, such as an LLM.
- a machine learning model such as an LLM.
- the query conversion system 100 can input the potential database query languages and corresponding results into a prompt for an LLM and the LLM can select the database query language.
- the query conversion system 100 can utilize a single LLM or multiple LLMs. Multiple LLMs can increase diversity for more refined outputs.
- aspects of this disclosure can outperform in-context learning without labeled data by a large margin and can close the gap with finetuning learning with thousands of labeled data, allowing for automatically generating queries with significantly less processing power and memory consumption.
- aspects of this disclosure outperformed in-context learning without labeled data by about 7% in execution accuracy and by about 8.1% in test suite accuracy.
- aspects of this disclosure performed less than fine-tuned learning by about 6% in execution accuracy and by about 4% in test suite accuracy but utilized significantly less processing power and memory consumption.
- the disclosed method requires significantly less processing power and memory consumption.
- aspects of this disclosure can be implemented in digital electronic circuitry, in tangibly embodied computer software or firmware, and/or in computer hardware, such as the structure disclosed herein, their structural equivalents, or combinations thereof.
- aspects of this disclosure can further be implemented as one or more computer programs, such as one or more modules of computer program instructions encoded on a tangible non-transitory computer storage medium for execution by, or to control the operation of, one or more data processing apparatus.
- the computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
- the computer program instructions can be encoded on an artificially generated propagated signal, such as a machine-generated electrical, optical, or electromagnetic signal, that is generated to encode information for transmission to suitable receiver apparatus for execution by a data processing apparatus.
- the term “data processing apparatus” refers to data processing hardware and encompasses various apparatus, devices, and machines for processing data, including programmable processors, a computer, or combinations thereof.
- the data processing apparatus can include special purpose logic circuitry, such as a field programmable gate array (FPGA) or an application specific integrated circuit (ASIC).
- the data processing apparatus can include code that creates an execution environment for computer programs, such as code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or combinations thereof.
- the data processing apparatus can include special-purpose hardware accelerator units for implementing machine learning models to process common and compute-intensive parts of machine learning training or production, such as inference or workloads.
- Machine learning models can be implemented and deployed using one or more machine learning frameworks, such as a TensorFlow framework, a Microsoft Cognitive Toolkit framework, an Apache Singa framework, or an Apache MXNet framework, or combinations thereof.
- the term “computer program” refers to a program, software, a software application, an app, a module, a software module, a script, or code.
- the computer program can be written in any form of programming language, including compiled, interpreted, declarative, or procedural languages, or combinations thereof.
- the computer program can be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
- the computer program can correspond to a file in a file system and can be stored in a portion of a file that holds other programs or data, such as one or more scripts stored in a markup language document, in a single file dedicated to the program in question, or in multiple coordinated files, such as files that store one or more modules, sub programs, or portions of code.
- the computer program can be executed on one computer or on multiple computers that are located at one site or distributed across multiple sites and interconnected by a data communication network.
- database refers to any collection of data.
- the data can be unstructured or structured in any manner.
- the data can be stored on one or more storage devices in one or more locations.
- an index database can include multiple collections of data, each of which may be organized and accessed differently.
- engine refers to a software-based system, subsystem, or process that is programmed to perform one or more specific functions.
- the engine can be implemented as one or more software modules or components or can be installed on one or more computers in one or more locations.
- a particular engine can have one or more computers dedicated thereto, or multiple engines can be installed and running on the same computer or computers.
- the processes and logic flows described herein can be performed by one or more computers executing one or more computer programs to perform functions by operating on input data and generating output data.
- the processes and logic flows can also be performed by special purpose logic circuitry, or by a combination of special purpose logic circuitry and one or more computers.
- a computer or special purpose logic circuitry executing the one or more computer programs can include a central processing unit, including general or special purpose microprocessors, for performing or executing instructions and one or more memory devices for storing the instructions and data.
- the central processing unit can receive instructions and data from the one or more memory devices, such as read only memory, random access memory, or combinations thereof, and can perform or execute the instructions.
- the computer or special purpose logic circuitry can also include, or be operatively coupled to, one or more storage devices for storing data, such as magnetic, magneto optical disks, or optical disks, for receiving data from or transferring data to.
- the computer or special purpose logic circuitry can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a Global Positioning System (GPS), or a portable storage device, e.g., a universal serial bus (USB) flash drive, as examples.
- Computer readable media suitable for storing the one or more computer programs can include any form of volatile or non-volatile memory, media, or memory devices. Examples include semiconductor memory devices, e.g., EPROM, EEPROM, or flash memory devices, magnetic disks, e.g., internal hard disks or removable disks, magneto optical disks, CD-ROM disks, DVD-ROM disks, or combinations thereof.
- aspects of the disclosure can be implemented in a computing system that includes a back end component, e.g., as a data server, a middleware component, e.g., an application server, or a front end component, e.g., a client computer having a graphical user interface, a web browser, or an app, or any combination thereof.
- the components of the system can be interconnected by any form or medium of digital data communication, such as a communication network. Examples of communication networks include a local area network (LAN) and a wide area network (WAN), e.g., the Internet.
- LAN local area network
- WAN wide area network
- the computing system can include clients and servers.
- a client and server can be remote from each other and interact through a communication network.
- the relationship of client and server arises by virtue of the computer programs running on the respective computers and having a client-server relationship to each other.
- a server can transmit data, e.g., an HTML page, to a client device, e.g., for purposes of displaying data to and receiving user input from a user interacting with the client device.
- Data generated at the client device e.g., a result of the user interaction, can be received at the server from the client device.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Mathematical Physics (AREA)
- General Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Biomedical Technology (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Evolutionary Computation (AREA)
- Biophysics (AREA)
- Software Systems (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
Claims
Applications Claiming Priority (3)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US202363462701P | 2023-04-28 | 2023-04-28 | |
| US18/225,277 US12554709B2 (en) | 2023-04-28 | 2023-07-24 | In-context text-to-SQL with reduced labeled data |
| PCT/US2023/036091 WO2024226087A1 (en) | 2023-04-28 | 2023-10-27 | In-context text-to-sql with reduced labeled data |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| EP4473420A1 true EP4473420A1 (en) | 2024-12-11 |
Family
ID=88975820
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| EP23813911.7A Pending EP4473420A1 (en) | 2023-04-28 | 2023-10-27 | In-context text-to-sql with reduced labeled data |
Country Status (2)
| Country | Link |
|---|---|
| EP (1) | EP4473420A1 (en) |
| WO (1) | WO2024226087A1 (en) |
-
2023
- 2023-10-27 WO PCT/US2023/036091 patent/WO2024226087A1/en not_active Ceased
- 2023-10-27 EP EP23813911.7A patent/EP4473420A1/en active Pending
Also Published As
| Publication number | Publication date |
|---|---|
| WO2024226087A1 (en) | 2024-10-31 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12554709B2 (en) | In-context text-to-SQL with reduced labeled data | |
| US12147422B2 (en) | System and method for transpilation of machine interpretable languages | |
| Grenié et al. | fundiversity: a modular R package to compute functional diversity indices | |
| US11403286B2 (en) | Bridge from natural language processing engine to database engine | |
| US20250036670A1 (en) | Large Language Models in Cloud Database Platforms | |
| US20160292591A1 (en) | Streamlined analytic model training and scoring system | |
| CN112930529A (en) | Generating software artifacts from conceptual data models | |
| EP4423673A1 (en) | Self-improving llms through consistency-based self-generated demonstrations | |
| US20240394545A1 (en) | Universal Self-Adaptive Prompting | |
| US20250245553A1 (en) | Load Balancing For Mixture Of Experts Machine Learning | |
| US20230195723A1 (en) | Estimation apparatus, learning apparatus, estimation method, learning method and program | |
| EP4460764A1 (en) | Populating datastores for integration testing | |
| US20260003983A1 (en) | Infrastructure-As-Code Validation With Language Models | |
| EP4473420A1 (en) | In-context text-to-sql with reduced labeled data | |
| US12579705B2 (en) | Generative model fine-tuning based on performance and quality | |
| CN120029604A (en) | Training data generation method, device, equipment and medium | |
| US20250013432A1 (en) | Custom Scratchpad Memory For Partial Dot Product Reductions | |
| CN121008851A (en) | Modeling methods, devices and equipment, storage media, and program products for prompt information | |
| WO2024155306A1 (en) | Self-improving llms through consistency-based self-generated demonstrations | |
| US12405952B2 (en) | Zero knowledge response | |
| US12536163B2 (en) | Foundational machine learning model for learned database tasks | |
| US20250224973A1 (en) | Solution Composition And Decomposition | |
| WO2024242959A1 (en) | Universal self-adaptive prompting | |
| US12530368B1 (en) | Scalable data import into managed lakehouses | |
| CN120803467B (en) | Methods, devices, electronic devices, storage media, and computer program products for converting code languages |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| STAA | Information on the status of an ep patent application or granted ep patent |
Free format text: STATUS: UNKNOWN |
|
| STAA | Information on the status of an ep patent application or granted ep patent |
Free format text: STATUS: THE INTERNATIONAL PUBLICATION HAS BEEN MADE |
|
| PUAI | Public reference made under article 153(3) epc to a published international application that has entered the european phase |
Free format text: ORIGINAL CODE: 0009012 |
|
| STAA | Information on the status of an ep patent application or granted ep patent |
Free format text: STATUS: REQUEST FOR EXAMINATION WAS MADE |
|
| 17P | Request for examination filed |
Effective date: 20240521 |
|
| AK | Designated contracting states |
Kind code of ref document: A1 Designated state(s): AL AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC ME MK MT NL NO PL PT RO RS SE SI SK SM TR |
|
| STAA | Information on the status of an ep patent application or granted ep patent |
Free format text: STATUS: EXAMINATION IS IN PROGRESS |
|
| 17Q | First examination report despatched |
Effective date: 20251114 |