Divide-and-conquer prompt for LLM-based text-to-SQL conversion
Abstract
Systems and methods for processing search queries are provided. A method, according to one implementation, includes a step of receiving a query from a user interface, the query including one or more questions or commands pertaining to datasets stored in a relational database. The method also includes a step of generating a prompt having instructions related to how a Large Language Model (LLM) is to handle a complex query having one or more cascading dependencies. Also, the method includes a step of providing the prompt, datasets, and query to an LLM with instructions to convert the query into Structure Query Language (SQL) code.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 22 · Forward citations: 0.
Claims (8 — 1 Independent, 7 Dependent)
- Claim 1Independent Claim
A non-transitory computer-readable medium configured to store computer logic having directions that, when executed, cause one or more processing devices to: receive a query from a user interface, the query including one or more questions or commands pertaining to datasets stored in a relational database; generate a prompt having instructions for a Large Language Model (LLM) to handle the query; and provide the prompt, datasets, and query to the LLM with instructions to convert the query into Structure Query Language (SQL) code, wherein, in response to determining that the query is complex, the prompt includes an instruction directing the LLM to: break down the complex query into sub-questions including a plurality of sub-questions comprising at least one parent sub-question and at least two child sub-questions; extract one or more cascading dependencies between the sub-questions by generating a dependency representation identifying, for each child sub-question, a parent result that the
- Claim 2Depends on #1
The non-transitory computer-readable medium of claim 1, wherein the LLM is configured to apply the SQL code, formulated based on the sub-SQL scripts, to the relational database to obtain one or more answers to the complex query.
- Claim 3Depends on #1
The non-transitory computer-readable medium of claim 1, wherein the query is related to a specific subject, and wherein the directions further cause the one or more processing devices to obtain a set of tables related to the specific subject from the relational database.
- Claim 4Depends on #1
The non-transitory computer-readable medium of claim 1, wherein the directions further cause the one or more processing devices to determine if the query is complex.
- Claim 5Depends on #4
The non-transitory computer-readable medium of claim 4, wherein, in response to determining that the query is not complex, the directions further cause the one or more processing devices to provide a simple prompt to the LLM.
- Claim 6Depends on #4
The non-transitory computer-readable medium of claim 4, wherein, in response to determining that the query is complex, the directions further cause the one or more processing devices to add an instruction to the prompt to direct the LLM to adopt a divide-and-conquer strategy for handling the complex query, wherein the divide-and-conquer strategy is configured to direct the LLM to: a) break down the complex query into the sub-questions, b) extract the cascading dependencies from the sub-questions, c) convert each sub-question into the corresponding sub-SQL script, and d) logically combine the sub-SQL scripts based on the cascading dependencies to formulate a final SQL that will provide correct answers to the complex query.
- Claim 7Depends on #1
The non-transitory computer-readable medium of claim 1, wherein the prompt includes intermediate reasoning steps to enable the LLM to handle a complex query.
- Claim 8Depends on #1
The non-transitory computer-readable medium of claim 1, wherein the directions further cause the one or more processing devices to modify the prompt, when handling the complex query having the one or more cascading dependencies, to instruct the LLM to behave in one or more of the following ways: a) act as expert for translating the query into the SQL code, b) follow a step by step approach, and c) use a Chain of Thought (CoT) technique.
Technical Overview & Description
FIELD OF THE DISCLOSURE The present disclosure relates generally to networking and computing. More particularly, the present disclosure relates to systems and methods for a divide-and-conquer prompt approach for Large Language Model (LLM)-based text-to-Structured Query Language (SQL) translation. BACKGROUND Creating customized reports from logs can become extremely difficult when logs include large amounts of data. Cloud-based systems can have transaction logs which include trillions of transactions with hundreds of millions of transactions being logged each day. Traditionally, users are required to spend a large amount of time selecting various filters and waiting for the logs to load to sort through the trillions of log data entries to get to the desired information. A system for creating customized reports is needed to allow users to easily receive desired data in a requested format. The present disclosure provides systems and methods for a natural language interface for querying logs in a cloud-based system. BRIEF SUMMARY The present disclosure provides systems and methods for a natural language interface for querying logs in a cloud-based system. Filtering through data associated with a cloud-based system can be extremely difficult. This is because cloud-based system logs can contain over 300 billion transactions or more every day. Because of the sheer size of these transaction logs, it is difficult to produce customized reports with specific data. Also, log queries require some expertise in a user, e.g., knowledge of SQL. In various embodiments, the systems and methods include training and utilizing a machine learning system that is adapted to convert natural language into a visualization of desired data. More particularly, the present systems and methods convert natural language into various filters necessary for creating a customized report from the log data. The present disclosure is further directed to systems and methods for performing a search query. In
Cited By — Indexed Forward Citations (0 of 0 total)
No indexed citing patents in this generation yet. Ingest USPTO/PatentsView bulk citation tables via patents-ingest to expand the local forward citation graph.
References Cited — Backward Prior Art (22)
| Patent | Title | Year | Citations |
|---|