Spaces:
Runtime error
Runtime error
from transformers import pipeline | |
import gradio as gr | |
# Set up the pipeline for question answering | |
pipe = pipeline("question-answering", model="Intel/dynamic_tinybert") | |
def answer_question(context, question): | |
# Use the pipeline to get the answer | |
result = pipe(question=question, context=context) | |
return f'<span style="color:red">{result["answer"]}</span>' # Wrap the answer in HTML span tag with red colour | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=answer_question, | |
inputs=[ | |
gr.Textbox(label="Please type or copy and paste the Context"), | |
gr.Textbox(label="Question") | |
], | |
outputs=gr.HTML(label="Answer") # Set output as HTML | |
) | |
# Launch the app | |
iface.launch() | |