Global Reasoning over Database Structures for Text-to-SQL Parsing
Paper · 2019 · Ben Bogin, Matt Gardner and Jonathan Berant
Summary
A question can ask for a name without saying which database table holds it. If both singer and song have a name column, the word “name” offers little help on its own. The rest of the question can make the choice clearer. A reference to a nation may point to the singer’s country, while a song title mentioned elsewhere can explain why the song’s name is also relevant. This paper asks how a text-to-SQL parser can use evidence like this when it translates a question into a database query. The challenge is particularly acute when the parser encounters a schema it has never seen during training.
The authors extend a parser that builds SQL through a sequence of grammar decisions. Their first change comes before decoding. They build a graph with a node for each table and column in the schema, then estimate each node’s relevance using the full question and the graph’s relationships. These estimates influence how the parser represents the schema. A column can receive support from neighboring elements even when its own name is a weak match for the question. The estimates are probabilities, so the parser still has access to alternatives as it constructs queries.
The other change comes after decoding. A reranker reviews the complete candidates that the parser has kept. It examines the tables and columns each candidate uses, the relationships among them, and the question words that point toward schema elements the candidate may have left out. The decoder remains responsible for constructing SQL. Its scores also break ties when candidates receive the same reranking score, as can happen when queries use the same tables and columns but differ in an operation.
On the hidden test set of Spider, the authors’ GLOBAL-GNN system reached 47.4% accuracy under the official query-matching evaluation. The preceding graph-based parser scored 39.4%. Development comparisons show that both additions helped, with the strongest gains on questions whose reference queries used multiple tables. The analysis also identifies where better schema selection stops helping. Among errors for which the decoder had retained the correct query, 44.4% already used the correct set of tables and columns. A candidate could identify the right pieces of the database and still choose the wrong operation, such as minimum instead of maximum.
Deep dive: Global Reasoning over Database Structures for Text-to-SQL Parsing
How global schema gating and query reranking help a text-to-SQL parser choose the right tables and columns in an unfamiliar database. · about 38 minutes to read
The problem and its context
A new schema changes what a question can refer to
Text-to-SQL is a form of semantic parsing. Its input is a question in ordinary language together with information about a database. Its output is a SQL query intended to express that question. A successful translation must choose both the operations to perform and the parts of the database to which those operations apply. The wording of a question may suggest what to return, what to restrict, or which pieces of information must be combined. The schema tells the parser where those pieces of information could be found and how they are related.
The paper studies the zero-shot setting, where the database schema supplied for a new question was absent during training. The parser receives that schema at prediction time. Training examples teach it how questions can be expressed as SQL and how to use evidence from a schema, but they cannot supply a stock of correct choices for every new database. A word that corresponded to a particular column in one training database may have several plausible counterparts in a new one. Another column may be relevant even though the question uses a different word for the same idea.
The schema describes the available tables and the columns of each table. It also records relationships in which a foreign-key column refers to a primary-key column in another table. A table and any of its columns are distinct elements in the parser’s representation. The authors call these elements database constants. In the singer and song example, singer.name and song.name are different constants even though they share the same column label. A parser has to resolve which one belongs at a particular position in the query.
Multi-table questions make this choice especially consequential. A column found in one table may supply the information the user wants to see, while a column elsewhere supplies a restriction. Combining the two may require additional schema elements. A query can therefore look plausible at the level of individual names while using the wrong combination of tables. Conversely, a table that appears weakly related to every word by itself may belong in the query because of the way the relevant parts of the database connect.
Why local matches can be inconclusive
In the paper’s running example, the decoder has just produced SELECT and needs a database constant. Its attention is on a mention of “name.” Both the name of a singer and the name of a song are plausible at that moment. Looking at the next decision in isolation gives the parser little reason to choose between the two. Looking across the question and the schema provides evidence about which mention belongs with which column.
One piece of evidence comes from “nation.” The paper associates that word with country in the singer table. If the question is already talking about a singer’s country, that makes singer.name a plausible interpretation of the name to be selected. The helpful relationship here is between two columns that belong to the same table. The question supplies a clue for one column, and schema structure makes that clue informative about another.
A separate clue comes from the other mention of “name,” which occurs near “Hey.” The authors explain that “Hey” is a value in the song name column. This makes it plausible that the later mention refers to the name of a song, leaving singer.name as the better interpretation of the earlier mention. The example uses a one-to-one correspondence as an intuition about how these clues fit together. The implemented method expresses alignments through scores and weighted averages. The example illustrates why an assignment should fit the question as a whole, even when a particular decision is prompted by a particular word.
The useful distinction is between evidence a word offers by itself and evidence that becomes available once several correspondences are considered together. “Name” may align strongly with two columns. “Nation” offers more specific evidence about one of the tables. A candidate that covers the singer reference and the song reference can be more plausible than one that makes a strong match for the repeated word and weak matches for everything around it. The paper builds two opportunities to exploit this distinction into an otherwise sequential parser.
What earlier parsers contributed
The paper describes earlier parsers that construct an output autoregressively. Each step uses the partial output so far to make another decision. In the base parser used here, the decisions expand a SQL grammar from the top down. The authors place this design in a line of grammar-based approaches that includes work on syntactic code generation and Abstract Syntax Networks. The grammar supplies a structure in which a decision can call for a table or column.
When the decoder reaches such a choice, attention indicates which words in the question currently deserve weight. The parser scores each possible database constant using its local similarities to those words. The paper relates this use of attention to earlier work on neural machine translation. The arrangement helps the decoder use different parts of a question at different stages. Its limitation is that a similarity between a word and a schema element is computed independently of the other possible correspondences. Choices about two closely related database elements can also be separated by several grammar decisions.
The most direct predecessor, Representing Schema Structure with Graph Neural Networks for Text-to-SQL Parsing, had already given the parser a representation of the schema as a graph. Tables were connected to their columns, and key relationships connected columns across tables. This let the parser represent an element in terms of its neighbors. The earlier parser also estimated how strongly to emphasize each node before propagating information through the graph. Its estimate, however, came from the word that offered the strongest local evidence for that node. The graph could enrich a representation after this initial emphasis had been decided.
The paper also draws on the tradition of discriminative reranking. A generator proposes several possible analyses, and a second scorer decides which proposal to prefer. Such a scorer can inspect properties that become available only when a proposal is complete. In text-to-SQL, one such property is the combination of tables and columns used anywhere in a candidate. The authors place graph-based relevance prediction before the existing decoder and use reranking afterwards, when that combination can be extracted from the complete query.
The method, step by step
What goes in and what comes out
A training example contains a question, its reference SQL query, and the schema of the database that the query targets. The reference serves two purposes. It supplies the sequence of grammar decisions that the decoder should learn to make, and it reveals which tables and columns should be relevant to the question. The relevance labels can therefore be obtained from the same examples used to supervise query generation. At prediction time, the parser has the question and schema. It must estimate relevance and propose queries from those inputs.
The notation for the training data can be written as follows.
{(x⁽ᵏ⁾, y⁽ᵏ⁾, S⁽ᵏ⁾)}ₖ₌₁ᴺ
The braces enclose the training collection. The superscript ⁽ᵏ⁾ identifies example k, and the index runs from 1 through N, the size of the collection. Within a triple, x is the question, y is its reference SQL query, and S is the corresponding schema. The same letters without an example index can refer to the question, query, and schema for an example under discussion. The set of table and column constants in S is V.
The two learned additions answer questions at different stages. Before any candidate SQL is complete, the relevance predictor asks which elements of the supplied schema are likely to matter. After the decoder has produced candidates, the reranker asks how well each actual selection of elements fits the question. The earlier schema encoder and grammar decoder connect those stages.
From a question and schema to a selected SQL query
The steps in order.
Encode the question and keep local evidence
The base parser reads the question with a bidirectional long short-term memory network, abbreviated BiLSTM. It produces a contextual vector for each word. Reading in both directions makes each vector sensitive to words on either side. This matters when a label has several plausible referents. The same word can have different contextual representations at different positions, including when “name” occurs more than once.
The paper writes the question as a sequence.
(x₁, …, x|ₓ|)
Here x denotes the question, x₁ is its first word, and the final term denotes the word indexed by |x|, the length of the question. The ellipsis stands for the intervening words. The notation xᵢ below denotes the word at position i. Its contextual vector from the BiLSTM is eᵢ.
The parser also computes a local linking score for each word and schema element. This score uses learned representations as well as manually specified features. The authors give edit distance and the fraction of string overlap as examples of those features. A shared name can thus provide direct evidence, while the learned representations provide another source of similarity. The value of keeping these links is that global processing can start with fairly specific evidence about which word may refer to which part of the schema.
When the grammar calls for a table or column, the decoder attends to the question and combines local link scores for the choice it is considering.
sᵥ = ∑ᵢ αᵢ sₗᵢₙₖ(v, xᵢ)
Here v is a database constant and sᵥ is its score for the decoder decision. The sum runs over question positions i. The attention weight αᵢ is the importance the decoder gives to position i at that step. The term sₗᵢₙₖ(v, xᵢ) is the local similarity of constant v to word xᵢ. Each similarity is multiplied by the corresponding attention weight before the contributions are added.
The scores become an output distribution through a softmax.
softmax({sᵥ}ᵥ∈ⱽ)
The braces collect the scores sᵥ indexed by v, and v ∈ V means that v ranges over the database constants. The softmax converts the scores into normalized probabilities, with higher scores receiving higher probabilities. The grammar indicates when a decision concerns a table or column. The scoring expression describes how the base parser evaluates the constants at such a decision.
The current attention weights depend on the stage of decoding, which provides a way for different SQL decisions to draw on different words. The link score within the sum is still a comparison of one word with one database element. If the decoder attends strongly to “name,” the score can support both qualified name columns. There is no term in that comparison for whether another part of the question favors the table to which a name belongs. That evidence enters through the graph-based components.
Represent the schema as a graph
The inherited schema representation makes each table and column a node in a graph. Edges connect a table to its columns and connect primary and foreign keys that the schema identifies as related. Edge types let the graph network learn different transformations for different kinds of connection. For instance, the connection between a table and a column it owns is represented differently from a connection defined by a key relationship.
A graph convolutional network, or GCN, repeatedly updates node representations using information from adjacent nodes. At the beginning, each node has a learned embedding scaled by a relevance probability. The paper gives this initialization for the encoder GCN.
hᵥ⁽⁰⁾ = ρᵥ · rᵥ
The vector hᵥ⁽⁰⁾ is the encoder’s initial state for node v, and the superscript ⁽⁰⁾ marks the state before graph updates. The vector rᵥ is the learned embedding of the database constant at v. The scalar ρᵥ is that constant’s relevance probability. The multiplication dot here means that every component of the embedding is scaled by the same probability.
The encoder then carries out its graph updates. Each update allows a node’s representation to reflect neighboring states, and successive updates can convey evidence along paths through the graph. The final state is the representation used for a database constant.
hᵥ = hᵥ⁽ᴸ⁾
Here hᵥ is the encoded representation of node v supplied to the parser. The right-hand side is the state of that node after L rounds of graph propagation. L denotes the number of rounds, and ⁽ᴸ⁾ marks the final round. The paper describes the role of edge-specific parameters in those updates without spelling out the recurrence in its account of the base encoder.
In the predecessor, the relevance probability was determined from local links. The links were first turned into a distribution over constants for each question word.
pₗᵢₙₖ(v | xᵢ) ∝ exp(sₗᵢₙₖ(v, xᵢ))
The conditional notation v | xᵢ refers to the candidate constant v given word xᵢ. The function pₗᵢₙₖ is the linking distribution. The proportionality sign means that the exponential of the similarity score determines relative weight, with normalization over constants turning those weights into probabilities. The function exp is the exponential, and sₗᵢₙₖ(v, xᵢ) is the local linking score.
The predecessor then used the strongest such probability across the question.
ρᵥ = maxᵢ pₗᵢₙₖ(v | xᵢ)
The quantity ρᵥ is the initial relevance weight for constant v. The operator maxᵢ picks the largest value over the question positions i. The expression being compared is the linking probability for v given each word. A constant could thus receive a high weight from one compelling match. Several partial clues, or the relevance of a connected constant, could affect its representation in later graph updates but did not participate in that maximum.
Predict relevance using the question and graph together
The first addition is a separate GCN that estimates the weights used by the encoder. The distinction between the two networks is their output. The gating GCN predicts a relevance probability for each constant. The encoder GCN uses those probabilities to produce representations for decoding. Both work with the schema structure, but the new predictor gathers graph evidence before the schema embeddings are scaled for the encoder.
The gating graph includes a global node in addition to the table and column nodes. The notation v_global identifies that node. A special type of edge connects it to every database constant, and its initial embedding is randomly initialized. These connections provide short paths by which information from otherwise distant schema nodes can reach one another. The original edges still distinguish the database relationships themselves.
For each database constant, the gating network needs some account of which words it may refer to. It obtains that account by averaging the contextual vectors of the question words using links in the direction from the constant to the question.
h̄ᵥ = ∑ᵢ pₗᵢₙₖ(xᵢ | v) · eᵢ
The vector h̄ᵥ summarizes the parts of the question associated with constant v. The sum runs over positions i, and eᵢ is the contextual vector at position i. The weight pₗᵢₙₖ(xᵢ | v) is the word’s linking probability given v. The conditioning direction is important. The earlier distribution compares constants for a given word. This one weights words for a given constant.
This weighted average lets a node start with question evidence related to its own role. Two columns with identical names can still gather similar evidence at this point. Their graph neighborhoods then give the network a way to update those initially similar states differently. In the running example, the singer name column shares a table with the country column, which can carry evidence from “nation.” The method makes that relationship available to a learned relevance predictor without prescribing the conclusion it must reach.
Each initial gating state combines the constant embedding, its weighted question representation, and the earlier local relevance estimate.
gᵥ⁽⁰⁾ = FF([rᵥ ; h̄ᵥ ; ρᵥ])
The vector gᵥ⁽⁰⁾ is the gating GCN’s starting state for constant v. FF is a learned feed-forward network. The square brackets collect its input, and the semicolon inside them denotes concatenation. The inputs are rᵥ, the constant’s embedding, h̄ᵥ, its summary of relevant question words, and ρᵥ, the relevance estimate from the strongest local link. The local score remains available as evidence for the new prediction.
After propagation, a feed-forward transformation and a sigmoid convert the final state into the global relevance estimate.
ρᵥᵍˡᵒᵇᵃˡ = σ(FF(gᵥ⁽ᴸ⁾))
The quantity ρᵥᵍˡᵒᵇᵃˡ is the new probability for constant v. The vector gᵥ⁽ᴸ⁾ is its state after L rounds in the gating graph. FF maps that state to a score, and σ is the sigmoid that turns the score into a probability. The superscript “global” distinguishes the resulting estimate from the local ρᵥ used to build the gating input.
The encoder uses the new probability in place of the old one in its initialization. This is a soft selection. A small relevance probability reduces a node’s initial contribution, while a large one preserves more of its embedding. All constants remain available to the parser. The decoder can still propose a query that uses a weakly weighted element if its other evidence supports that choice.
Train the relevance gate and generate candidates
From each reference query y, the authors collect Uᵧ, the set of database constants appearing in that query. A table or column in Uᵧ serves as a positive example for relevance. Every other constant in the schema serves as a negative example for that question. The resulting loss rewards high probabilities for reference constants and low probabilities for the rest.
−∑ᵥ∈ᵁᵧ log(ρᵥᵍˡᵒᵇᵃˡ) − ∑ᵥ∉ᵁᵧ log(1 − ρᵥᵍˡᵒᵇᵃˡ)
The first sum ranges over constants v belonging to Uᵧ. The second ranges over schema constants v outside Uᵧ. The function log is the logarithm, and ρᵥᵍˡᵒᵇᵃˡ is the predicted probability of relevance. In the second sum, 1 minus that probability is the predicted probability of irrelevance. The minus signs make confident predictions in the wrong direction incur a larger loss. The membership signs ∈ and ∉ distinguish the reference constants from the other constants.
Training also uses the usual decoding objective. The reference SQL determines the sequence of grammar decisions, and the decoder learns to assign high likelihood to that sequence. Because the gate’s probabilities affect the representations used by the decoder, the gating network receives training signal through the decoding objective as well as through the explicit relevance labels. This arrangement lets the authors later ask how much the labels contribute when the architecture remains in place.
The decoder is another long short-term memory network. It expands the SQL grammar from the top down and produces an output query through successive decisions. Some decisions specify the query’s construction. Others fill a position with a table or column. The encoded question, the schema representations, and the decoder’s local linking scores provide evidence at the relevant stages. A beam retains multiple alternatives during generation so that the parser can offer complete candidates for a subsequent comparison.
Gating can improve the evidence used to generate alternatives. It still has to predict relevance without knowing which candidate the decoder will finish or which SQL operations it will choose. Each candidate supplies a more concrete object to evaluate. It reveals the set of constants the decoder actually used, which makes it possible to compare that set with the question and with other choices in the beam.
Represent the constants in a candidate
For a candidate SQL query ŷ, the authors extract the set Uŷ of database constants that it uses. The reranker receives the question x, the schema S, and this candidate. It starts from the subgraph formed by Uŷ and the global node. This retains the schema edges among the included nodes. The choice of subgraph makes the representation specific to the proposal. A different set of tables and columns gives the reranker a different graph to examine even though the question and overall schema stay the same.
For each selected constant, the initial state uses its embedding and the same kind of weighted question representation that the gate uses.
fᵥ⁽⁰⁾ = FF([rᵥ ; h̄ᵥ])
The vector fᵥ⁽⁰⁾ is the initial reranking state for constant v in the selected subgraph. FF is a feed-forward network. Within the brackets, the semicolon denotes concatenation of the constant embedding rᵥ and the question summary h̄ᵥ for that constant. This input definition contains no local relevance scalar.
After the reranking GCN has propagated information, the global node summarizes the subgraph.
fᵁŷ = fᵥ_global⁽ᴸ⁾
The notation fᵁŷ denotes the representation of the set Uŷ, and the right-hand side is the state f of the global node v_global after L updates. In the gating network the global node mainly shortened paths between schema elements. Here its final state is read out directly as a vector for the candidate’s chosen set.
This provides a candidate-level representation of the relations among selected nodes and the evidence attached to them. It has a particular blind spot. If a candidate leaves out a column that would explain an important word, that column is absent from the subgraph. A representation formed solely from the retained portion may describe what the candidate covers while giving little direct evidence about what it omitted.
Check the question for evidence of omissions
The reranker therefore builds a second representation by returning to the entire schema and asking what each question word aligns to. For this calculation, a selected node contributes its updated reranking state. An unselected node contributes its original embedding.
ϕᵥ = fᵥ⁽ᴸ⁾ if v ∈ Uŷ, and rᵥ otherwise
The vector ϕᵥ is the representation used for constant v in this alignment calculation. If v belongs to Uŷ, the selected set, it is represented by fᵥ⁽ᴸ⁾, its state after L reranking graph updates. In every other case the representation is rᵥ, the learned constant embedding. The distinction allows a question word to draw evidence from both inside and outside the candidate’s selection.
The word’s evidence is a weighted sum over all schema constants.
lᵢᵠ = ∑ᵥ∈ⱽ pₗᵢₙₖ(v | xᵢ) · ϕᵥ
Here lᵢᵠ is the alignment vector for word position i, and the superscript ϕ indicates that the sum uses the representations ϕᵥ. The sum ranges over v in V, the full set of schema constants. The weight pₗᵢₙₖ(v | xᵢ) is the linking probability of v given word xᵢ. The multiplication dot scales the vector ϕᵥ by that probability before the vectors are added.
For instance, a question word may strongly favor a column that the candidate omits. Much of its alignment vector can then come from the omitted column’s embedding. A word that favors a selected column draws more of its alignment information from a representation shaped by the chosen subgraph. This is how the architecture brings omissions into view. The weighted combination accommodates uncertainty when a word points to several plausible constants.
The alignment evidence is concatenated to the contextual vector for the word.
eᵢᵃˡⁱᵍⁿ = [eᵢ ; lᵢᵠ]
The vector eᵢᵃˡⁱᵍⁿ is the alignment-enriched representation at position i. Its components are eᵢ, the original contextual word vector, and lᵢᵠ, the schema alignment vector. The brackets with the semicolon denote concatenation. The reranker can use the word in context alongside evidence about the constants it may refer to.
The paper gives the attention score for an enriched word vector as a dot product.
(eᵢᵃˡⁱᵍⁿ)ᵀ wₐₜₜ
The superscript T transposes the vector eᵢᵃˡⁱᵍⁿ for the dot product with the learned attention vector wₐₜₜ. The result is a scalar attention score for position i. Attention over the positions produces the question-level vector eₐₗᵢᵍₙ. This aggregation lets the scorer give different importance to words depending on what they say and how they align to the schema for the candidate under review.
The resulting coverage signal is learned. It can help identify a question word whose strongest schema correspondences were excluded, but it does not require every word to contribute a distinct table or column. The example of the two mentions of “name” motivates looking at correspondences together. The implementation uses soft links, contextual word vectors, and attention to learn which patterns of coverage matter.
Score the candidates and learn their order
The reranker combines the subgraph representation and the question alignment representation into one score.
sŷ = wᵀ FF(fᵁŷ, eₐₗᵢᵍₙ)
Here sŷ is the scalar logit for candidate query ŷ, meaning its score before conversion to a probability. The feed-forward network FF takes fᵁŷ, the representation of the selected constants, and eₐₗᵢᵍₙ, the aggregate representation of question alignment. The learned vector w is transposed, as marked by T, to take a dot product with the feed-forward output.
This score focuses on which constants appear in a candidate and what the choice leaves uncovered. A candidate’s aggregation operator, for instance, does not change the selected-node input if the tables and columns are identical. The same applies to other changes that leave the set of constants intact. The decoder consequently retains an important role after generation. When the reranker ties candidates, the authors prefer the one with the better autoregressive score.
The reranker is trained separately. For training, the authors take K = 40 candidates from the decoder’s beam, where K denotes the number of candidates considered. If the reference query is present, the loss is calculated using that query and 10 randomly selected negative candidates. The objective is to minimize the negative log probability assigned to the reference query in this comparison. The paper’s overview shows that this loss does not send gradients back through the decoder’s discrete SQL outputs. The gate can learn through the decoding loss, while reranking learns to choose among the decoder’s proposals.
During testing, the reranker examines the beam’s top candidates, with K set to 10. It assigns its score to each and uses the decoder’s ordering to resolve ties. A candidate outside that list is beyond its reach. This makes the quality of the initial proposals a direct constraint on the overall procedure and gives the authors a way to evaluate generation and selection separately.
The authors report one variant that additionally represents the SQL text of each candidate. They describe its logit as follows.
sŷ = wᵀ FF(fᵁŷ, hₐₗᵢᵍₙ, h_qᵤₑᵣᵧ)
The score sŷ, learned output vector w, transpose T, feed-forward network FF, and selected-set vector fᵁŷ play the same roles as in the original score. The paper writes hₐₗᵢᵍₙ for the alignment input in this variant, in the position occupied by eₐₗᵢᵍₙ in the main design. The new vector h_qᵤₑᵣᵧ concatenates the last and first hidden states from a BiLSTM over the generated SQL. That addition lets the scorer respond to differences in SQL text even if the underlying set of tables and columns is identical.
Experiments and results
What Spider measures
The evaluation uses Spider, which places the parser in the setting of complex, previously unseen database schemas. The paper gives the dataset split sizes as 7,000 training examples, 1,034 development examples, and 2,147 test examples. The authors follow the preprocessing of their graph-based predecessor. They also make implementation changes to that predecessor and give its original and reimplemented development scores separately. The authors make the Global-GNN code available in the spider-schema-gnn-global repository.
The main metric is accuracy under the official Spider evaluation script. The authors describe its criterion as a loose exact match of queries. The score expresses how frequently the selected query matches the reference according to that script. In particular, an accuracy number reported here refers to query matching under the benchmark’s criterion. The paper also measures how frequently the reference query appears anywhere in the decoder’s candidate list. That second quantity concerns the options available to the final scorer, even when the returned query is wrong.
The authors compare results on all examples and on subsets grouped by the number of tables used in the reference SQL. SINGLE covers queries using one table. MULTI covers queries using more than one. The group labels describe the reference query, so an erroneous prediction that introduces an extra table does not move the example from one group to the other. The grouping helps examine whether changes directed at schema choices are especially effective when several tables have to be coordinated.
Hidden test results
The paper’s hidden test comparison includes SyntaxSQLNet, the earlier schema GNN, and GLOBAL-GNN. SyntaxSQLNet provides a comparison with an earlier grammar-oriented parser. The schema GNN is the direct predecessor whose graph representation and parser the authors extend. GLOBAL-GNN combines the learned relevance gate with the candidate reranker.
Text-to-SQL parsers on the Spider hidden test set by query-match accuracy
GLOBAL-GNN leads the reported comparison on the hidden test set.
The numbers
| System or setting | accuracy % |
|---|---|
| SyntaxSQLNet | 19.7 |
| Schema GNN | 39.4 |
| GLOBAL-GNN (this paper) | 47.4 |
The direct comparison on the hidden test set is between 39.4% for the schema GNN and 47.4% for GLOBAL-GNN. The development experiments give more detail about the mechanisms behind that overall result. In particular, they distinguish the gains from changes to the base implementation from the gains observed when the authors add global relevance and reranking. That distinction matters because the hidden test comparison is between the earlier reported system and the finished parser.
Development results and the multi-table split
On the development set, SyntaxSQLNet scored 18.9% overall, and the earlier schema GNN scored 40.7%. The authors’ reimplementation of the GNN reached 44.1% development accuracy. That makes 44.1% the pertinent baseline for assessing the additions against the implementation from which they start. GLOBAL-GNN reached 52.1% development accuracy.
The SINGLE and MULTI scores show where that improvement appears. On SINGLE, the reimplemented GNN reached 58.3% and GLOBAL-GNN reached 61.6%. On MULTI, the reimplementation scored 27.6% and GLOBAL-GNN scored 40.3%. The original schema GNN scored 52.2% on SINGLE and 26.8% on MULTI. The full system improved both types of development example, and the comparison with the reimplementation shows the larger gain on questions using multiple tables.
These results are consistent with the problem illustrated by the name columns. Queries that span tables offer more occasions for a local choice to look reasonable while the overall set of choices is incomplete or poorly connected. A parser that represents candidate selections together has evidence that can help in those cases. The SINGLE results show that choosing schema elements jointly can also matter within one table. Column omissions and ambiguous column names remain possible even when the reference needs no second table.
The development beam figures give a different view of the improvement. The reference query appeared in the K = 10 beam for 62.2% of development examples with the reimplementation and for 65.9 % with the full system. The full system returned a matching query on 52.1% of the development set. Together these measurements show that the generator made the correct answer available more often with global gating and that there remained cases in which the correct candidate was available but did not win. The reranker’s job concerns that second part of the pipeline.
The headline held-out result establishes the performance of the combined system under the Spider evaluation. The development comparisons are the basis for statements about the particular roles of the two additions, the effect of relevance supervision, and the difference between SINGLE and MULTI. Keeping these roles distinct also clarifies the interpretation of a beam score. A correct query in the beam is evidence that generation produced it. Choosing it requires the final scoring procedure to rank it ahead of the alternatives.
What the ablations show
Global gating and reranking each contribute
The most direct ablations remove one of the two additions while retaining the other. Removing global gating takes overall development accuracy from the full system’s 52.1% to 48.8%. Removing reranking gives 48.3%. The two results provide evidence for contributions at different stages. A better account of the schema helps before candidates are complete, and a second look at the developed candidates improves the final choice.
GLOBAL-GNN and component ablations on Spider development query-match accuracy
The complete system ranks highest, and removing either main component lowers accuracy.
The numbers
| System or setting | accuracy % |
|---|---|
| Without reranking | 48.3 |
| Without global gating | 48.8 |
| Without relevance loss | 50.1 |
| Without alignment representation | 50.8 |
| GLOBAL-GNN (this paper) | 52.1 |
The beam measurements help separate those effects. With reranking disabled, the beam coverage reported for development is 65.9%, the same coverage level as for the full system. Reranking operates on the finished proposals, so removing it changes the decision about which query to return. With global gating removed, coverage is 62.2%. This change occurs upstream. The set of queries available for ranking is less likely to include the reference when the globally informed gate is absent.
The table-count split adds detail. Without global gating, the system reached 60.9% on SINGLE and 33.8% on MULTI. Without reranking, it reached 58.1% on SINGLE and 36.8% on MULTI. The complete system reached 61.6% and 40.3% on those development subsets. In this comparison, the MULTI result is more sensitive to removal of global gating. The SINGLE result is more sensitive to removal of reranking. Both subsets benefit from the full pipeline, and the different patterns show why overall accuracy alone gives an incomplete account of the components.
The ablations test the two additions in the context of this parser. They also reveal why their effects cannot be inferred just by looking at whether top-ranked accuracy rises. The gate can change which SQL alternatives survive generation. The reranker can change which of those alternatives is returned. The same improvement in final accuracy could arise through either route. The beam statistic provides evidence about the first route, while comparisons between reranked and original outputs help assess the second.
Relevance supervision helps the gate
The authors keep the global gating architecture and remove the relevance loss in another experiment. This leaves the decoding objective to guide the gate through the representations it produces for the decoder. The resulting system scores 50.1% on development, with 64.8% beam coverage. Its accuracy is 60.9% for SINGLE and 36.6% for MULTI.
The change isolates the value of explicitly teaching the gate which constants occur in the reference query. The network still has access to the question, local links, and schema connections. It can still learn from whether its choices help the decoder. The improvement from adding the relevance loss shows that asking the intermediate component to predict reference membership contributes beyond the signal it receives from query generation. The outcome supports the relevance training objective as part of the overall system. The reported comparison measures the resulting query accuracy and beam coverage, so it does not quantify how well each individual probability tracks actual relevance.
This is informative because the two training objectives address related but distinct errors. A wrong grammar decision can make the entire SQL query wrong even when the gate identified appropriate tables and columns. Conversely, the right query can receive a high score without every relevance estimate being especially sharp. Direct membership labels give the gating network feedback specifically about the tables and columns present in the reference.
The alignment representation contributes information about coverage
Another ablation removes the question-alignment vector from the reranker. The reranker can still score the subgraph of constants a candidate selected. The removal takes development accuracy to 50.8%, with 60.7% on SINGLE and 38.3% on MULTI. The reported beam coverage is 65.9%. The candidates are generated upstream in the same way, and the altered score changes how the procedure chooses among them.
The result supports the authors’ decision to revisit the question and look beyond the selected subgraph. A subgraph representation can capture relations among chosen elements. The alignment vector gives the scorer an additional route to detect that a question word points strongly towards an excluded column or table. The observed improvement concerns that vector as a whole. The experiment does not assign separate effects to its contextual word input, its link-weighted sum, and the attention that combines information across positions.
The authors’ qualitative analysis illustrates the difference between coverage and precision. In one recurring pattern, the baseline missed a table join or a column associated with part of the question. The full system produced a query that covered the missing material. In the other pattern, a strong lexical resemblance pulled an unrelated table into the baseline’s query. The improved parser avoided the extra table. The analysis identifies both kinds of correction without reporting how frequent each is across all development examples. The distinction matters because raising coverage alone could encourage a query to include extra schema elements, while preferring smaller selections could leave genuine parts of the question unaddressed.
Scoring the whole SQL string was weaker in this setup
The authors also tried giving the reranker an encoding of the generated SQL text in addition to the selected subgraph and the alignment input. This query reranker reached 47.8% overall on development. Its SINGLE accuracy was 55.3%, and its MULTI accuracy was 38.3%. The standard GLOBAL-GNN reranker performed better overall and on both subsets. The query variant had 65.9% beam coverage, so its lower overall score concerns its choices from the available proposals.
The motivation for the variant is clear from the original reranker’s input. Two queries can use identical tables and columns and differ in the logical operation they apply. An encoder of the query text gives the reranker a chance to distinguish them. In the authors’ inspection, many errors introduced by the variant were small operational mistakes, such as preferring minimum where maximum was needed. For this architecture and training setup, the evidence supports letting the reranker concentrate on schema choices and leaving finer SQL decisions to the decoder.
That comparison is narrower than a general conclusion about whether final scorers should consider operations. The experiment adds one particular sequence representation of the output query. Its result shows that this extra representation did not improve the authors’ candidate scorer. It leaves open whether a scorer designed around specific SQL decisions, or trained to coordinate them with schema selection, would behave differently. The authors identify such coordination as a possible direction when discussing the errors that remain.
Oracle conditions show room for both stages to improve
The authors examine hypothetical settings in which part of the task is solved using reference information. Their prose describes a perfect gate that gives probability 1.0 exactly to constants appearing in the reference query. Under the perfect-gating condition they report development accuracy of 63.2%. Adding perfect reranking raises the reported figure to 73.5%. The results are diagnostic because both conditions give the procedure information unavailable to the deployed parser.
The development table separately lists an Oracle Relevance row with 56.4% accuracy and 73.5% beam coverage. The paper’s discussion gives 63.2% for the perfect-gating condition without specifying how it corresponds to the table’s 56.4% accuracy. They are separate reported figures. The common 73.5% indicates the attainable selection accuracy described for perfect reranking and the beam coverage listed in the table’s oracle row. The beam figure has a clear operational meaning. A perfect selector can return the reference only when the generator has put it among the candidates.
The gap between the ordinary system’s results and these oracle figures shows why the authors treat gating and reranking as complementary. Better relevance information can improve the proposals and increase the scope for a better selector. Better ranking can exploit correct proposals that the ordinary scorer passes over. Even under the oracle conditions, candidate generation remains a limit. Supplying the right constants still leaves the decoder responsible for assembling a query.
The authors examine this issue directly in their error analysis. Among errors in which the correct query was in the beam, 44.4% used the right set of database constants in the erroneous output. Most errors within that category involved local decisions such as a minimum or maximum operation, with larger structural mistakes accounting for the rest. The denominator is important. The figure describes errors where the correct query was available for selection, rather than all development examples or all parser errors. Other examined mistakes involved missing or extra columns and tables, particularly in complex queries.
Limitations
Limits the authors identify
The authors identify a division of responsibility between schema selection and the rest of SQL construction. Their improvements target the grounding problem of choosing tables and columns in a new database. Even perfect identification of those constants leaves open how to combine them, what conditions to apply, and which operation to use. The error analysis makes this limitation concrete because a substantial share of the examined errors already had the correct set of constants. Improving the global choice of schema elements cannot by itself resolve a distinction like minimum versus maximum when both queries use the same column.
The standard reranker takes a set as its principal description of the SQL candidate. This representation treats a constant as present whenever it occurs in the query. It does not encode where that constant was used or the logical operation applied to it. If two candidates select the same constants, the authors’ reranking inputs give the same account of their selection. The paper explicitly notes ties and gives the decoder’s scores the deciding role in those cases.
The authors also identify larger structural mistakes alongside the local ones. Some candidates use the correct schema elements but assemble an incorrect SQL structure. The attempted query-text variant offers evidence about one way of broadening the reranker. Its lower development accuracy shows a difficulty of this particular extension. The authors’ suggestion that future work could decide over schema choices and SQL tokens jointly remains an open direction in the paper.
The beam creates another explicit limit. A correct query that received a low rank during generation can still be recovered by reranking. It cannot construct a new one. The ordinary beam measurements and the oracle results quantify this constraint for the reported setup. A perfect selector can reach the accuracy allowed by the proposals it receives, and a missing reference query requires a change to generation or to which candidates are retained.
The relevance probabilities are also intentionally soft. A good gate can encourage the encoder to use the right tables and columns while still allowing the decoder to depart from that preference. This flexibility is useful when an estimate is uncertain. It also means the gate offers no guarantee that the final SQL will contain the constants it favors or exclude those it considers irrelevant. The oracle-gating result is consistent with this distinction. Correct relevance information still has to be turned into the right sequence of SQL decisions.
Limits of the evaluation and evidence
The comparisons concern Spider and the paper’s query-matching procedure. Spider supplies the unseen-schema setup needed to evaluate the authors’ central problem. The reported results establish improvement under that setup. The paper does not present separate experiments across other databases benchmarks or across other implementations of zero-shot parsing. The authors propose that the two techniques could be transferred. The empirical evidence here comes from adding them to their graph-based predecessor.
A query-match score also has a particular interpretation. It records agreement with the reference according to the official evaluator’s criterion. An increase shows that the parser returned the expected SQL more often on that measure. It gives no separate estimate of how often users would consider the answers satisfactory or how often alternative formulations would produce the same results on the database. That distinction is especially relevant when assessing claims about a natural-language interface beyond the benchmark.
The SINGLE and MULTI comparison is informative about the paper’s motivating problem, though table count captures only one aspect of query complexity. A single table may support several plausible columns and operations. Two multi-table queries can also place very different demands on the parser. The larger improvement on MULTI establishes an association with that benchmark category. The qualitative examples illustrate how coverage and precision can improve, while the reported analysis does not allocate the multi-table gain among joins, better column selection, and other interacting decisions.
The relevance target comes from a particular reference SQL query. This gives the gate a clear supervisory signal, but a relevance label means that a constant occurs in that reference. It is not a separately judged account of every schema element a reader could consider relevant. A related column can be informative when reasoning about the question and still be absent from the query. The architecture partly accommodates this distinction because the graph can use neighboring information and the weights are soft. The reported relevance ablation evaluates the downstream usefulness of reference membership as a training target.
Some mechanisms are tested together. The global-gating ablation evaluates a component that combines local evidence, question representations, schema propagation, and a global node. Removing it gives evidence for the package of changes. It does not reveal how much would be lost by removing only the global node or by changing particular edge types. Similarly, the coverage ablation evaluates a complete representation built from local links, selected and unselected node states, word context, and attention. Its improvement supports adding the representation to the reranker at the level tested.
The reranker’s training cases are also conditioned on successful search. It compares a reference query with sampled negatives when the reference is in the training beam. At test time, it scores a smaller list of candidates. This is appropriate to its role as a selector, and it limits what that training objective addresses. If the generator repeatedly misses the reference for a type of question, the reranker does not learn to supply that missing query. The reported experiments do not establish how performance would change under different beam sizes or negative-sampling choices.
Finally, the differing accuracy figures in the oracle table and discussion limit how precisely the headroom can be assigned to an individual oracle setting. The paper gives the ordinary component comparisons clearly enough to assess the contributions of gating and reranking. Its oracle figures are best read as evidence that better relevance information and candidate selection leave room for improvement under the authors’ generation procedure.
What came after
The later work that cites this paper approaches several of the same decisions from different points in the parsing process. Some studies concentrate on how to represent a question alongside a schema. Others focus on the separation between selecting schema elements and constructing SQL, or place text-to-SQL inside a wider approach to structured data. Their stated topics allow these connections to be traced at the level of the problems they take up. A citation alone does not establish that a later parser implements the same gate or reranking procedure.
RAT-SQL takes up two closely related issues in its stated design, relation-aware schema encoding and linking. Both were central to GLOBAL-GNN. One asks how the representation of a column or table can reflect its relations to other schema elements. The other asks how the wording of a question points to those elements in an unfamiliar database. The relation-aware formulation keeps attention on the evidence needed to identify a constant in context. Its emphasis is especially close to the first stage of GLOBAL-GNN, where links based on the question become more informative through the representation of schema relations. RAT-SQL
LGESQL pursues graph-based text-to-SQL parsing through line-graph enhancement and a mixture of local and non-local relations. Its stated focus continues the question of which relations should be available to a parser when it represents schema elements. GLOBAL-GNN uses ordinary schema edges alongside a global node that shortens paths across the graph. LGESQL’s focus on local and non-local relations places the choice of graph representation itself at the center of the problem. The connection concerns the reach of structural evidence, including when the elements that need to inform each other are distant in the original schema graph. LGESQL
RESDSQL explicitly separates schema linking from skeleton parsing. Its subject is closely related to the division that GLOBAL-GNN’s experiments expose. Choosing which tables and columns a question refers to and deciding the shape of the SQL are distinct sources of difficulty. GLOBAL-GNN assigns additional computation to the first and relies on a grammar decoder for the second. RESDSQL makes the decoupling of schema linking and SQL skeleton parsing its stated approach. That gives the distinction an architectural role in a later line of work. RESDSQL
TaBERT addresses the joint understanding of text and tables through pretraining. Its emphasis connects to the problem of making the interaction between a question and tabular structure available before a final SQL decision. GLOBAL-GNN builds that interaction using word-to-constant links and a schema graph within the parser. TaBERT places joint textual and tabular understanding at the representation-learning stage. TaBERT
Structure-Grounded Pretraining for Text-to-SQL likewise puts structural grounding into pretraining. The phrase identifies a different point at which to address a familiar difficulty. A parser facing a new schema needs representations that support connections between question wording and structured elements. GLOBAL-GNN uses supervised relevance estimates and candidate scoring to act on these connections. The later work’s stated focus is to build structure-grounded representations through pretraining for text-to-SQL. Structure-Grounded Pretraining for Text-to-SQL
Bridging Textual and Tabular Data for Cross-Domain Text-to-SQL Semantic Parsing takes up the connection between question wording and the database in the cross-domain setting. That setting preserves the difficulty that motivated the original paper. A parser must ground the question in schema items it could not have learned as a fixed inventory of answers during training. The later work frames the task around bringing textual and tabular information together. This places the interface between the words and the database at the center of cross-domain parsing. Bridging Textual and Tabular Data
The study of robustness to synonym substitution focuses on a closely related source of uncertainty in the question. GLOBAL-GNN starts from local links that include lexical similarity, then brings in schema and question context when local evidence is ambiguous. A synonym substitution changes the wording a parser receives while targeting a similar meaning. The later robustness study makes this kind of variation the object of investigation. Its stated task connects directly to the question of how reliably a parser grounds an expression when the words available for matching change. Towards Robustness of Text-to-SQL against Synonym Substitution
UnifiedSKG places grounding in a wider setting by treating structured knowledge grounding as a unified, multitask, text-to-text problem. GLOBAL-GNN studies one particular expression of that problem, where the structures are database schemas and the outputs are SQL queries. UnifiedSKG’s stated scope broadens the setting in which systems have to connect language to structured information. The relationship is at the level of grounding across a structured input, with schema selection in text-to-SQL as a concrete instance. UnifiedSKG
Across these approaches, the distinction made visible by the original experiments remains useful for reading what each study sets out to change. Improvements to linking and schema representation address the evidence available for choosing database elements. Separating schema linking from SQL skeleton parsing addresses how those choices relate to query construction. Studies of lexical robustness ask how stable the grounding is when the words change. The original paper supplies a concrete case in which the gain from better grounding can be measured independently of the SQL decisions that remain difficult.
Cite
Cite as Ben Bogin, Matt Gardner and Jonathan Berant. 2019. Global Reasoning over Database Structures for Text-to-SQL Parsing. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP).
@inproceedings{bogin2019global,
title = {{Global Reasoning over Database Structures for Text-to-SQL Parsing}},
author = {Ben Bogin, Matt Gardner and Jonathan Berant},
booktitle = {Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)},
year = {2019},
doi = {10.18653/v1/d19-1378},
url = {https://doi.org/10.18653/v1/d19-1378}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/bogin-2019-global-reasoning-over-database-structures/