Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
# Load tokenizer and model
|
@@ -10,8 +10,8 @@ model = AutoModelForSeq2SeqLM.from_pretrained("hrshtsharma2012/NL2SQL-Picard-fin
|
|
10 |
spider_dataset = load_dataset("spider", split='train[:5]')
|
11 |
|
12 |
def generate_sql(query):
|
13 |
-
|
14 |
-
outputs = model.generate(
|
15 |
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return sql_query
|
17 |
|
@@ -25,7 +25,7 @@ interface = gr.Interface(
|
|
25 |
outputs="text",
|
26 |
examples=example_questions,
|
27 |
title="NL to SQL with Picard",
|
28 |
-
description="This model converts natural language queries into SQL using the Spider dataset. Try
|
29 |
)
|
30 |
|
31 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
# Load tokenizer and model
|
|
|
10 |
spider_dataset = load_dataset("spider", split='train[:5]')
|
11 |
|
12 |
def generate_sql(query):
|
13 |
+
inputs = tokenizer(query, return_tensors="pt", padding=True)
|
14 |
+
outputs = model.generate(**inputs, max_length=512)
|
15 |
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return sql_query
|
17 |
|
|
|
25 |
outputs="text",
|
26 |
examples=example_questions,
|
27 |
title="NL to SQL with Picard",
|
28 |
+
description="This model converts natural language queries into SQL using the Spider dataset. Try one of the example questions or enter your own!"
|
29 |
)
|
30 |
|
31 |
# Launch the app
|