File size: 659 Bytes
9311971 e373b8e d00f8b0 fb1b355 e373b8e d00f8b0 e373b8e d00f8b0 e373b8e d00f8b0 9311971 d00f8b0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
# Load your QA model
qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot')
# Define a function to handle the QA
def qa_function(context, question):
result = qa_pipeline({'context': context, 'question': question})
return result['answer']
# Create a Gradio interface
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()
|