IP Library › Granted Patent US 12,730,807
Granted Patent B2
US 12,730,807 · App. 19/008,743 · Granted Sep 8, 2026

Natural language conversion to SQL for complex scenarios

Inventors: Rui Han (Xi'An, CN); Yuan Yuan Ding (Shanghai, CN); Qi Liang Zhou (Xi'An, CN); Yong Wang (Xian, CN); Deng Xin Luo (Xian, CN)
Assignee: International Business Machines Corporation
G06F16/24522G06F16/2246G06F16/2456
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,730,807
App. No.
19/008,743
Granted
Sep 8, 2026
Kind
B2
Abstract

An example operation includes one or more of receiving a natural language input via a software application, executing a machine learning model on the natural language input to determine a plurality of sub-queries corresponding to the natural language input, searching a tree structure for field values that correspond to the plurality of sub-queries, relationships between the field values, and computations to be performed, generating a structured query language (SQL) command based on the field values, relationships between the field values, and the computations to be performed, and executing the SQL command on a database to generate query results and return the query results to the software application.

Claims (43)

1 . A computer-implemented method comprising:

receiving a natural language input via a software application;

executing a machine learning model on the natural language input to determine a plurality of sub-queries corresponding to the natural language input;

searching a tree structure for field values that correspond to the plurality of sub-queries and relationships between the field values, wherein the searching comprises searching a plurality of layers of the tree structure and identifying a plurality of query attributes for a structured query language (SQL) command, respectively, and executing a Monte Carlo Tree Search (MCTS) on the tree structure starting from a root node of the tree structure to decide a path in the tree structure which includes a child node that contains a greatest upper confidence bound;

generating the SQL command based on the field values and relationships between the field values, wherein the generating comprises generating the SQL command to include the plurality of query attributes; and

executing the SQL command on a database to generate query results and return the query results to the software application.

2 . The computer-implemented method of claim 1 , wherein the executing the machine learning model comprises determining hidden query content from the natural language input based on execution of the machine learning model and generating a sub-query which includes the hidden query content.

3 . The computer-implemented method of claim 1 , wherein the searching comprises identifying tables to be queried from the database and at least one join operation to be performed on the tables, from the tree structure.

4 . The computer-implemented method of claim 1 , wherein the searching comprises identifying an operation for the SQL command including at least one of an aggregate function, a Boolean function, and a numeric calculation, and column identifiers for the operation, from the tree structure.

5 . The computer-implemented method of claim 1 , wherein the generating comprises executing a second machine learning model on the SQL command, the natural language input, and database schema data to generate a refactored SQL command, wherein the executing comprises executing the refactored SQL command on the database.

6 . The computer-implemented method of claim 1 , further comprising:

retraining the machine learning model.

7 . The computer-implemented method of claim 6 , wherein the machine learning model is retrained using at least the natural language input, the plurality of sub-queries and the SQL command.

8 . A computer system comprising:

a processor set;

a set of one or more computer-readable storage media; and

program instructions, collectively stored in the set of one or more storage media, that cause the processor set to perform computer operations comprising:

receiving a natural language input via a software application;

executing a machine learning model on the natural language input to determine a plurality of sub-queries corresponding to the natural language input;

searching a tree structure for field values that correspond to the plurality of sub-queries and relationships between the field values, wherein the searching comprises searching a plurality of layers of the tree structure and identifying a plurality of query attributes for a structured query language (SQL) command, respectively, and executing a Monte Carlo Tree Search (MCTS) on the tree structure starting from a root node of the tree structure to decide a path in the tree structure which includes a child node that contains a greatest upper confidence bound;

generating the SQL command based on the field values and relationships between the field values, wherein the generating comprises generating the SQL command to include the plurality of query attributes; and

executing the SQL command on a database to generate query results and return the query results to the software application.

9 . The computer system of claim 8 , wherein the executing the machine learning model comprises determining hidden query content from the natural language input based on execution of the machine learning model and generating a sub-query which includes the hidden query content.

10 . The computer system of claim 8 , wherein the searching comprises identifying tables to be queried from the database and at least one join operation to be performed on the tables, from the tree structure.

11 . The computer system of claim 8 , wherein the searching comprises identifying an operation for the SQL command including at least one of an aggregate function, a Boolean function, and a numeric calculation, and column identifiers for the operation, from the tree structure.

12 . The computer system of claim 8 , wherein the generating comprises executing a second machine learning model on the SQL command, the natural language input, and database schema data to generate a refactored SQL command, wherein the executing comprises executing the refactored SQL command on the database.

13 . The computer system of claim 8 , wherein the program instructions further cause the processor set to perform computer operations comprising:

retraining the machine learning model.

14 . The computer system of claim 13 , wherein the machine learning model is retrained using at least the natural language input, the plurality of sub-queries and the SQL command.

15 . A computer program product comprising:

a set of one or more computer-readable storage media; and

program instructions, collectively stored in the set of one or more computer-readable storage media, for causing a processor set to perform computer operations comprising:

receiving a natural language input via a software application;

executing a machine learning model on the natural language input to determine a plurality of sub-queries corresponding to the natural language input;

searching a tree structure for field values that correspond to the plurality of sub-queries and relationships between the field values, wherein the searching comprises searching a plurality of layers of the tree structure and identifying a plurality of query attributes for a structured query language (SQL) command, respectively, and executing a Monte Carlo Tree Search (MCTS) on the tree structure starting from a root node of the tree structure to decide a path in the tree structure which includes a child node that contains a greatest upper confidence bound;

generating the SQL command based on the field values and relationships between the field values, wherein the generating comprises generating the SQL command to include the plurality of query attributes; and

executing the SQL command on a database to generate query results and return the query results to the software application.

16 . The computer program product of claim 15 , wherein the executing the machine learning model comprises determining hidden query content from the natural language input based on execution of the machine learning model and generating a sub-query which includes the hidden query content.

17 . The computer program product of claim 15 , wherein the searching comprises identifying tables to be queried from the database and at least one join operation to be performed on the tables, from the tree structure.

18 . The computer program product of claim 15 , wherein the searching comprises identifying an operation for the SQL command including at least one of an aggregate function, a Boolean function, and a numeric calculation, and column identifiers for the operation, from the tree structure.

19 . The computer program product of claim 15 , wherein the program instructions are further causing the processor set to perform:

retraining the machine learning model.

20 . The computer program product of claim 19 , wherein the machine learning model is retrained using at least the natural language input, the plurality of sub-queries and the SQL command.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 3, 2025
From: HAN, RUI; DING, YUAN YUAN; ZHOU, QI LIANG; WANG, YONG; LUO, DENG XIN
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 069730/0501 →
Continuity (1)
Related Publication 20260195324A1 · Jul 9, 2026
References Cited (18)
US 10380213B1 · Sanchez · 2019 [cited by applicant]
US 10430407B2 · Bhatt · 2019 [cited by examiner]
US 11269872B1 · Moo · 2022 [cited by examiner]
US 11798529B2 · Zhu et al. · 2023 [cited by applicant]
US 20200034362A1 · Galitsky · 2020 [cited by examiner]
US 20200334233A1 · Lee · 2020 [cited by examiner]
US 20200334252A1 · Lee · 2020 [cited by examiner]
US 20220215622A1 · Stevens · 2022 [cited by examiner]
US 20240242154A1 · Jindal et al. · 2024 [cited by applicant]
CN 112347121A · 2021 [cited by applicant]
CN 116414865A · 2023 [cited by applicant]
CN 116414961A · 2023 [cited by applicant]
CN 116991875A · 2023 [cited by applicant]
CN 117271557A · 2023 [cited by applicant]
CN 117708162A · 2024 [cited by applicant]
CN 117743371A · 2024 [cited by applicant]
Lian et al., “ChatBI: Towards Natural Language to Complex Business Intelligence SQL”, arXiv:2405.00527v1 , May 1, 2024, 12 pages. [cited by applicant]
Yu et al., “Prompt-Based Monte-Carlo Tree Search for Goal-oriented Dialogue Policy Planning”, Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, Dec. 6-10, 2023, pp. 7101-7125. [cited by applicant]