Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a pre-trained QA model | |
| qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2") | |
| # Define a function to get answers | |
| def answer_question(context, question): | |
| result = qa_pipeline(question=question, context=context) | |
| return result['answer'] | |
| # Create Gradio Interface | |
| interface = gr.Interface( | |
| fn=answer_question, | |
| inputs=["text", "text"], | |
| outputs="text", | |
| title="Question Answering Model", | |
| description="Ask a question based on the given context." | |
| ) | |
| # Launch the app | |
| interface.launch() | |