Rajeev Kumar commited on
Commit
8455d54
1 Parent(s): c1daf61

updated the filess

Browse files
Files changed (2) hide show
  1. app.py +9 -11
  2. requirements.txt +2 -3
app.py CHANGED
@@ -1,19 +1,17 @@
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()
 
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
- layer==0.9.350435
2
- torch==1.11.0
3
- sentencepiece==0.1.96
 
1
+ transformers
2
+ sentencepiece