Answers.Body: <p>BERT (Bidirectional Encoder Representations from Transformers):
  BERT is a powerful pre-trained language model developed by Google. It can be fine-tuned for specific tasks, including natural language query understanding. BERT can capture the context and relationships between words in a sentence, making it effective for understanding complex queries.</p>
  <p>T5 (Text-to-Text Transfer Transformer):
  T5 is a versatile language model that frames all NLP tasks as text-to-text tasks. It can be used for natural language query understanding by training it to convert user queries into corresponding SQL statements.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-24T16:55:40.917Z
Answers.LastActivityDate: 2024-01-24T16:55:40.917Z
Answers.UserDisplayName: Springs
Body: <p>We want to build an AI Chatbot, that has access to our DB schema and the data (it is a RDBMS system) and can answer complex questions around this data. Few examples like -</p>
  <ul>
  <li>What was the most expensive IT purchase in last 6 months</li>
  <li>Which purchase category has most spikes in spend over last one month</li>
  <li>which department has upward spend pattern in last 3 months</li>
  </ul>
  <p>What we have tried -</p>
  <ul>
  <li>tried a few nl2sql models</li>
  <li>tried openai APIs to convert the question to a SQL</li>
  </ul>
  <p>What we want to achieve -</p>
  <ul>
  <li>we want to pre-train the model with the database schema, so that building a SQL is not a guesswork and model exactly knows how the DB looks like</li>
  <li>we don't want to send the DB schema with each prompt (typically how it is done in nl2sql or openai), since our DB schema is huge and complex and sending it with each prompt will exhaust the context length</li>
  </ul>
  <p>Questions -</p>
  <ul>
  <li>Is this a problem statement that can be solved by AI models?</li>
  <li>If yes, where we should start?</li>
  </ul>
  <p>Any direction/suggestion would be highly appreciated. Thanks in advance.</p>
  
Tags: <natural-language-processing>
Title: What would be the best AI model to query a database in natural language?
UserDisplayName: Atanu Roy
ThreadText: # What would be the best AI model to query a database in natural language?
  
  (Asked by: username_0 on 2023-12-15)
  
  We want to build an AI Chatbot, that has access to our DB schema and the data (it is a RDBMS system) and can answer complex questions around this data. Few examples like -
  
  * What was the most expensive IT purchase in last 6 months
  * Which purchase category has most spikes in spend over last one month
  * which department has upward spend pattern in last 3 months
  
  What we have tried -
  
  * tried a few nl2sql models
  * tried openai APIs to convert the question to a SQL
  
  What we want to achieve -
  
  * we want to pre-train the model with the database schema, so that building a SQL is not a guesswork and model exactly knows how the DB looks like
  * we don't want to send the DB schema with each prompt (typically how it is done in nl2sql or openai), since our DB schema is huge and complex and sending it with each prompt will exhaust the context length
  
  Questions -
  
  * Is this a problem statement that can be solved by AI models?
  * If yes, where we should start?
  
  Any direction/suggestion would be highly appreciated. Thanks in advance.
  
  **Tags:** natural-language-processing
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-24. Score: 0
  
  BERT (Bidirectional Encoder Representations from Transformers):
  BERT is a powerful pre-trained language model developed by Google. It can be fine-tuned for specific tasks, including natural language query understanding. BERT can capture the context and relationships between words in a sentence, making it effective for understanding complex queries.
  
  T5 (Text-to-Text Transfer Transformer):
  T5 is a versatile language model that frames all NLP tasks as text-to-text tasks. It can be used for natural language query understanding by training it to convert user queries into corresponding SQL statements.
  
  
  ---
  
  