Edit model card

Paper

NatSight: A framework for building domain agnostic Natural Language Interface to Databases for next-gen Augmented Analytics

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. 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 and fine-tune as sequence-to-sequence task.

Using Transformers🤗

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

$ 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}                                                  
    } 
    ```
Downloads last month
6
Safetensors
Model size
139M params
Tensor type
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Dataset used to train C5i/NatSight-bart-base-wikisql