Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,6 @@ from datasets import load_dataset
|
|
6 |
tokenizer = AutoTokenizer.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
|
7 |
model = AutoModelForSeq2SeqLM.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
|
8 |
|
9 |
-
# Load a part of the Spider dataset
|
10 |
-
spider_dataset = load_dataset("spider", split='train[:5]')
|
11 |
-
|
12 |
def generate_sql(query):
|
13 |
input_text = "translate English to SQL: " + query
|
14 |
inputs = tokenizer(input_text, return_tensors="pt", padding=True)
|
@@ -16,17 +13,13 @@ def generate_sql(query):
|
|
16 |
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
17 |
return sql_query
|
18 |
|
19 |
-
# Use examples from the Spider dataset
|
20 |
-
example_questions = [(question['question'],) for question in spider_dataset]
|
21 |
-
|
22 |
# Create a Gradio interface
|
23 |
interface = gr.Interface(
|
24 |
fn=generate_sql,
|
25 |
inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
|
26 |
outputs="text",
|
27 |
-
examples=example_questions,
|
28 |
title="NL to SQL with Picard",
|
29 |
-
description="This model converts natural language queries into SQL using the Spider dataset.
|
30 |
)
|
31 |
|
32 |
# Launch the app
|
|
|
6 |
tokenizer = AutoTokenizer.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
|
7 |
model = AutoModelForSeq2SeqLM.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
|
8 |
|
|
|
|
|
|
|
9 |
def generate_sql(query):
|
10 |
input_text = "translate English to SQL: " + query
|
11 |
inputs = tokenizer(input_text, return_tensors="pt", padding=True)
|
|
|
13 |
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
return sql_query
|
15 |
|
|
|
|
|
|
|
16 |
# Create a Gradio interface
|
17 |
interface = gr.Interface(
|
18 |
fn=generate_sql,
|
19 |
inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
|
20 |
outputs="text",
|
|
|
21 |
title="NL to SQL with Picard",
|
22 |
+
description="This model converts natural language queries into SQL using the Spider dataset. Enter your query!"
|
23 |
)
|
24 |
|
25 |
# Launch the app
|