IP Library › Granted Patent US 12,566,757
Granted Patent B1
US 12,566,757 · App. 18/898,734 · Granted Mar 3, 2026

Generating and detecting text-to-structured query language using adversarial networks

Inventors: Yi Ming Wang (Xian, CN); Rui Han (Xian, CN); Mu Dan Cao (Beijing, CN); Jun Guo (Xian, CN); Sen Liang (Xian, CN); Deng Xin Luo (Xian, CN); Yu Zui You (Ningbo, CN)
Assignee: International Business Machines Corporation
G06F16/24522G06N3/092
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,566,757
App. No.
18/898,734
Granted
Mar 3, 2026
Kind
B1
Abstract

Generating structured query language queries, by extracting database schema from a target database, inputting the database schema into a generative model, training the generative model using a Monte-Carlo method and input data, training a discriminator model to distinguish generated and real input data, determining a loss value for generated input data, further training the generative model using the loss value, receiving, over a network, input text from a user, automatically generating, using the generative model, an output using the input text and providing, over the network, the output to the user.

Claims (111)

1 . A method comprising:

extracting database schema from a target database;

inputting the database schema into a generative model;

training the generative model using a Monte-Carlo method;

training a discriminator model to distinguish generated and real input data by;

fixing parameters of the generative model;

applying a first label to real input data;

applying a second label to generated input data;

merging the labeled real input data and the labeled generated input data into a common dataset;

providing the common dataset as input to the discriminator model yielding a set of results;

determining loss function values according to the set of results and the respective labels of the common dataset; and

updating discriminator model parameters according to the loss function values;

determining a loss value for generated input data;

training the generative model using the loss value model;

receiving, over a network, input text from a user;

automatically generating, using the generative model, an output using the input text; and

providing, over the network, the output to the user.

2 . The computer implemented method according to claim 1 , further comprising:

receiving, over the network, a query;

determining, by the discriminator model, a status of the query; and

providing, over the network, the status to the user.

3 . The computer implemented method according to claim 1 , wherein the output comprises an SQL query, a table schema, and data information.

4 . The computer implemented method according to claim 1 , wherein determining a loss value for generated input data comprises:

receiving incomplete generated input data from a temporary generative model;

generating a plurality of remainder data to yield a plurality of completed generated input data;

evaluating each of the plurality of completed generated input data;

determining a reward value for each of the completed generated input data according to the evaluation;

determining an expectation of reward values according to the reward values for the plurality of completed generated input data as a loss function value; and

updating temporary generative model parameters according to the loss function value.

5 . The computer implemented method according to claim 1 , further comprising:

updating generative model parameters using temporary generative model parameters;

receiving complete input data from the generative model;

evaluating the complete input data using the discriminator model, yielding a loss function value; and

updating the generative model parameters according to the loss function value.

6 . The computer implemented method according to claim 1 , wherein training the generative model comprises:

receiving a training epoch threshold value from a user over the network; and

training the generative model for the training epoch threshold value number of epochs.

7 . A computer program product for generating structured query language queries, the computer program product comprising one or more computer readable storage media and collectively stored program instructions on the one or more computer readable storage media, the stored program instructions which, when executed, cause one or more computer processors to provide a method including:

extracting database schema from a target database;

inputting the database schema into a generative model;

training the generative model using a Monte-Carlo method;

training a discriminator model to distinguish generated and real input data by;

fixing parameters of the generative model;

applying a first label to real input data;

applying a second label to generated input data;

merging the labeled real input data and the labeled generated input data into a common dataset;

providing the common dataset as input to the discriminator model yielding a set of results;

determining loss function values according to the set of results and the respective labels of the common dataset; and

updating discriminator model parameters according to the loss function values;

determining a loss value for generated input data;

training the generative model using the loss value yielding a revised generative model;

receiving, over a network, input text from a user;

automatically generating, using the revised generative model, an output using the input text; and

providing, over the network, the output to the user.

8 . The computer program product according to claim 7 , further comprising:

receiving, over the network, a query;

determining, by the discriminator model, a status of the query; and

providing, over the network, the status to the user.

9 . The computer program product according to claim 7 , wherein the output comprises an SQL query, a table schema, and data information.

10 . The computer program product according to claim 7 , wherein determining a loss value for generated input data comprises:

receiving incomplete generated input data from a temporary generative model;

generating a plurality of remainder data to yield a plurality of completed generated input data;

evaluating each of the plurality of completed generated input data;

determining a reward value for each of the completed generated input data according to the evaluation;

determining an expectation of reward values according to the reward values for the plurality of completed generated input data as a loss function value; and

updating temporary generative model parameters according to the loss function value.

11 . The computer program product according to claim 7 , further comprising:

updating generative model parameters using temporary generative model parameters;

receiving complete input data from the generative model;

evaluating the complete input data using the discriminator model, yielding a loss function value; and

updating the generative model parameters according to the loss function value.

12 . The computer program product according to claim 7 , wherein training the generative model comprises:

receiving a training epoch threshold value from a user over the network; and

training the generative model for the training epoch threshold value number of epochs.

13 . A computer system for generating structured query language queries, the computer system comprising:

one or more computer processors;

one or more computer readable storage media; and

stored program instructions on the one or more computer readable storage media for execution by the one or more computer processors, the stored program instructions which, when executed, cause one or more computer processors to provide a method including:

extracting database schema from a target database;

inputting the database schema into a generative model;

training the generative model using a Monte-Carlo method;

training a discriminator model to distinguish generated and real input data by;

fixing parameters of the generative model;

applying a first label to real input data;

applying a second label to generated input data;

merging the labeled real input data and the labeled generated input data into a common dataset;

providing the common dataset as input to the discriminator model yielding a set of results;

determining loss function values according to the set of results and the respective labels of the common dataset; and

updating discriminator model parameters according to the loss function values;

determining a loss value for generated input data;

training the generative model using the loss value model;

receiving, over a network, input text from a user;

automatically generating, using the generative model, an output using the input text; and

providing, over the network, the output to the user.

14 . The computer system according to claim 13 , further comprising:

receiving, over the network, a query;

determining, by the discriminator model, a status of the query; and

providing, over the network, the status to the user.

15 . The computer system according to claim 13 , wherein the output comprises an SQL query, a table schema, and data information.

16 . The computer system according to claim 13 , wherein determining a loss value for generated input data comprises:

receiving incomplete generated input data from a temporary generative model;

generating a plurality of remainder data to yield a plurality of completed generated input data;

evaluating each of the plurality of completed generated input data;

determining a reward value for each of the completed generated input data according to the evaluation;

determining an expectation of reward values according to the reward values for the plurality of completed generated input data as a loss function value; and

updating temporary generative model parameters according to the loss function value.

17 . The computer system according to claim 13 , further comprising:

updating generative model parameters using temporary generative model parameters;

receiving complete input data from the generative model;

evaluating the complete input data using the discriminator model, yielding a loss function value; and

updating the generative model parameters according to the loss function value.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 27, 2024
From: WANG, YI MING; HAN, RUI; CAO, MU DAN; GUO, JUN; LIANG, SEN; LUO, DENG XIN; YOU, YU ZUI
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 068715/0964 →
References Cited (24)
US 10825219B2 · Fu et al. · 2020 [cited by applicant]
US 20200265331A1 · Tashman et al. · 2020 [cited by applicant]
US 20200334252A1 · Lee · 2020 [cited by applicant]
US 20230126695A1 · Hatten · 2023 [cited by examiner]
US 20250086171A1 · Kunz · 2025 [cited by examiner]
US 20250173330A1 · Durg · 2025 [cited by examiner]
CN 111723937A · 2020 [cited by applicant]
CN 112559556B · 2021 [cited by applicant]
CN 108027833B · 2022 [cited by applicant]
CN 114897163A · 2022 [cited by applicant]
CN 115238143A · 2022 [cited by applicant]
CN 116821168B · 2024 [cited by applicant]
CN 114817295B · 2024 [cited by applicant]
Hong, Next-Generation Database Interfaces: A Survey of LLM-based Text-to-SQL, pp. 1-18, Jul. 16 (Year: 2024). [cited by examiner]
Iacob, Neural Approaches for Natural Language Interfaces to Databases: A Survey, pp. 381-395 (Year: 2020). [cited by examiner]
Xiong, Transferable Natural Language Interface to Structured Queries aided by Adversarial Generation, pp. 1-8 (Year: 2018). [cited by examiner]
GANs for Synthetic Data Generation, pp. 1-23, (Year: 2022). [cited by examiner]
Zhong, SEQ2SQL: Generating Structured Queries From Natural Language Using Reinforcement Learning, pp. 1-12, (Year: 2017). [cited by examiner]
Almohaimeed, GAT-SQL: An Advanced Prompt Engineering Approach for Effective Text-to-SQL Interactions, Aug. 8 (Year: 2024). [cited by examiner]
Gan et al. “Towards Robustness of Text-to-SQL Models against Synonym Substitution”, arXiv:2106.01065, Jun. 19, 2021, 11 pages. [cited by applicant]
Kelkar et al. “Bertrand-DR: Improving Text-to-SQL using a Discriminative Re-ranker”, arXiv:2002.00557, Nov. 3, 2020, 7 pages. [cited by applicant]
Xiong et al. “Transferable Natural Language Interface to Structured Queries aided by Adversarial Generation”, arXiv:1812.01245, Dec. 7, 2018, 8 pages. [cited by applicant]
Xue et al. “SQLGAN: Adversarial Training Methods for Text-to-SQL Generation”, Yale College and Department of Computer Science, Yale University, 2020, 1 page. [cited by applicant]
International Searching Authority, “Notification of Transmittal of the International Search Report and the Written Opinion of the International Searching Authority, or Declaration,” Patent Cooperation Treaty, Jan. 7, 20… [cited by applicant]