RAG_System / app.py
Jitendra14355's picture
Update app.py
86fa319 verified
raw
history blame contribute delete
790 Bytes
import gradio as gr
from transformers import pipeline
# Load lightweight QA model
qa_pipeline = pipeline(
"question-answering",
model="distilbert-base-cased-distilled-squad"
)
# Function
def answer(context, question):
if context.strip() == "" or question.strip() == "":
return "Please enter context and question."
result = qa_pipeline(
question=question,
context=context
)
return result["answer"]
# UI
demo = gr.Interface(
fn=answer,
inputs=[
gr.Textbox(lines=8, label="Context"),
gr.Textbox(lines=2, label="Question")
],
outputs="text",
title="๐Ÿ” RAG-QA System",
description="Ask questions from given context.",
theme=gr.themes.Soft()
)
demo.launch(server_name="0.0.0.0", server_port=7860)