File size: 713 Bytes
0e145f7
1416484
0e145f7
1416484
 
 
1fe4027
e492060
1416484
 
 
 
2a5a516
8f29cfe
1416484
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
import gradio as gr

nlp = pipeline('question-answering', model='deepset/roberta-base-squad2', tokenizer='deepset/roberta-base-squad2')

def qnamodel(context,question):
  question_set = {'context':context,'question':question}
  results = nlp(question_set)
  return results['answer']

interface = gr.Interface(fn=qnamodel, 
                        inputs=[gr.inputs.Textbox(lines=7, label="Context"), gr.inputs.Textbox(lines=2, label="Question")],
                        outputs= gr.outputs.Textbox(label="Answer"),
                        title='Context Question Answering')
                        
interface.launch(inline=False)