Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,19 +7,19 @@ tokenizer = T5Tokenizer.from_pretrained('t5-small', legacy=False)
|
|
7 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
8 |
|
9 |
# dataset = load_dataset("b-mc2/sql-create-context")
|
10 |
-
dataset = load_dataset("
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
def generate_sql(question):
|
20 |
# Format the question for the model if needed. For example:
|
21 |
-
|
22 |
-
input_text = f"{question}" # Directly use the question if the model is fine-tuned for SQL generation
|
23 |
|
24 |
# Tokenize the input text
|
25 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
@@ -39,7 +39,7 @@ iface = gr.Interface(
|
|
39 |
outputs=gr.Textbox(),
|
40 |
title="Natural Language to SQL",
|
41 |
description="This app uses a Seq2Seq model to generate SQL queries from natural language questions.",
|
42 |
-
|
43 |
)
|
44 |
|
45 |
# Launch the app
|
|
|
7 |
model = T5ForConditionalGeneration.from_pretrained('t5-small')
|
8 |
|
9 |
# dataset = load_dataset("b-mc2/sql-create-context")
|
10 |
+
dataset = load_dataset("wikisql", split="train")
|
11 |
|
12 |
+
examples = []
|
13 |
|
14 |
+
for i in range(3): # Let's take the first 3 examples
|
15 |
+
item = dataset[i]
|
16 |
+
question = item['question']
|
17 |
+
examples.append([question])
|
18 |
|
19 |
def generate_sql(question):
|
20 |
# Format the question for the model if needed. For example:
|
21 |
+
input_text = f"translate English to SQL: {question}"
|
22 |
+
# input_text = f"{question}" # Directly use the question if the model is fine-tuned for SQL generation
|
23 |
|
24 |
# Tokenize the input text
|
25 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
|
|
39 |
outputs=gr.Textbox(),
|
40 |
title="Natural Language to SQL",
|
41 |
description="This app uses a Seq2Seq model to generate SQL queries from natural language questions.",
|
42 |
+
examples=examples
|
43 |
)
|
44 |
|
45 |
# Launch the app
|