Evaluating the Text-to-SQL Capabilities of Large Language Models
Paper · 2022 · Nitarshan Rajkumar, Raymond Li and Dzmitry Bahdanau
Summary
A person asking a database for information can describe the answer they want without knowing how the data is stored. A system translating that request into SQL, the language used to query the database, has to work out which tables and columns carry the relevant information and how to combine or filter it. The authors ask whether Codex, a text generator already trained on code, can do that work without further training on the translation task. They compare it with GPT-3 and with systems trained specifically to produce SQL from questions.
On the development set of Spider, a benchmark spanning different databases, davinci-codex achieves 67% execution accuracy with a prompt that contains table definitions and sample rows. That score measures agreement with the expected answer when queries are run. The corresponding test-suite accuracy is 56.5%. This evaluation checks whether a query behaves like the reference across a suite of execution tests, so it can recognize equivalent queries written in different ways. The authors compare the execution score with the earlier 68% reported for BRIDGE v2. The comparison puts prompted Codex close to an established task-trained system on that metric and split.
The database description accounts for much of the observed change in performance. With davinci-codex on Spider development questions, execution accuracy is 8.3% when the prompt supplies the question alone and 56.8% when it gives a description of the schema, the layout of tables and columns, in the API Docs format. SQL table declarations give 59.9%. Those declarations include column types and foreign keys, which describe links between tables. Adding sample values to the declarations brings execution accuracy to 67.0% with 3 rows per table. The combined format loses accuracy when more rows are added.
The authors inspect 100 randomly sampled queries from that best configuration that can run but fail the test-suite check. The human annotator accepts 31% of that sample as reasonable translations. A question may leave open whether to return a name or an identifier, whether to show a useful extra column, or whether to return all records tied at an extreme. Other disagreements reveal mistakes that the annotator also rejects, such as grouping distinct entities by a shared name or replacing a condition in the question with a shortcut based on a stored value or a learned association.
On GeoQuery and Scholar, the authors compare two uses of the same small set of question–query examples. Codex reads them in the prompt, while a previously trained T5-3B system adapts through fine-tuning, an additional training phase. Codex is ahead in the few-example settings highlighted in the paper. Before any local examples are supplied, the ordering depends on the dataset. The experiments show how a system can acquire useful guidance from the input alone and why its measured performance depends on which database facts and conventions that input makes visible.
Deep dive: Evaluating the Text-to-SQL Capabilities of Large Language Models
The paper tests how Codex turns questions into SQL, how database context changes accuracy, and how a few examples help it adapt to a new domain. · about 36 minutes to read
The problem and its context
What a question leaves the database to resolve
Text-to-SQL is a form of semantic parsing. The input is an ordinary-language request and the output is a formal expression that a computer can interpret. In this case, the expression is an SQL query, and executing it retrieves an answer from a particular database. The practical attraction is that a person can ask for information in familiar terms without first learning the database layout or writing the query by hand.
A question and a database describe the same subject in different ways. The question names objects and relationships as people talk about them. The database represents those objects as records and those relationships through the fields available in its tables. A table organizes records into rows, with columns identifying which values each record carries. The schema describes this arrangement. A query needs to use the actual names and relationships in that schema, including links the question may never mention explicitly.
Consider the kind of request the authors use to explain their error analysis, one asking for the person at an age extreme. The query needs a representation of age or a field from which the ordering can be established. It also needs to decide what to return about the person. A name makes sense as a human-readable answer, while an identifier can uniquely specify the record within the database. If several people tie, the result may contain all of them or an individual chosen under a convention. Those choices affect the answer even if the intended extreme is clear.
Questions that require aggregation bring a different decision into view. A query can summarize rows separately for each entity, provided it has a way to decide which rows belong together. A name can look like a suitable basis for grouping because it appears in the question or is easy to read. If the schema allows different entities to share that name, using it to form groups changes what is being counted or summarized. The translation problem includes recognizing which stored fields represent identity, which represent descriptions, and which connect records across tables.
The authors describe a common research setup that makes the target database part of the input. A training example gives the system a question, a description of the schema, and in some approaches information about the contents. The corresponding SQL supplies the target for learning. This setup reflects a distinction that runs through the paper. A schema can establish that a field exists and describe its type or relationships. Database contents can illustrate which values actually occur and how they are represented. A translator can draw different clues from each.
The case for testing an already trained generator
The immediate background is a line of work that starts with a system pretrained on ordinary text and adapts it to query generation. Pretraining provides a general starting point, and training on task examples teaches the connection between questions, schemas, and their associated SQL. The authors describe gains from using larger pretrained systems in that supervised setting, where supervision consists of examples paired with their desired outputs.
Their T5 comparisons come from that line of work. According to the paper, T5 is trained on Spider using publicly available checkpoints that were pretrained on Common Crawl. A checkpoint is a saved state of a trained system. T5 uses an encoder to represent the input and a decoder to produce the query, with the question and schema conditioning the output. The authors identify the 3B-parameter T5 configuration with PICARD as the leading Spider approach in their account of the field. PICARD constrains which continuations are allowed during generation through incremental parsing. It addresses the formal demands of SQL at the stage when output is being written.
The paper also draws on BRIDGE v2, a BERT-based system that maps an input sequence to an output sequence. Its inclusion gives the authors a point of comparison from earlier work devoted to the relationship between text and tables. The question raised by the Codex experiments is whether a system with broad prior exposure to code can reach a comparable level of execution accuracy when the current task is communicated through an input. BRIDGE
Two developments motivate that alternative. Earlier work on GPT-3 reported useful behavior from giving a generator a small number of worked examples in the input. This is one route to few-shot learning, where the system adapts to a task from limited evidence. Earlier work on Codex studied generation after additional training on code. Taken together, those developments lead to a specific empirical question. If a generator can read examples as context and already has experience with programming languages, how far can a textual description of a database and a request take it towards a working query? GPT-3 and few-shot learning · Codex and code generation
Generalization at different scales
Spider and the single-database datasets let the authors examine different kinds of transfer. Spider asks how query generation works across domains. The database description varies with the question, so the system needs to use the particular tables and columns available in the instance being evaluated. In the study's zero-shot Spider setting, the API generators receive no worked question–query pairs for the task. A prompt can still include an extensive description of the database. Zero-shot describes the absence of demonstrations, while the prompt comparisons vary how much other information the system receives.
GeoQuery and Scholar give the authors a way to study adaptation within a domain. Their starting observation, attributed to earlier work, is that training on Spider transfers poorly to some single-database tasks when there is no further adaptation. A database brings its own vocabulary and structure, and a benchmark can also have a customary way of expressing answers. Examples for that database may help the system infer those conventions as well as learn which tables or operations are useful.
The resulting comparison involves different uses of a limited resource. A domain example can be treated as training material, allowing the system to update what it has learned, or it can be shown immediately before the new question as a demonstration. A fair comparison needs to specify which examples are made available and what kind of prior training each system brings. Those choices matter especially when a support set is small enough that an individual example can introduce a query structure the other examples never show.
The method, step by step
Set up the translation and comparison
The basic procedure starts with a question and its associated database. The prompt is a piece of text that presents the question alongside whatever schema descriptions, sample values, or worked examples the experiment permits. The API generator then writes an SQL continuation. The study compares that continuation with the benchmark's reference query through execution. A separate inspection examines selected cases where a runnable query fails the semantic evaluation.
From a database question to an evaluated query
The steps in order.
The API experiments cover GPT-3 variants named ada, babbage, curie, and davinci. The two Codex variants are cushman-codex and davinci-codex. In both families, training and generation involve next-token prediction. A token is a unit in the text representation, and generation repeatedly chooses a token given the sequence so far. A prefix with database definitions and a question can therefore condition the same process that would continue another kind of text. GPT-3 received broad internet training, while Codex received further training using GitHub code.
The authors compare the API results with published T5 and BRIDGE v2 results on Spider. The few-shot branch has its own T5-3B baseline, which starts from a system already trained on Spider. This baseline takes the limited examples in a subsequent training stage. The diagram follows the prompting branch, where the support pairs appear in the actual text used to generate the answer. The question and corresponding SQL in each pair serve the same supervisory purpose in both branches, but they are made available through different procedures.
Change what the prompt says about the database
The Question format puts the request in an SQL comment. A comment is text intended for a reader of the code and carries no instruction for the database engine to execute. With this format the generator sees the natural-language task in a code-like setting, while the names and relationships specific to the database are absent. This supplies a starting point for measuring what changes when the prompt begins to describe the database.
API Docs introduces the schema. The authors take its presentation from a text-to-SQL example in the Codex API documentation. It uses a comment-style representation outside standard SQLite syntax. SQLite is the SQL environment used to check executability in the Spider experiments. The schema description makes it possible to refer to the tables and columns available for the question, even though it presents them as explanatory text.
Select X supplies a view of database contents through the results of a limited selection from each table. The authors describe the operation with this SQL pattern.
SELECT * FROM T LIMIT X
SELECT requests data, * stands for all the table's columns, FROM identifies where the data comes from, and T represents the table. LIMIT adds a cap on the number of returned rows, with X representing that cap. The authors place the displayed output in comments. Its column headers reveal the names of fields, and the returned rows illustrate the values found in those fields. Thus even the format based on row contents provides some information about structure.
Create Table gives a more explicit description of structure through SQL declarations for the database's tables. It includes column types and foreign keys. A type describes what kind of data a field holds. A foreign key describes a relationship to a key in another table and can furnish a field to use in a join, an operation that combines related rows across tables. For a question whose answer requires information organized in separate places, knowing how those places connect can matter as much as knowing their names.
Create Table + Select X puts these definitions together with the displayed query results. The definitions describe the organization and relationships, and the row previews give concrete examples of the contents. The row limit is an experimental setting. In Create Table + Select 3, the row preview for each table comes from the selection capped at 3 rows. The authors can vary that cap while retaining the same type of table declaration. This gives them a way to see how the amount of displayed data affects the usefulness of the combined prompt.
The Fewshot format extends the combined prompt with completed question–query pairs. The examples follow the database description and precede the question to be answered. In the appendix's 5-shot illustration, the database information is from the same format with a 3-row preview, then come 5 completed pairs and the target question. The ordering makes the pairs demonstrations of what a completed translation looks like. They also give evidence about local choices such as which columns to return when the question names an entity.
Choose a small set of structurally different examples
For GeoQuery and Scholar, the authors repurpose the datasets' question splits. The examples are organized by query template. A template captures the shape of the SQL across questions whose wording or literal values can differ. A literal is a value written directly into the query, such as the text being matched in a condition. Changing a literal can change which rows qualify while preserving the rest of the query's structure. The dataset organization lets the authors choose demonstrations by recurring structure. Improving Text-to-SQL Evaluation Methodology
The procedure first ranks templates by their frequency in the training split. In the authors' notation, n is the number of target-domain support examples, the examples made available for adaptation. For the n-shot setting, the authors draw an example at random from each of the n highest-ranked templates. The randomness applies to the choice within a template. The frequency ranking determines which templates are eligible at that support count.
The distinction between a template and its individual examples matters to the comparison. Selecting several different phrasings that all map to the same structure would give evidence about wording or values, with little variety in the SQL patterns shown. Choosing from different templates gives each support slot a distinct structure under the dataset's grouping. Because the ranking comes from the training split, frequency means frequency in that split. The selection procedure is designed around its recurring forms.
The experiments use the same support set for Codex and T5-3B at a given shot count. Codex sees the question and answer for each support example in the prompt. T5-3B receives those pairs as training data for the new domain. Matching the pairs means that a difference at a given count cannot be attributed to one system receiving an especially revealing example that was withheld from the other. Both see the same question meanings and target SQL structures, even though one reads them as context and the other uses them for an update.
Specify the additional training for T5
The T5-3B starting system reaches 71% exact-match accuracy on the Spider validation set after Spider training. Exact match is the paper's stated measure for this checkpoint. It measures agreement with the reference under the benchmark's matching criterion. The GeoQuery and Scholar comparisons use test-suite accuracy, so the Spider score describes the baseline's starting point on its previous task under a different measure.
For adaptation, the authors choose the learning rate in the 20-shot setting. The learning rate controls the size of the adjustments during training. The paper gives these candidates on a common scale.
[0.1, 0.2, 0.5, 1, 2] · 10⁻⁵
Each number in brackets is a candidate coefficient. The brackets collect the alternatives, the centered dot denotes multiplication, and 10⁻⁵ gives the shared scale applied to each coefficient. The authors select the candidate based on the best validation performance after 300 training steps. The validation performance provides the criterion for choosing the training setting before the test-set assessment.
The batch size is 1024. A batch is the collection of examples processed together for a training update. In this procedure the batch can hold the entire few-shot support set. T5 therefore adapts through a specified training process, with the starting state, validation procedure, candidate rates, and batch size forming part of the comparison. In the complete-data conditions, the baseline also trains on the full domain training sets, giving a reference for how it performs with much more local supervision.
The appendix describes an additional, preliminary training comparison for GPT-3 on the full Spider training set. The authors train for four epochs with batches of eight and set the learning-rate multiplier to zero.1. An epoch is a pass through the training data, and the multiplier scales the learning-rate setting used in that procedure. These settings belong to the appendix comparison. The headline Codex configuration on Spider uses the contextual table descriptions and receives no such additional training on Spider.
Fit the information into the input
A prompt window places a bound on how much text the system can receive, measured in tokens. Davinci-codex has a 4096-token window, compared with 2048 tokens for the other API variants studied. The authors report that only davinci-codex can use the combined Create Table + Select X format with more than 1 row. The paper also describes less efficient handling of whitespace tokens by GPT-3. Under the tested representations, those variants cannot use the combined format at all.
That constraint affects what a comparison of the variants can mean. When both Codex variants can read a particular format, the authors can compare their outputs under that shared representation. When the full prompt fits only davinci-codex, its available input differs. The extra window space is part of what the system offers in practice, and it determines which question and database details can be presented together.
The same issue affects demonstrations. On GeoQuery, davinci-codex can take up to 40 support examples. Cushman-codex and the GPT-3 variants fit up to 10. On Scholar the database description is more complex and its queries are longer, so the corresponding capacity is 10 examples for davinci-codex and 5 for cushman-codex. The GPT-3 variants cannot fit any support pairs in the Scholar setting. The attainable support count depends on the length of the database representation and the size of the examples, as well as on the nominal window.
Generate queries and define the error sample
The API generation uses temperature 0. In the few-shot procedure the paper explicitly describes the decoding as greedy, meaning that generation takes the preferred continuation at each step. Temperature is a generation setting associated with how much variation the system allows in token choice. The appendix specifies 200 tokens for generation and identifies stop strings corresponding to opening markers for comments, a blank line, and a statement terminator. A stop string ends the continuation when it appears. These settings give a common generation procedure for the API experiments.
For each API variant, the authors check that a single served version was used for the reported runs. That check matters because an API name can continue to identify a product while the version behind it changes. Within the study, a comparison across prompt formats therefore uses the same underlying version for a given variant.
The generation is assessed through the benchmark before the authors select examples for manual inspection. They focus that inspection on davinci-codex with Create Table + Select 3 and randomly sample 100 predictions from a specific group. The sampled queries are executable SQL and fail the test-suite check. The annotator considers whether each is an acceptable interpretation of the question and examines what departure from the reference led to the disagreement. This sampling makes the audit a close look at meaning and output conventions among runnable failures.
Experiments and results
Read each metric against its own question
The Spider development evaluation reports validity, execution accuracy, and test-suite execution accuracy, abbreviated VA, EX, and TS. Validity is the percentage of generated queries that can execute as SQLite SQL. It answers an operational question about whether the database can run the output. A query can satisfy that requirement while selecting the wrong column, using the wrong filter, or summarizing the wrong group of records.
Execution accuracy asks whether execution returns the expected result on the database used for evaluation. Under that check, differences in the written SQL can be immaterial when the result agrees. The converse matters as well. Two queries can return the same answer for the data at hand because those particular records happen to satisfy both operations. Consider a grouping operation in a table where everyone currently has a different name. A grouping by name and a grouping by identifier can agree for those records, although they behave differently when entities share a name.
Test-suite accuracy applies a suite of execution checks to assess whether the generated query and the reference have the same meaning. This gives alternative SQL formulations a route to credit through their behavior. It also gives the evaluation a way to expose agreement that depends on the particular data. Its standard remains equivalence to the reference query. A query can express a reasonable interpretation of the question while returning something that the reference does not ask for, and the manual audit studies exactly this kind of disagreement.
That distinction is especially pertinent when one system was trained on Spider examples and another was asked to produce SQL from a prompt. Supervision on the benchmark can make a particular query style familiar. Behavioral evaluation lets the prompted system receive credit when it writes an equivalent query in its own style. An exact-match result, such as the one reported for the T5-3B starting checkpoint, answers a separate question and should be read in its own setting. The few-shot figures for GeoQuery and Scholar use test-suite accuracy.
Follow the Spider results across prompt formats
The paper gives a numerical progression for davinci-codex on Spider's development split. The change from Question to API Docs introduces information about the target schema. Create Table supplies schema details in SQL declarations. The best combined prompt keeps the declarations and adds results from limited selections on the tables.
Davinci-codex prompt formats on Spider development execution accuracy
The strongest prompt pairs explicit table definitions with a short preview of the stored rows.
The numbers
| System or setting | execution accuracy % |
|---|---|
| Question | 8.3 |
| API Docs | 56.8 |
| Create Table | 59.9 |
| Create Table + Select 3 (this paper) | 67.0 |
The Question result shows the difficulty of coordinating with a database that the input never describes. API Docs makes the available schema explicit, and the large change in execution accuracy shows how consequential that information is for this setup. The additional improvement with Create Table accompanies a change both in notation and in what the prompt says about fields and relationships. At the final step, the short preview adds a source of evidence about the values that the schema organizes.
The paper gives the best Spider development execution score as 67% in its comparison across systems. It gives the same configuration's test-suite accuracy as 56.5%. The latter figure belongs to davinci-codex with Create Table + Select 3. Reading the metrics together tells the reader how often execution agrees on the database used for the ordinary check and how often the prediction also meets the test suite's standard for semantic agreement. The numbers answer different empirical questions about the same set of generated queries.
BRIDGE v2 is the published historical comparison that the authors emphasize. It reached 68% execution accuracy in the Spider comparison cited by the paper. The figure compares the performance of the prompted Codex setting with that established result, using the execution metric central to the authors' claim.
Codex and BRIDGE v2 on Spider development execution accuracy
Prompted Codex comes close to the published execution result for BRIDGE v2.
The numbers
| System or setting | execution accuracy % |
|---|---|
| BRIDGE v2 | 68 |
| davinci-codex with Create Table + Select 3 (this paper) | 67 |
The basis for calling Codex a strong baseline is the proximity of those execution results and the way Codex is used. The authors assemble a database description, pose the question, and evaluate the continuation without further task training for that configuration. Their comparison with T5 and PICARD places this result alongside a supervised approach that combines Spider training with constraints during generation. The headline comparison with BRIDGE v2 concerns execution accuracy specifically. The paper gives the Codex test-suite result as a separate measure of its behavior.
Compare adaptation on GeoQuery
For the domain experiments, each point on a support-count comparison represents a different amount of target-domain evidence. Codex has that evidence in its input, while the baseline has it in a new training stage. Both are assessed for how closely their generated queries agree with the references under the test suite. The whole-training-set T5 result gives another point of orientation. Trained on the full 549 GeoQuery training examples, T5 reaches 85.7% on the GeoQuery test set under the reported evaluation.
On GeoQuery, both Codex variants are already ahead of the Spider-trained T5 baseline when given no demonstrations from the target domain. The authors suggest that a preference about expressing a maximum or minimum could contribute to the result. They observe that Codex's default approach to argmax, the operation of returning an item associated with the highest value, is compatible with a GeoQuery convention that differs from Spider's. The analogous issue arises for a minimum. Choices about ties or how to identify qualifying records matter when evaluating these queries.
With the limited support sets, davinci-codex outperforms T5-3B trained on the same examples. The paper describes a substantial advantage in the comparison with up to 40 GeoQuery examples in the davinci-codex prompt. It also reports that GPT-3 davinci performs poorly on this task. The outcome therefore concerns the particular prompted generator as well as the availability of demonstrations. Even within the API systems, the fact that a question and example pairs can be represented in a prompt does not imply similar success at producing SQL.
The full-data T5 score helps distinguish the effects of scarce evidence from the baseline's performance with much greater exposure to the domain. The few-shot comparison asks how effectively the systems use the same small set. The complete-data score asks how well the T5 procedure performs when it can learn from the whole local training split. Both belong to GeoQuery and the test-suite evaluation, with different supervision budgets.
Compare adaptation on Scholar
Scholar starts with the opposite zero-shot ordering. The T5 baseline is ahead of Codex when the systems have no target-domain support examples. This matters for interpreting the subsequent gains. A generator's initial ability to fit a database's questions and conventions can differ from its ability to respond to a handful of worked examples from that database.
The reported ordering changes in the 5 and 10-shot Scholar settings. Codex does better than T5-3B when each uses the same support examples through its assigned adaptation procedure. The window constraints determine which Codex variants can be evaluated at those counts. Davinci-codex fits 10 Scholar examples, and cushman-codex fits 5. The longer queries and more involved schema mean that even the larger window offers less room for demonstrations than it does on GeoQuery.
With the entire Scholar training set, consisting of 499 examples, T5 reaches 87.2% on the Scholar test set in the reported test-suite evaluation. This establishes a competitive supervised reference for the full-data regime. The few-shot result concerns adaptation when examples are scarce. Scholar is particularly informative because the observed advantage with demonstrations follows a weaker zero-shot starting position.
The comparison across the domains puts the authors' main conclusion on a narrower and more useful footing. On GeoQuery, Codex begins ahead and also does well with the small support sets. On Scholar, T5 begins ahead and Codex moves ahead when the examples are supplied in the settings highlighted by the authors. Both patterns support the practical value of demonstrations for the tested code-trained generator. They also show why the performance of a prompted system before adaptation and its performance after adaptation deserve to be measured separately.
Locate the human result within the Spider evaluation
The manual assessment gives a different kind of result from the accuracy plots. Among the 100 randomly selected runnable predictions rejected by the test suite, the annotator finds 31% acceptable. These predictions differ in meaning from the references under the benchmark check. The annotator's task is to decide whether their answers are nevertheless defensible readings of the original question. This makes the percentage a measure of disagreement between the benchmark interpretation and human judgment in a particular group of failures.
The result helps distinguish classes of improvements that an aggregate test-suite score alone would blend together. If a query filters on the wrong condition or combines entities incorrectly, the generator needs to express a different operation. If a query answers in names where the benchmark expects identifiers, the choice may be resolved by conveying the desired output convention. Both cases can lower benchmark accuracy, but they tell the reader different things about what the system understood and what the input made explicit.
What the ablations show
Schema access produces the largest visible change in the prompt sequence
The prompt comparisons function as ablations of the information and representation available at generation time. The simplest comparison keeps davinci-codex and the Spider development evaluation fixed while changing from a request on its own to a request accompanied by a schema. The jump from the question-only score to API Docs identifies access to database structure as a major part of the strong result. A system asked for a query has a much better chance of choosing usable table and field references when those references are in the input.
The next comparison changes the kind of schema representation. Create Table expresses the schema through SQL declarations and includes details about types and foreign keys. The associated improvement shows that giving some schema information leaves room to improve how it is conveyed. The experiment changes several properties together. Its evidence attaches to the whole representation, so the contribution of valid SQL syntax, column types, and stated relationships remains intertwined.
The combined prompt comparison adds information of another kind. Seeing observed values can help a system interpret names that are opaque in isolation or recognize the form in which a concept is stored. A declaration says what fields and links are defined. A preview can illustrate which kinds of entries occupy the fields. In the tested setting the combination improves execution accuracy. The evidence concerns the use of short previews together with explicit declarations, under the generator and database conditions used in the experiment.
More rows affect the formats differently
The row-count comparison is informative because Select X and Create Table + Select X make different uses of the table preview. For Select X, the authors describe little change in performance as more rows are displayed. The headers and row contents together supply what the prompt communicates about the database. Adding rows within that format gives more examples of the same columns.
In the combined format, the declarations are already present. Here the reported accuracy reaches its peak at 3 rows and then deteriorates as the preview grows. The same basic operation of adding more stored values therefore has a different measured effect once the prompt also carries explicit structural information. This is evidence about the interaction between the amount of data shown and the representation it accompanies. The paper measures the decline but leaves its mechanism open.
The result also gives meaning to the authors' selection of Create Table + Select 3 for manual inspection. It is the setting selected for its strong aggregate performance. The remaining errors therefore show what can happen even when the generator has both direct structural cues and examples of the data. Some such errors involve using those examples to take an unwarranted shortcut, though the paper does not trace the decline from longer previews to any particular error category.
The effect of size depends on which variants can read the same input
The authors observe clear gains across the GPT-3 size ordering. Within Codex, the gap is usually smaller when prompt styles can be matched. They describe cushman-codex as generally within 1 percentage point of davinci-codex in the Spider development comparisons at the same prompt style. For Create Table, the paper reports a 3 percentage point advantage for cushman-codex over davinci-codex. Those figures describe differences in the matched-style comparisons, instead of the result of running both variants with the best combined prompt.
Davinci-codex can take the larger combined input that gives the highest reported execution score. This leads the authors to suggest that extra room for context may contribute more to its peak than the presumed increase in parameter count. The pattern behind the suggestion is that a large advantage does not consistently appear when both variants can use the same format, while the longer window enables a strong format the smaller-window variant cannot accommodate. The study varies named API systems, with both training and implementation details that are imperfectly known. It can identify the practical opportunity afforded by the window, while the relative causal contributions of capacity and scale remain uncertain.
Executable failures reveal different translation problems
Among the manually reviewed failures, the authors distinguish interpretations the annotator rejects from those judged acceptable despite a mismatch with the reference. The first group includes shortcuts. In these cases Codex uses a particular database value or an association acquired in pretraining, where the benchmark query expresses a condition with the literal from the question. Suppose a condition describes a category and the current database contains a single familiar example of it. Substituting that example for the category can narrow the query to the wrong condition. The paper's shortcut category captures this type of departure from what the question asks.
A second substantive failure concerns GROUP BY, the SQL clause that assigns rows to groups before an aggregate is calculated for each group. The authors identify cases where Codex groups by a name or title even though a primary key is needed. A primary key identifies a record uniquely. If different entities share a label, grouping by that label can merge rows that belong to separate entities. The query can run successfully and return a plausible-looking aggregate while performing the wrong operation.
The cases the annotator accepts often concern the result's form. The SELECT part of a query specifies the fields to return. A question may ask which entity meets a condition without telling the system whether to return its name or a database identifier. The reference follows a per-database choice, while the generated query can take a different, defensible one. Adding a useful column creates another kind of difference. The generated query can offer the requested information together with a field that helps a person interpret it, but the extra field changes the result that the execution tests compare.
Tie handling illustrates a disagreement about a query's scope. A request for the person with the lowest age can be read as asking for an individual or for everyone who shares that lowest age. The benchmark reference implements a particular resolution, and a runnable prediction can implement another. In the appropriate data, both outputs can look sensible to a reader and still differ behaviorally. The test-suite check is doing its job when it distinguishes two operations that return different sets. The question's wording may leave room for either operation.
The reported 31% concerns this intersection of human acceptability and test-suite rejection within the sampled runnable failures. Its significance comes from identifying why a set of outputs disagreed with the benchmark. The categories locate potential improvements in different parts of the translation process. Some require recognizing which entity a field identifies or preserving the value condition as stated. Others require evidence about the benchmark's preferred answer form or tie policy.
Demonstrations sometimes bring conventions into view
The appendix compares selected GeoQuery outputs before and after adding demonstrations. The authors identify them as cherry-picked cases from the validation set, contrasting 0-shot and 10-shot prompting. In the illustrated cases the new output more closely resembles the reference style. Changes include the selected columns and the way the answer is obtained for an extreme-value question.
These examples are particularly useful alongside the manual Spider analysis. A question's surface wording may leave decisions about the output open. Demonstrations can show how those decisions were resolved for previous questions on the same database. That provides a plausible explanation for some of the adaptation visible in the GeoQuery examples. The selected cases illustrate behavior that occurred, while overall effectiveness is assessed by the support-count experiments. The study does not separately measure how much of the few-shot advantage comes from adopting local conventions and how much comes from improved choice of query operations.
The authors propose more explicit control of Codex behavior as future work, including through prompt design and examples. That proposal follows from the nature of the disagreements. Where a case turns on a legitimate choice left implicit, a demonstration may make the desired resolution easier to infer. Where it turns on the meaning of a filter or the identity of a group, improvements would need to reach the database operation itself. The paper's analyses show why either kind of change can register as a gain in the same test-suite measure.
Limitations
Limits identified by the authors
The Spider headline results are development-set scores. The authors chose that evaluation because the held-out test questions could not be processed offline in their API setup. Sending those questions to the provider would risk exposing material meant to stay outside training. That choice limits the empirical comparison to the development evaluation and the related checks the authors describe. The reported ranking has no measurement on Spider's held-out test split in the study.
Possible prior exposure to the development questions is a separate concern. The authors note that the Spider development material is available on GitHub, which is a source of Codex training code. They investigate a straightforward retrieval explanation by prompting Codex with verbatim fragments of the dev.sql file. The resulting continuations fail to reproduce the file's contents. That file presents question–query pairs in a format different from the study's more informative prompts and lacks the schema material that accompanies the strongest results.
The authors add two behavioral observations. First, the poor question-only condition offers little evidence that a familiar question by itself triggers reproduction of its answer. Second, the generated SQL does not follow the reference queries' regular aliasing style. An alias is a short name used to refer to a table within a query. Differences in aliasing are relevant to the hypothesis that the generator directly repeats complete reference queries. Schema dependence and differences in style support the authors' case against verbatim recall as the main account of performance.
They also report results on Spider-Realistic, a modified development subset that removes explicit column-name references from questions. Performance is lower there, with similar trends across the evaluated systems. The authors say this version was unavailable publicly on GitHub and use that fact as another argument against a file-memorization explanation. They also refer to separate observations about recitation in Copilot, which they describe as derived from Codex. Those observations serve as background for their reasoning about what direct code reproduction tends to look like. Structure-Grounded Pretraining for Text-to-SQL
The appendix states uncertainties about API parameter counts. It reports estimates for GPT-3 from earlier analysis and treats the proposed Codex sizes as guesses. That makes the named variants and their tested configurations firmer points of comparison than exact internal scales. The authors also caution that the versions served by the API can change. Checking that each variant had a consistent version during the experiment addresses changes within the study. Reproducing the result later depends on whether that same served version and configuration can be obtained.
The authors describe the Spider training runs for GPT-3 as preliminary. They use default fine-tuning settings and say the cost discouraged a search over training settings. Those runs offer a comparison under the chosen settings. The authors identify fine-tuning Codex itself as future work, leaving the effects of task-specific training on the main system open.
Limits that follow from the comparisons
The evidence against direct memorization addresses a particular explanation for the results. A careful reader can distinguish that explanation from broader effects of training exposure. A generator might have seen relevant fragments, database names, or related examples and still produce SQL in a different style when given a new prompt. The experiments assess output behavior under various prompts. They provide no comprehensive inventory of the training data. The verified contribution of schema information can coexist with uncertainty about prior exposure to benchmark material.
The matched support examples make the GeoQuery and Scholar comparisons easier to interpret. Each system sees the same limited supervision at a given shot count, with one receiving it as context and one using it in training. The systems also have different architectures and training histories. Codex received additional code training, and T5-3B enters the comparison after supervised training on Spider. The result establishes the relative performance of these adaptation procedures with these starting systems. To measure the effect of changing the adaptation mechanism alone, the starting systems and prior exposure would have to be held fixed.
Prompt capacity introduces another qualification. The best Spider prompt is available to davinci-codex because its window can hold the representation. Comparisons across all available settings therefore depend partly on differences in the evidence each system can receive. The matched-format runs reduce that source of variation for the configurations they cover. Differences in token handling and window size determine which comparisons are feasible, and their influence is also visible in the maximum support counts on the two single-database tasks.
The support selection favors recurring query structures. Drawing a random instance within each selected template still gives the most common templates priority. Consequently, the few-shot findings describe adaptation under that selection rule. They leave open how the systems would respond to examples chosen to emphasize rare structures, or to a pair chosen for its particular relevance to an individual target question. Likewise, the validation examples from GeoQuery help explain how style and conventions can change, while the frequency of each kind of change remains unmeasured by those selected illustrations.
Limits on interpreting the human judgments
The audit has a deliberately narrow denominator. Its 100 predictions come from the executable outputs that fail the test suite for the best reported Spider prompt and variant. Invalid SQL falls outside that sample, as do accepted predictions and outputs from the other prompt settings. The 31% figure describes the judgments within the sampled failure group. An overall human-acceptability score would require evidence from the rest of the prediction set and a definition of how those judgments are to be aggregated.
The judgments also involve a human interpretation of what counts as sufficient. An additional column may be welcome to an annotator and unsuitable to an application that expects a specified set of fields. A human reader may accept a name in response to a question about an entity, while an application that will use the returned value to join another table may require its identifier. The audit records the judgment of an annotator and the examples the authors selected to characterize Codex behavior. The degree of agreement across readers or downstream uses remains open.
Finally, the study takes a question and its database as the unit of evaluation. It measures the translation produced under an assembled prompt and scores that output against benchmark expectations. A working database interface also has to decide how to deal with an underspecified request during use. Resolving ties, confirming an output column, or asking a follow-up question would involve interaction that this experiment does not evaluate. The reported results characterize query generation within the benchmark protocol.
What came after
Evaluating text-to-SQL as a database interface
Later citing work continues the distinction between measuring a generator's general abilities and testing what it can do when given a particular database. The later titles identify the directions those papers take. Their citation of the Codex evaluation connects them to an early comparison in which the schema representation, sample values, and method of supplying examples were explicit parts of the setup.
Text-to-SQL Empowered by Large Language Models pursues benchmark evaluation of the broader approach. The subject of the comparison extends beyond the initial question of whether prompted Codex provides a serious baseline. The earlier paper gives that research direction a concrete reason to report the input alongside the score. The same generator can be evaluated with only the request, with a textual schema, or with SQL definitions and actual values, and those settings elicit quite different execution results. A benchmark evaluation of the approach makes those choices part of what readers need to know when interpreting a comparison. Text-to-SQL Empowered by Large Language Models
The large-scale database-grounded benchmark framed around whether an LLM can serve as a database interface takes up the practical motivation directly. Its emphasis on grounding brings the database into the evaluation question. From the perspective of the earlier study, this shifts attention to a system's ability to work with the particular data representation users have, including the relationships and values the question leaves implicit. The citation links the larger interface question to an evaluation that showed how strongly results can depend on what is communicated about the current database. Can LLM Already Serve as A Database Interface?
The evaluation of ChatGPT's zero-shot text-to-SQL capability takes the no-demonstration question to another named system. Its stated focus carries forward the experimental regime used on Spider in the earlier paper. Zero-shot evaluation still leaves an important variable to characterize, namely the database information available at inference time. The distinction between worked examples and other context is essential here. A prompt can show table relationships and stored values while leaving the target request as the sole question to be translated. ChatGPT’s zero-shot Text-to-SQL evaluation
Giving generation more structure
DIN-SQL combines decomposed in-context learning with self-correction. Decomposition makes the organization of the generation process part of the method, and self-correction introduces revision after an initial attempt. The earlier work's demonstrations teach through completed question–query pairs. DIN-SQL's stated approach takes the broader premise that guidance in context can matter and places it within a process organized around parts of the translation and correction of the output. That direction is directly relevant to the earlier study's observation that errors can arise at different decisions, including how to group records and which result columns to return. DIN-SQL
LEVER takes execution into verification for language-to-code generation. In the Codex evaluation, execution supplies evidence for scoring the query after generation. Verification using execution gives the behavior of generated code a role in deciding whether the output should be trusted. The connection is the use of a formal interpreter to observe something more informative than textual plausibility. The earlier distinction between executability and semantic agreement clarifies the problem facing an execution-based verifier. A runnable artifact provides behavior that can be examined, and that behavior still has to be interpreted against the request. LEVER
SDE-SQL makes exploration with SQL probes part of its approach to generation. The Codex study presents database evidence selected in advance, including a limited preview drawn from each table. The later paper's stated use of self-driven exploration addresses the related problem of obtaining evidence through queries during the process. This connects to the earlier question of how much useful information a system can gain from the database itself. The row-count comparison gives that question a concrete motivation. Even when displaying stored values helps, the value of the evidence depends on what is shown and how it fits with the schema description. SDE-SQL
Building systems and benchmarks beyond the original comparison
CodeS pursues open-source systems built for text-to-SQL. That research direction joins the query-generation problem to the availability of the system being evaluated. In the Codex paper, the exact parameter counts are uncertain and version control depends on observing which version the API served. An open-source direction makes system construction and availability explicit parts of the later research agenda. Its connection to the earlier study is both the task itself and the question of what can be established about the configuration behind a reported number. CodeS
L2CEval takes evaluation to the wider problem of generating code from language. The Codex study provides a database-specific instance of decisions that matter in that larger setting. The output must be interpretable by a formal system, its observed behavior must match the request, and the benchmark needs a criterion for accepting alternative expressions. SQL makes the distinction especially visible because a single result can conceal differences that emerge on other data. The broader evaluation direction brings those questions into scope wherever generated code is assessed through its behavior. L2CEval
Work on in-context learning for few-shot dialogue state tracking takes the limited-example question to a different structured output task. A dialogue state keeps track of information expressed over an interaction. The relationship to text-to-SQL lies in using worked examples to guide how an ordinary utterance maps into an expected structure. In the database study, the same support pairs become demonstrations for one system and adaptation data for another. The dialogue work's stated focus places the use of examples in context at the center of a separate task where the intended output also depends on conventions about what information to represent. In-Context Learning for Few-Shot Dialogue State Tracking
Together, these citing works trace developments in benchmark design, the organization of generation, verification, and system availability. The original measurements give those directions specific questions to carry forward. How much database evidence is available before the query is written? Which conventions can a demonstration communicate? What does execution reveal about a candidate answer, and what still depends on interpreting the user's request? The Codex evaluation makes each question visible by changing the input, comparing adaptation procedures, and examining the actual queries behind the scores.
Cite
Cite as Nitarshan Rajkumar, Raymond Li and Dzmitry Bahdanau. 2022. Evaluating the Text-to-SQL Capabilities of Large Language Models. arXiv (Cornell University).
@misc{rajkumar2022evaluating,
title = {{Evaluating the Text-to-SQL Capabilities of Large Language Models}},
author = {Nitarshan Rajkumar, Raymond Li and Dzmitry Bahdanau},
year = {2022},
doi = {10.48550/arxiv.2204.00498},
eprint = {2204.00498},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2204.00498}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/rajkumar-2022-evaluating-text-sql-capabilities-large/
References
- Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel M. Ziegler, Jeffrey Wu, Clemens Winter, Christopher Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020. Language models are few-shot learners (http://arxiv.org/abs/2005.14165). our card
- Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Nikolas Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Josh Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. 2021. Evaluating large language models trained on code (http://arxiv.org/abs/2107.03374). our card
- Xiang Deng, Ahmed Hassan Awadallah, Christopher Meek, Oleksandr Polozov, Huan Sun, and Matthew Richardson. 2021. Structure-grounded pretraining for text-to-sql (https://doi.org/10.18653/v1/2021.naacl-main.105). Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies. our card
- Catherine Finegan-Dollak, Jonathan K. Kummerfeld, Li Zhang, Karthik Ramanathan, Sesh Sadasivam, Rui Zhang, and Dragomir Radev. 2018. Improving text-to-SQL evaluation methodology (https://doi.org/10.18653/v1/P18-1033). In Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 351–360, Melbourne, Australia. Association for Computational Linguistics. our card
- Leo Gao. 2021. On the Sizes of OpenAI API Models (https://blog.eleuther.ai/gpt3-model-sizes/). OpenAlex ↗ · Scholar ↗
- Srinivasan Iyer, Ioannis Konstas, Alvin Cheung, Jayant Krishnamurthy, and Luke Zettlemoyer. 2017. Learning a neural semantic parser from user feedback (https://doi.org/10.18653/v1/P17-1089). In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 963–973, Vancouver, Canada. Association for Computational Linguistics. OpenAlex ↗ · Scholar ↗
- Xi Victoria Lin, Richard Socher, and Caiming Xiong. 2020. Bridging textual and tabular data for cross-domain text-to-sql semantic parsing (http://arxiv.org/abs/2012.12627). our card
- Torsten Scholak, Nathan Schucher, and Dzmitry Bahdanau. 2021. Picard: Parsing incrementally for constrained auto-regressive decoding from language models (http://arxiv.org/abs/2109.05093). OpenAlex ↗ · Scholar ↗
- Peter Shaw, Ming-Wei Chang, Panupong Pasupat, and Kristina Toutanova. 2021. Compositional generalization and natural language variation: Can a semantic parsing approach handle both? (https://doi.org/10.18653/v1/2021.acl-long.75) In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 922–938, Online. Association for Computational Linguistics. our card
- Alane Suhr, Ming-Wei Chang, Peter Shaw, and Kenton Lee. 2020. Exploring unexplored generalization challenges for cross-database semantic parsing (https://doi.org/10.18653/v1/2020.acl-main.742). In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 8372–8388, Online. Association for Computational Linguistics. OpenAlex ↗ · Scholar ↗
- Tao Yu, Rui Zhang, Kai Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Li, Qingning Yao, Shanelle Roman, Zilin Zhang, and Dragomir Radev. 2019. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task (http://arxiv.org/abs/1809.08887). our card
- John M. Zelle and Raymond J. Mooney. 1996. Learning to parse database queries using inductive logic programming (http://dl.acm.org/citation.cfm?id=1864519.1864543). In Proceedings of the Thirteenth National Conference on Artificial Intelligence - Volume 2, pages 1050–1055. our card
- Ruiqi Zhong, Tao Yu, and Dan Klein. 2020. Semantic evaluation for text-to-sql with distilled test suites (http://arxiv.org/abs/2010.02840). OpenAlex ↗ · Scholar ↗
- Albert Ziegler. 2021. Research recitation (https://docs.github.com/en/github/copilot/research-recitation). OpenAlex ↗ · Scholar ↗