teaevo commited on
Commit
2ee70bc
·
1 Parent(s): 7b0e766

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,16 +1,17 @@
1
  import gradio as gr
2
- from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
 
3
 
4
  def execute_sql(user_query):
5
  model_name = "microsoft/tapex-large-sql-execution" # Tapex large SQL execution model
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
8
 
9
  inputs = tokenizer(user_query, return_tensors="pt", padding=True)
10
- outputs = model.generate(inputs['input_ids'], attention_mask=inputs['attention_mask'], max_length=1024)
11
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
12
 
13
- return response
14
 
15
  '''
16
  def chatbot_response(user_message):
 
1
  import gradio as gr
2
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer
3
+ from transformers import TapasTokenizer, TapasForQuestionAnswering
4
 
5
  def execute_sql(user_query):
6
  model_name = "microsoft/tapex-large-sql-execution" # Tapex large SQL execution model
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
9
 
10
  inputs = tokenizer(user_query, return_tensors="pt", padding=True)
11
+ outputs = model(**inputs)
12
+ answer = tokenizer.decode(inputs['input_ids'][0][outputs['start_logits'].argmax():outputs['end_logits'].argmax() + 1])
13
 
14
+ return answer
15
 
16
  '''
17
  def chatbot_response(user_message):