import gradio as gr from transformers import pipeline qa = pipeline("question-answering") def question_answering(question, context): return qa(question, context)["answer"] question = "What is Pragyan?" context = "Chandrayaan-3 is the third and most recent lunar Indian Space Research exploration mission under the Chandrayaan programme of ISRO. It consists of a lander named Vikram and a rover named Pragyan similar to Chandrayaan-2. Its propulsion module behaves like a communication relay satellite." title = "Extractive question answering" description = """ """ question_box = gr.Textbox(label="Question:", placeholder="What is Pragyan?", lines=2) context_box = gr.Textbox(label="Context", placeholder=context, lines=10) demo = gr.Interface(fn=question_answering, inputs=[question_box, context_box], outputs="text", title=title, description=description) demo.launch()