File size: 1,134 Bytes
ebc56ac
 
9a5e84c
ebc56ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a5e84c
ebc56ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import tensorflow as tf
from transformers import pipeline
nlp = pipeline("question-answering")

import gradio as gr

def func(context, question):
  result = nlp(question = question, context=context)
  return result['answer']

example_1 = "(1) My name is Ajulor Christian, I am a data scientist and machine learning engineer"
qst_1 =  "what is christian's profession?"

example_2 = "(2) Natural Language Processing (NLP) allows machines to break down and interpret human language. It's at the core of tools we use every day – from translation software, chatbots, spam filters, and search engines, to grammar correction software, voice assistants, and social media monitoring tools."
qst_2 =  "What is NLP used for?"

app = gr.Interface(fn=func, inputs = ['textbox', 'text'], outputs = 'textbox', 
                   title = 'Question Answering bot', theme = 'dark-grass',
                   description = 'Input context and question, then get answers!',
                   examples = [[example_1, qst_1],
                               [example_2, qst_2]]
                   )
                   
app.launch(share=True, inline=False)