import gradio as gr from transformers import pipeline # Load a Question Answering model qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2") def get_answer(question): # Define a context for factual answers context = """ New Delhi is the capital of India. India is a country in South Asia and is the seventh-largest country by land area. """ answer = qa_pipeline(question=question, context=context) return answer["answer"] # Create Gradio Interface iface = gr.Interface( fn=get_answer, inputs="text", outputs="text", title="Ask Any Question", description="Ask factual questions and get precise answers." ) iface.launch()