File size: 5,638 Bytes
8560eef a44ad4f dfc6249 8560eef b94f5c0 8560eef a44ad4f 8560eef a44ad4f 8560eef a44ad4f 8560eef 6dcd35c dcdb28c 8560eef 46dc28a 8560eef 46dc28a 8560eef a44ad4f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
---
language:
- en
license: apache-2.0
tags:
- NatSight-AdpSeq2Seq
- Text2SQL
datasets:
- wikisql
widget:
- text: "What was the number of race that Kevin Curtain won? </s> c0 | number <eom> v4 | Kevin Curtain </s> c0 | No <eom> c1 | Date <eom> c2 | Round <eom> c3 | Circuit <eom> c4 | Pole_Position <eom> c5 | Fastest_Lap <eom> c6 | Race_winner <eom> c7 | Report"
---
## Paper
## [NatSight: A framework for building domain agnostic Natural Language Interface to Databases for next-gen Augmented Analytics](https://dcal.iimb.ac.in/baiconf2022/full_papers/2346.pdf)
Authors: *Rohit Sroch*, *Dhiraj Patnaik*, *Jayachandran Ramachandran*
## Abstract
In modern organizations, a large volume of customer, transactional, and operational data is stored in relational database management systems (RDBMS). It provides scalability and agility for various business use cases. However, the interaction between these databases and business users is limited as users often lack the knowledge of query languages such as SQL and they need to rely on technical experts to interact with the database for curating insights \& analytics. Recent advances in augmented analytics platforms have enabled business users to engage with data in natural language and consume insights in the form of data tables and charts. There are still limitations as the experience is still suboptimal.
The development of natural language interfaces to databases has long been a challenge as previous approaches rely on a considerable amount of human-labeled data for domain adaptation. Moreover, most interfaces provide a constrained environment and do not allow the users to freely and naturally interact with data.
In this work, we propose our framework for building domain-agnostic natural language (NL) interfaces to relational databases (NLIDBs) in few-shot and zero-shot scenarios. Also, recent advancements in the area of Transfer learning allowed us to leverage Transformer-based pre-trained language models (PLMs), resulting in various real-world applications in functional areas like CRM, Supply Chain, Ecommerce, Health Care, etc. for getting real-time insights. More specifically, our framework works in the following ways: First, it provides graph focused auto-suggestions to complete the natural language queries based on the graph representation of database schema, and Second, it uses an adaptive sequence-to-sequence translator model that translates natural language queries to corresponding SQL queries. Furthermore, a feedback loop is used to improve the system based on active learning.
Experiment results on benchmark datasets show that our approach achieves a state-of-the-art performance and can be effective in the few-shot and zero-shot scenarios for domain-agnostic applications.
*Sroch, R. & Patnaik, D. & Ramachandran, J. (2022). [NatSight: A framework for building domain agnostic Natural Language Interface to Databases for next-gen Augmented Analytics](https://dcal.iimb.ac.in/baiconf2022/full_papers/2346.pdf).
9th International Conference on Business Analytics and Intelligence, IIM Banglore (BAI Conf’22).*
## NatSight-bart-base-wikisql
For weights initialization, we used [facebook/bart-base](https://huggingface.co/facebook/bart-base) and fine-tune as sequence-to-sequence task.
## Using Transformers🤗
```python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("course5i/NatSight-bart-base-wikisql")
model = AutoModelForSeq2SeqLM.from_pretrained("course5i/NatSight-bart-base-wikisql")
# define input
raw_nat_query = "What was the number of race that Kevin Curtain won?"
query_mention_schema = "c0 | number <eom> v4 | Kevin Curtain"
table_header_schema = "c0 | No <eom> c1 | Date <eom> c2 | Round <eom> c3 | Circuit <eom> c4 | Pole_Position <eom> c5 | Fastest_Lap <eom> c6 | Race_winner <eom> c7 | Report"
encoder_input = raw_nat_query + " </s> " + query_mention_schema + " </s> " + table_header_schema
input_ids = tokenizer.encode(encoder_input, return_tensors="pt", add_special_tokens=True)
generated_ids = model.generate(input_ids=input_ids, num_beams=5, max_length=128)
preds = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True) for g in generated_ids]
output = preds[0]
print("Output generic SQL query: {}".format(output))
# output
"SELECT COUNT(c0) FROM TABLE WHERE c4 = v4"
```
## Intended uses & limitations
More information needed
### Training hyperparameters
Please take a look at the `training_args.bin` file
```python
$ import torch
$ hyperparameters = torch.load(os.path.join('training_args.bin'))
```
### Dev/Test results
|| |NatSight-AdpSeq2Seq (BART-base) | |
|:----|:----|:----|:----|
||Dev ||Test |
|Acc-(Logical form) %|Acc-(Execution) %|Acc-(Logical form) %|Acc-(Execution) %|
|83.38|87.83|84|86.39|
### Framework versions
- Transformers >=4.8.0
- Pytorch >=1.6.0
- TensorFlow >=2.5.0
- Datasets >=1.10.2
- Tokenizers >=0.11.6
If you use these models, please cite the following paper:
```
@article{article,
author={Sroch, R. & Patnaik, D. & Ramachandran, J},
title={NatSight: A framework for building domain agnostic Natural Language Interface to Databases for next-gen Augmented Analytics},
journal={9th International Conference on Business Analytics and Intelligence, IIM Banglore (BAI Conf’22)},
day={17},
year={2022},
month={Dec},
url = {https://dcal.iimb.ac.in/baiconf2022/full_papers/2346.pdf}
}
``` |