Leveraging Explicit Lexico-logical Alignments in Text-to- SQL Parsing (2022)

Abstract: Text-to-SQL aims to parse natural language questions into SQL queries, which is valuable in providing an easy interface to access large databases. Previous work has observed that leveraging lexico-logical alignments is very helpful to improve parsing performance. However, current attention-based approaches can only model such alignments at the token level and have unsatisfactory generalization capability. In this paper, we propose a new approach to leveraging explicit lexico-logical alignments. It first identifies possible phrase-level alignments and injects them as additional contexts to guide the parsing procedure. Experimental results on \textsc{Squall} show that our approach can make better use of such alignments and obtains an absolute improvement of 3.4% compared with the current state-of-the-art.

## introduction text-to-sql parsing is the task of mapping natural language questions to executable sql queries on relational databases @xcite . it provides an easy way for common users unfamiliar with query languages to access large databases and has attracted great attention. recently, lexicological alignments, which align question phrases to their corresponding sql query fragments, have been proved to be very helpful in improving parsing performance @xcite . as shown in figure 1 , the token "competitor" should be aligned to "c1" in the sql query. to capture such alignments, several attention-based models were proposed @xcite @xcite , which employ the attention weights among tokens to indicate the alignments. specifically, they use an attention module to perform schema linking at the encoding stage @xcite , and may use another attention to align each output token to its corresponding input tokens at the decoding stage @xcite . table: athletics at the 1932 summer olympics -men's 50 kilometres walk name (c1) nationality (c2) time (c3) … paul sievert germany 5:16:41 … ernie crosbie united states 5:28:02 … bill chisholm united states 5:51:00 … … … … … question: sql query: ? select which the longest had time competitor from united states c1 from w where @xmath0: an example from squall. alignments belonging to the same type are marked with the same color. however, we argue that the attention mechanism is not an appropriate way to capture and leverage lexico-logical alignments. it mainly has the following two problems. first, the standard attention can only model alignments at the token level rather than the phrase level, while there are many multi-granular, non-continuous alignments in the text-to-sql task. for the example in figure 1 , "order by . . . limit 1" is a sql keyword pattern representing a superlative operation. however, the standard attention module can only align "order", "by", "limit", and "1" to "the longest" token by token, rather than regarding them as a whole. it may confuse the decoder and lead to the failure to generate this pattern correctly @xcite . second, traditional attentionbased approaches are prone to overfitting the training data, which is harmful to the model's generalization capability. it is not only the domain generalization @xcite but also the compositional generalization @xcite . specifically, the former refers to the generalization across different databases, while the latter refers to the ability to generate new structures composed of seen components. to solve the aforementioned problems, we propose a neural parsing framework to leverage explicit lexico-logical alignments. @xcite have pointed out that if we align question tokens to columns or values in databases before parsing, it will help to improve the model's generalization among different domains (databases). motivated by this, our framework consists of two steps. specifically, we first implement a simple model to obtain possible lexico-logical alignments before parsing. while in the second step, we inject such alignments into a standard seq2seq parser by treating them as additional contexts, similar to "prompt information" or "evidence" in machine reading comprehension @xcite @xcite . moreover, to alleviate the negative effects on the parser caused by noise alignments, we propose a data augmentation method that adds noisy alignments during the training procedure. experimental results on an open-released dataset, squall @xcite , show that our framework achieves state-of-the-art performance and obtains an absolute improvement of 3.4% compared with existing attention-based models. ## conclusion in this paper, we propose a neural parsing framework to leverage explicit lexico-logical alignments by treating them as additional contexts. moreover, to alleviate the negative effects on the parser caused by noise alignments, we add noisy alignments during training inspired by data augmentation. experimental results on squall show that our framework achieves state-of-the-art performance compared with existing attention-based models.