besijar commited on
Commit
77229ef
·
1 Parent(s): 75ccbc6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ from transformers import pipeline
4
+ import gradio as gr
5
+
6
+ model = pipeline('question-answering', model='deepset/tinyroberta-squad2', tokenizer='deepset/tinyroberta-squad2')
7
+
8
+ def qa(passage, question):
9
+ question = question
10
+ context = passage
11
+ nlp_input = {
12
+ 'question': question,
13
+ 'context': context
14
+ }
15
+
16
+ return model(nlp_input)['answer']
17
+
18
+ passage = "The quick brown fox jumped over the lazy dog."
19
+ question = "Who jumps over the lazy dog?"
20
+
21
+ iface = gr.Interface(qa,
22
+ title="Question Answering using RoBERTa",
23
+ inputs=[gr.inputs.Textbox(lines=15), "text"],
24
+ outputs=["text"],
25
+ examples=[["{}".format(passage), "{}".format(question)]])
26
+ iface.launch()