Natural Language Response Generation from SQL with Generalization and Back-translation (2020)

Abstract: Generation of natural language responses to the queries of structured language like SQL is very challenging as it requires generalization to new domains and the ability to answer ambiguous queries among other issues. We have participated in the CoSQL shared task organized in the IntEx-SemPar workshop at EMNLP 2020. We have trained a number of Neural Machine Translation (NMT) models to efficiently generate the natural language responses from SQL. Our shuffled back-translation model has led to a BLEU score of 7.47 on the unknown test dataset. In this paper, we will discuss our methodologies to approach the problem and future directions to improve the quality of the generated natural language responses.

## introduction natural language interfaces to databases (nlidb) has been the focus of many research works, including a shared track on the conversational text-to-sql challenge at emnlp-intexsempar 2020 @xcite . we have focused on the second task, natural language response generation from sql queries and execution results. for example, when the sql query "select dorm name from dorm" is present, a possible response by the system could be "this is the list of the names of all the dorms". the ideal responses should demonstrate the results of the query, present the logical relationship between the query objects and the results, and be free from any grammatical error. another challenge for this task is that the system needs to be able to generalize and do well on the sql queries and the database schema which it has never seen before. ## related works many existing papers focus on text to sql generation like @xcite and @xcite which emphasize self-attention and reinforcementlearning-based approaches. the problem of generating natural language responses from sql is that this specific area is relatively under-researched, but we have tried to come up with probable solutions in this shared task. @xcite inspired us to generalize sql keywords for better response generation with improvement in generalization. we have employed back-translation, used by @xcite and @xcite , in order to increase the bleu score. we were also motivated by the linguistic generalization results pointed out by @xcite and @xcite where the lemma and the part-of-speech tag are added to the natural language dataset for better generalization. although we did not include it in our final model due to challenges in removing the linguistic factors, this approach offers a potential future in the generalization of the generated natural language responses. ## pre-processing methods we decided to take the neural machine translation (nmt) approach, where the sql queries with the execution results are regarded as the source, and the natural language, more specifically english, responses are seen as the target. we chose seq2seq as our baseline model. after several attempts of training and parameter tuning, we were able to obtain a baseline bleu score. in order to further improve the bleu score, first, we came up with the idea of sql keyword generalization. sql keyword generalization is a preprocessing method we applied to the input data (i.e. the sql queries with the execution results). we original keywords generalization union, intersection, except set and, or logic exists, unique, in nest any, all range avg, count, sum, max, min agg the remaining common sql keywords are difficult to be grouped with other ones. for example, group by and having have distinct meanings and work differently as they are followed by nonidentical elements. group by is followed by a "grouping-list", usually an attribute of a table, while having is followed by a "group-qualification", usually a comparison involving an operator. therefore, those keywords are kept as they are in the input data. moreover, the operators are also not generalized since >, ≥, <, ≤ are used to compare numerical values only, @xmath0, like strings. overall, the reason we applied this sql keyword generalization pre-processing is to avoid situations where certain common keywords are seen only for a few times or even never seen in the training data set, then the trained model would react poorly to those keywords in the test data set by pulling words from the vocabulary almost randomly. ## shuffled back-translation another idea we utilized to improve the bleu score is the iterative back-translation as described in @xcite and @xcite . back-translation is a simple way of adding synthetic data to the training model by training a targetto-source model, then generating a synthetic source dataset using a monolingual corpus on the target side. the synthetic source dataset and the provided target dataset are augmented to the training datasets to re-train the model. since no monolingual corpus was provided in our case, we split the original dataset. to address any potential bias, we shuffled the dataset before splitting so that the created monolingual dataset is free from bias. we also tried a variant of back translation called cyclic translation. the idea simply repeats the step of back-translation. after generating the synthetic source dataset from the provided target dataset, that dataset is used as input to the baseline source-totarget model to generate the synthetic target dataset. the synthetic source dataset and synthetic target dataset are augmented to the training datasets to train the model once again. the shuffled back-translated model with a high drop-out rate and more number of training steps led to the highest bleu score on the development dataset as reported in section 5. ## experiment and results a lot of diverse models have been trained for our experiments as enumerated below which have been labeled as follows: the other parameters are set to the default tensorflow nmt values. then, we came up with the idea of sql keyword generalization and implemented this idea. it turned out to be wonderful and improved the bleu score significantly (from 7.60 to 9.72). next, we focused on other possible pre-processing techniques that we could apply. we initially were considering four methods: tokenization, true-casing, linguistic factorization, and byte pair encoding. according to our testing, byte pair encoding, and the combination of these two methods degraded the bleu score. linguistic factorization led to high bleu scores but the removal of the linguistic factors from the generated response again reduced the bleu score. tokenization also degrades the performance of the model. after carefully observing the given dataset, we found that it has already been tokenized, so further tokenization is unnecessary. in the end, sql keyword generalization and true-casing are the two pre-processing techniques that we apply to the model. afterwards, we started to think about the steps in the training process that we could improve. we implemented back-translation, and it increased the bleu score. however, we found this method is likely to introduce an overfitting issue. to be more specific, since we were not given any test data or any dataset analogous to a monolingual corpus, we split the given ground truth file for the development set into two files and used them (one as our "development" ground truth and the other as our "test" ground truth) for the external evaluation during the training. the model achieved a much higher bleu score on our "development" ground truth than previously recorded but the bleu score on our "test" ground truth decreased in comparison to that previously recorded. then, we came up with three ways to deal with this issue. the first one was the cyclic translation where no extra data (i.e. the monolingual data) is introduced in the training. this new way of training did help with the overfitting issue with a higher bleu score on our created "test" dataset but failed to improve the bleu score on the given development set. the second way was to shuffle the monolingual data used in the back-translation. it solved the overfitting issue but did not achieve a higher bleu score on the development data either. the last way was to change the values for certain hyper-parameters. for instance, we increased the dropout rate from 0.4 to 0.5 to strengthen regularization. accordingly, we also increased the number of training steps from 12000 to 20000. we applied the hyper-parameter changes to all three training methods, the original back-translation, cyclic translation, and shuffled back-translation. in the end, the shuffled back-translation model with the new hyperparameter settings and the two pre-processing practices achieved the highest bleu score on the development set. ## conclusion our submitted shuffled back-translation with a drop-out rate of 0.5 and 20000 training steps on tensorflow nmt gives a bleu score of 7.47 on the unknown testing dataset and a bleu score of 12.12 on the development dataset. a further conclusion can be drawn once the grammar and the logical consistency rate (lcr) scores are released by the organizers. it can be observed that shuffled back-translation with a higher drop-out rate gave a high bleu score on the development dataset compared to the baseline or the back-translated model with a lower drop-out rate. this suggests that the shuffling of the dataset before back-translation can potentially address the issue of any bias in the datasets. the improved results with increased dropout suggest that regularization has been effective in this experimental setting. the idea of cyclic translation deserves further exploration. generalization may be improved on the natural language responses by developing an improved variant of the linguistic factoring approach. the collection of additional training data can also be useful to increase the bleu score on the unknown test dataset.