File size: 904 Bytes
c2ebdfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d267fc
c2ebdfa
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from transformers import pipeline

pipe = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")

def main(question, context):
  answer = pipe(question=question, context=context)
  return answer["answer"]

with gr.Blocks() as demo:
  gr.Markdown("""# Question Answerer!""")
  with gr.Row():
    with gr.Column():
      text1 = gr.Textbox(
            label="Question",
            lines=1,
            value="Who does Cristiano Ronaldo play for?",
        )
      text2 = gr.Textbox(
            label="Context",
            lines=3,
            value="Cristiano Ronaldo is a player for Manchester United",
        )
      output = gr.Textbox()
      b1 = gr.Button("Ask Question!")
      b1.click(main, inputs=[text1, text2], outputs=output)
  gr.Markdown("""#### powered by [Tassle](https://bit.ly/3LXMklV)""")


if __name__ == "__main__":
    demo.launch()