Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
|
|
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 =
|
8 |
|
9 |
inputs = tokenizer(user_query, return_tensors="pt", padding=True)
|
10 |
-
outputs = model
|
11 |
-
|
12 |
|
13 |
-
return
|
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):
|