SarowarSaurav commited on
Commit
9494426
·
verified ·
1 Parent(s): 44ff7d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -1,22 +1,13 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- import random
4
 
5
- # List of backend servers (simulated instances of the pipeline)
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
- # Function to select a backend server in a round-robin manner
13
- def select_backend():
14
- return random.choice(backend_servers)
15
 
16
  # Define the function to answer questions
17
  def get_answer(text):
18
- backend = select_backend()
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()