Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from datasets import load_dataset
|
|
6 |
tokenizer = T5Tokenizer.from_pretrained('t5-small')
|
7 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
8 |
|
|
|
9 |
def generate_sql(question):
|
10 |
# Format the question for the model if needed. For example:
|
11 |
# input_text = f"translate English to SQL: {question}"
|
@@ -21,13 +22,16 @@ def generate_sql(question):
|
|
21 |
sql_query = tokenizer.decode(output_ids, skip_special_tokens=True)
|
22 |
return sql_query
|
23 |
|
|
|
|
|
24 |
# Define the Gradio interface
|
25 |
iface = gr.Interface(
|
26 |
fn=generate_sql,
|
27 |
inputs=gr.Textbox(lines=2, placeholder="Enter your question here..."),
|
28 |
outputs=gr.Textbox(),
|
29 |
title="Natural Language to SQL",
|
30 |
-
description="This app uses a Seq2Seq model to generate SQL queries from natural language questions."
|
|
|
31 |
)
|
32 |
|
33 |
# Launch the app
|
|
|
6 |
tokenizer = T5Tokenizer.from_pretrained('t5-small')
|
7 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
8 |
|
9 |
+
dataset = load_dataset("wikisql", split='test')[:3]
|
10 |
def generate_sql(question):
|
11 |
# Format the question for the model if needed. For example:
|
12 |
# input_text = f"translate English to SQL: {question}"
|
|
|
22 |
sql_query = tokenizer.decode(output_ids, skip_special_tokens=True)
|
23 |
return sql_query
|
24 |
|
25 |
+
examples = [[item['question']] for item in dataset]
|
26 |
+
|
27 |
# Define the Gradio interface
|
28 |
iface = gr.Interface(
|
29 |
fn=generate_sql,
|
30 |
inputs=gr.Textbox(lines=2, placeholder="Enter your question here..."),
|
31 |
outputs=gr.Textbox(),
|
32 |
title="Natural Language to SQL",
|
33 |
+
description="This app uses a Seq2Seq model to generate SQL queries from natural language questions.",
|
34 |
+
examples=examples
|
35 |
)
|
36 |
|
37 |
# Launch the app
|