Spaces:
Sleeping
Sleeping
File size: 764 Bytes
123d64a 2d1dad8 123d64a 0da23b5 d2b11c7 0da23b5 d2b11c7 0da23b5 d2b11c7 4960c9d d2b11c7 4e528b4 d2b11c7 11338f1 f24e7b1 f181c01 d2b11c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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'], answer['score'], answer['start'], answer['end']
iface = gr.Interface(
fn=answer_question,
inputs=["text", "text"],
outputs=["text", "number", "number", "number"],
title="Extractive Question Answering"
)
iface.launch()
|