HusnaManakkot commited on
Commit
d40fcf6
1 Parent(s): a970b77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,8 +3,8 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
  from datasets import load_dataset
4
  from difflib import get_close_matches
5
 
6
- # Load the WikiSQL dataset
7
- wikisql_dataset = load_dataset("wikisql", split='train') # Increase the number of examples for better matching
8
 
9
  # Load tokenizer and model
10
  tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL")
@@ -17,7 +17,7 @@ def find_closest_match(query, dataset):
17
 
18
  def generate_sql_from_user_input(query):
19
  # Find the closest match in the dataset
20
- matched_query = find_closest_match(query, wikisql_dataset)
21
  if not matched_query:
22
  return "No close match found in the dataset.", ""
23
 
@@ -33,8 +33,8 @@ interface = gr.Interface(
33
  fn=generate_sql_from_user_input,
34
  inputs=gr.Textbox(label="Enter your natural language query"),
35
  outputs=[gr.Textbox(label="Matched Query from Dataset"), gr.Textbox(label="Generated SQL Query")],
36
- title="NL to SQL with T5 using WikiSQL Dataset",
37
- description="This model finds the closest match in the WikiSQL dataset for your query and generates the corresponding SQL."
38
  )
39
 
40
  # Launch the app
 
3
  from datasets import load_dataset
4
  from difflib import get_close_matches
5
 
6
+ # Load the Spider dataset
7
+ spider_dataset = load_dataset("spider", split='train[:100]') # Increase the number of examples for better matching
8
 
9
  # Load tokenizer and model
10
  tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-wikiSQL")
 
17
 
18
  def generate_sql_from_user_input(query):
19
  # Find the closest match in the dataset
20
+ matched_query = find_closest_match(query, spider_dataset)
21
  if not matched_query:
22
  return "No close match found in the dataset.", ""
23
 
 
33
  fn=generate_sql_from_user_input,
34
  inputs=gr.Textbox(label="Enter your natural language query"),
35
  outputs=[gr.Textbox(label="Matched Query from Dataset"), gr.Textbox(label="Generated SQL Query")],
36
+ title="NL to SQL with T5 using Spider Dataset",
37
+ description="This model finds the closest match in the Spider dataset for your query and generates the corresponding SQL."
38
  )
39
 
40
  # Launch the app