# US 2026/0087002 A1 · Natural language generation for database queries

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2026/0087002 A1
- Document ID: US20260087002A1
- Status: Published application
- Kind: A1
- Application number: 19/334,315
- Filed: 2025-09-19
- Published: 2026-03-26
- Earliest claimed: 2024-09-25
- Assignees: The Toronto-Dominion Bank
- Applicants: The Toronto-Dominion Bank
- Inventors: Ilan Gofman; Satya Krishna Gorti; Guangwei Yu; Jesse Cole Cresswell; Zhaoyan Liu; Rasa Hosseinzadeh; Jiapeng Wu; Noel Vouitsis; Maksims Volkovs
- Web page: https://patentgrep.com/patent/US20260087002A1

## CPC

- G06F 16/243: {Natural language query formulation}
- G06F 16/2237: {Vectors, bitmaps or matrices}
- G06F 16/24522: {Translation of natural language queries to structured queries}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A natural language query is translated to a corresponding database query using a language model. To improve the quality of the generated database query, natural language models may be applied to select appropriate tables of the database and to generate a plurality of candidate database queries. Each candidate database query is executed against the database to obtain associated query results. A language model evaluates the plurality of candidate database queries and associated query results to determine which database query most correctly matches the natural language query and returns that database query or associated query results as a response to the natural language query.

## Claims

### Claim 1

A system for natural-language database queries, comprising:
one or more processors for executing instructions;
one or more computer-readable media containing instructions for execution by the one or more processors for:
receiving a natural language query for querying a database, the natural language query not being in a format compatible with a format for querying the database;
determining a plurality of candidate database queries by applying the natural language query to a query generation language model;
determining a plurality of candidate database query results, each corresponding to the plurality of candidate database queries, by querying the database with the respective candidate database query;
selecting a candidate database query by providing natural language query, the plurality of candidate database queries and associated sets of candidate database query results to a query evaluation language model; and
providing the selected candidate database query or the associated set of candidate database query results as a response to the natural language query.

### Claim 2 (depends on 1)

The system of claim 1, wherein applying the natural language query to the query generation language model comprises prompting the query generation language model with the natural language query, a set of tables in the database, and metadata describing the tables of the database.

### Claim 3 (depends on 2)

The system of claim 2, wherein the instructions are further executable for selecting the set of tables for the query generation language model as a subset of tables of the database by applying the natural language query to a table selection language model.

### Claim 4 (depends on 2)

The system of claim 2, wherein the instructions are further executable for determining examples of data fields for at least one table of the set of tables by applying an embedding of the natural language model to a vector index.

### Claim 5 (depends on 1)

The system of claim 1, wherein the natural language query evaluation model jointly evaluates two or more of the plurality of candidate database queries.

### Claim 6 (depends on 1)

The system of claim 1, wherein selecting the candidate database query includes a plurality of pairwise comparisons of the plurality of candidate database queries by the query evaluation language model.

### Claim 7 (depends on 1)

The system of claim 1, wherein the instructions are further executable for determining whether the plurality of candidate database query results are the same; and wherein selecting the candidate database query is performed selectively when the plurality of candidate database query results are not the same.

### Claim 8 (depends on 1)

The system of claim 1, wherein training the query evaluation language model with training data is determined from training the query generation language model.

### Claim 9

A method for natural-language database queries, comprising:
receiving a natural language query for querying a database, the natural language query not being in a format compatible with a format for querying the database;
determining a plurality of candidate database queries by applying the natural language query to a query generation language model;
determining a plurality of candidate database query results, each corresponding to the plurality of candidate database queries, by querying the database with the respective candidate database query;
selecting a candidate database query by providing natural language query, the plurality of candidate database queries and associated sets of candidate database query results to a query evaluation language model; and
providing the selected candidate database query or the associated set of candidate database query results as a response to the natural language query.

### Claim 10 (depends on 9)

The method of claim 9, wherein applying the natural language query to the query generation language model comprises prompting the query generation language model with the natural language query, a set of tables in the database, and metadata describing the tables of the database.

### Claim 11 (depends on 10)

The method of claim 10, further comprising selecting the set of tables for the query generation language model as a subset of tables of the database by applying the natural language query to a table selection language model.

### Claim 12 (depends on 10)

The method of claim 10, further comprising determining examples of data fields for at least one table of the set of tables by applying an embedding of the natural language model to a vector index.

### Claim 13 (depends on 9)

The method of claim 9, wherein the natural language query evaluation model jointly evaluates two or more of the plurality of candidate database queries.

### Claim 14 (depends on 9)

The method of claim 9 wherein selecting the candidate database query includes a plurality of pairwise comparisons of the plurality of candidate database queries by the query evaluation language model.

### Claim 15 (depends on 9)

The method of claim 9, further comprising determining whether the plurality of candidate database query results are the same; and wherein selecting the candidate database query is performed selectively when the plurality of candidate database query results are not the same.

### Claim 16 (depends on 9)

The method of claim 9, wherein training the query evaluation language model with training data is determined from training the query generation language model.

### Claim 17

A non-transitory computer-readable medium for natural-language database queries, the non-transitory computer-readable medium comprising instructions executable by a processor for:
receiving a natural language query for querying a database, the natural language query not being in a format compatible with a format for querying the database;
determining a plurality of candidate database queries by applying the natural language query to a query generation language model;
determining a plurality of candidate database query results each corresponding to the plurality of candidate database queries, by querying the database with the respective candidate database query;
selecting a candidate database query by providing natural language query, the plurality of candidate database queries and associated sets of candidate database query results to a query evaluation language model; and
providing the selected candidate database query or the associated set of candidate database query results as a response to the natural language query.

### Claim 18 (depends on 17)

The non-transitory computer-readable medium of claim 17, wherein applying the natural language query to the query generation language model comprises prompting the query generation language model with the natural language query, a set of tables in the database, and metadata describing the tables of the database.

### Claim 19 (depends on 18)

The non-transitory computer-readable medium of claim 18, wherein the instructions are further executable for selecting the set of tables for the query generation language model as a subset of tables of the database by applying the natural language query to a table selection language mode.

### Claim 20 (depends on 18)

The non-transitory computer-readable medium of claim 18, wherein the instructions are further executable for determining examples of data fields for at least one table of the set of tables by applying an embedding of the natural language model to a vector index.
