Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
import random
|
4 |
|
5 |
-
#
|
6 |
-
backend_servers = [
|
7 |
-
pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad"),
|
8 |
-
pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad"),
|
9 |
-
pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad")
|
10 |
-
]
|
11 |
|
12 |
-
|
13 |
-
def select_backend():
|
14 |
-
return random.choice(backend_servers)
|
15 |
|
16 |
# Define the function to answer questions
|
17 |
def get_answer(text):
|
18 |
-
|
19 |
-
result = backend(question=text, context=knowledge_base_text)
|
20 |
return result["answer"]
|
21 |
|
22 |
# Define the Gradio interface
|
@@ -60,7 +51,4 @@ iface = gr.Interface(
|
|
60 |
theme='compact'
|
61 |
)
|
62 |
|
63 |
-
iface.launch()
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# Use a pipeline as a high-level helper
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
pipe = pipeline("question-answering", model="Intel/dynamic_tinybert")
|
|
|
|
|
7 |
|
8 |
# Define the function to answer questions
|
9 |
def get_answer(text):
|
10 |
+
result = pipe(question=text, context=knowledge_base_text)
|
|
|
11 |
return result["answer"]
|
12 |
|
13 |
# Define the Gradio interface
|
|
|
51 |
theme='compact'
|
52 |
)
|
53 |
|
54 |
+
iface.launch()
|
|
|
|
|
|