neural-net-rahul commited on
Commit
c82f7d2
1 Parent(s): cd78e0b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from transformers import pipeline
4
+
5
+ title = "Question Answering System"
6
+ description = """
7
+ Click on examples below to try them
8
+
9
+ <img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
10
+ """
11
+
12
+ article = "Check out [my github repository](https://github.com/Neural-Net-Rahul/Question-Answering-system-using-fine-tuned-hugging-face-transformer) and my [fine tuned model](https://huggingface.co/neural-net-rahul/bert-finetuned-squad)"
13
+
14
+ textbox1 = gr.Textbox(label="Context :", placeholder="The New Yorker noted that by the time Zuckerberg began classes at Harvard in 2002, he had already achieved a reputation as a programming prodigy.", lines=3)
15
+ textbox2 = gr.Textbox(label="Question :", placeholder="Who achieved reputation as a programming prodigy?", lines=3)
16
+ textbox3 = gr.Textbox(label='Answer :', placeholder="Zuckerberg",lines=5)
17
+
18
+ model = pipeline('question-answering',model='neural-net-rahul/bert-finetuned-squad')
19
+
20
+ def ques_ans(context,question):
21
+ return model(question=question, context=context)['answer']
22
+
23
+
24
+ gr.Interface(
25
+ fn=ques_ans,
26
+ inputs=[textbox1,textbox2],
27
+ outputs=textbox3,
28
+ title=title,
29
+ description=description,
30
+ article=article,
31
+ examples=[["Zuckerberg began using computers and writing software in middle school. In high school, he built a program that allowed all the computers between his house and his father's dental office to communicate with each other.","What does the program do?"],["Modi completed his higher secondary education in Vadnagar in 1967; his teachers described him as an average student and a keen, gifted debater with an interest in theatre. He preferred playing larger-than-life characters in theatrical productions, which has influenced his political image","Modi was good in which art?"]]
32
+ ).launch(share=True)