Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,16 +6,13 @@ 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 |
-
# Initialize the pipeline
|
10 |
-
nl2sql_pipeline = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
11 |
-
|
12 |
# Load a part of the Spider dataset
|
13 |
spider_dataset = load_dataset("spider", split='train[:5]')
|
14 |
|
15 |
def generate_sql(query):
|
16 |
-
|
17 |
-
|
18 |
-
sql_query =
|
19 |
return sql_query
|
20 |
|
21 |
# Use examples from the Spider dataset
|
@@ -28,7 +25,7 @@ interface = gr.Interface(
|
|
28 |
outputs="text",
|
29 |
examples=example_questions,
|
30 |
title="NL to SQL with Picard",
|
31 |
-
description="This model converts natural language queries into SQL using the Spider dataset. Try
|
32 |
)
|
33 |
|
34 |
# Launch the app
|
|
|
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_ids = tokenizer(query, return_tensors="pt").input_ids
|
14 |
+
outputs = model.generate(input_ids)
|
15 |
+
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
return sql_query
|
17 |
|
18 |
# Use examples from the Spider dataset
|
|
|
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 example questions or enter your own!"
|
29 |
)
|
30 |
|
31 |
# Launch the app
|