Spaces:
Runtime error
Runtime error
Rajeev Kumar
commited on
Commit
·
8455d54
1
Parent(s):
c1daf61
updated the filess
Browse files- app.py +9 -11
- requirements.txt +2 -3
app.py
CHANGED
|
@@ -1,19 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
def greet(query):
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text", examples=[
|
| 15 |
-
"
|
| 16 |
-
"Cars built after 2020 and manufactured in Italy",
|
| 17 |
-
"Top 10 cities by their population"
|
| 18 |
])
|
| 19 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 3 |
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("dbernsohn/t5_wikisql_en2SQL")
|
| 5 |
+
model = AutoModelWithLMHead.from_pretrained("dbernsohn/t5_wikisql_en2SQL")
|
| 6 |
|
| 7 |
def greet(query):
|
| 8 |
+
input_text = f"translate English to Sql: {query} </s>"
|
| 9 |
+
features = tokenizer([input_text], return_tensors='pt')
|
| 10 |
+
output = model.generate(input_ids=features['input_ids'],
|
| 11 |
+
attention_mask=features['attention_mask'])
|
| 12 |
+
return tokenizer.decode(output[0])
|
| 13 |
|
| 14 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text", examples=[
|
| 15 |
+
"what are the names of all the people in the USA"
|
|
|
|
|
|
|
| 16 |
])
|
| 17 |
iface.launch()
|
requirements.txt
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
sentencepiece==0.1.96
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
sentencepiece
|
|
|