herMaster commited on
Commit
f42556b
β€’
1 Parent(s): 73f9920

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
4
+
5
+ model_name = "deepset/roberta-base-squad2"
6
+
7
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
8
+
9
+ def chat(context, question):
10
+ QA_input = {
11
+ "question" : question,
12
+ "context" : context
13
+ }
14
+ res = nlp(QA_input)
15
+
16
+ return res['answer']
17
+
18
+ screen = gr.Interface(
19
+ fn = chat,
20
+ inputs = [gr.Textbox(lines = 8, placeholder = "Enter your context here πŸ‘‰"), gr.Textbox(lines = 2, placeholder = "Enter your question here πŸ‘‰")],
21
+ outputs = gr.Textbox(lines = 10, placeholder = "Your answer will be here soon πŸš€"),
22
+ title="Facilitating the QnA with roberta-base-squad2 πŸ‘©πŸ»β€πŸ’»πŸ““βœπŸ»πŸ’‘",
23
+ description="This app aims to facilitate the simple QnA with the provided contextπŸ’‘",
24
+ theme="soft",
25
+ )
26
+
27
+ screen.launch()