kimhung0011's picture
Update app.py
2d1dad8 verified
raw
history blame
741 Bytes
import subprocess
# Install transformers library
subprocess.check_call(["pip", "install", "transformers"])
subprocess.check_call(["pip", "install", "torch"])
import gradio as gr
from transformers import pipeline
# Replace this with your own checkpoint
model_checkpoint = "huggingface-course/bert-finetuned-squad"
question_answerer = pipeline("question-answering", model=model_checkpoint)
def answer_question(question, context):
answer = question_answerer(question=question, context=context)
return answer['answer']
iface = gr.Interface(
fn=answer_question,
inputs=[gr.inputs.Textbox(label="Context"), gr.inputs.Textbox(label="Question")],
outputs="text",
title="Hugging Face Question Answering"
)
iface.launch()