|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot') |
|
|
|
|
|
def qa_function(context, question): |
|
result = qa_pipeline({'context': context, 'question': question}) |
|
return result['answer'] |
|
|
|
|
|
gr.Interface( |
|
fn=qa_function, |
|
inputs=[ |
|
gr.components.Textbox(label="Context", placeholder="Enter some text to ask questions from"), |
|
gr.components.Textbox(label="Question", placeholder="Enter your question") |
|
], |
|
outputs=gr.components.Textbox(label="Answer") |
|
).launch() |
|
|