Spaces:
Runtime error
Runtime error
Rajeev Kumar
commited on
Commit
·
c1daf61
1
Parent(s):
8a559c7
Add application files
Browse files- app.py +19 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import layer
|
3 |
+
|
4 |
+
model = layer.get_model('layer/t5-fine-tuning-with-layer/models/t5-english-to-sql').get_train()
|
5 |
+
tokenizer = layer.get_model('layer/t5-fine-tuning-with-layer/models/t5-tokenizer').get_train()
|
6 |
+
|
7 |
+
def greet(query):
|
8 |
+
input_ids = tokenizer.encode(f"translate English to SQL: {query}", return_tensors="pt")
|
9 |
+
outputs = model.generate(input_ids, max_length=1024)
|
10 |
+
sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
11 |
+
return sql
|
12 |
+
|
13 |
+
|
14 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text", examples=[
|
15 |
+
"Show me the average price of wines in Italy by provinces",
|
16 |
+
"Cars built after 2020 and manufactured in Italy",
|
17 |
+
"Top 10 cities by their population"
|
18 |
+
])
|
19 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
layer==0.9.350435
|
2 |
+
torch==1.11.0
|
3 |
+
sentencepiece==0.1.96
|