|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
qa_pipeline = pipeline('question-answering', model='your_username/Extractive-QA-Bot') |
|
|
|
|
|
def answer_question(context, question): |
|
result = qa_pipeline(question=question, context=context) |
|
return result['answer'] |
|
|
|
|
|
interface = gr.Interface( |
|
fn=answer_question, |
|
inputs=[ |
|
gr.inputs.Textbox(label="Context", placeholder="Enter some text to ask questions from"), |
|
gr.inputs.Textbox(label="Question", placeholder="Ask a question based on the context") |
|
], |
|
outputs="text", |
|
title="Extractive QA Bot", |
|
description="Ask questions and get answers based on the provided context." |
|
) |
|
|
|
|
|
interface.launch() |
|
|