Spaces:
Runtime error
Runtime error
File size: 1,520 Bytes
2a2c864 b8db52d 6da417a 2a2c864 debe187 6da417a debe187 b8db52d 8cea305 debe187 8cea305 debe187 8cea305 debe187 6da417a debe187 b8db52d debe187 |
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 27 28 29 30 31 32 33 34 35 |
import gradio as gr
from transformers import pipeline
qa_pipeline = pipeline(task="question-answering",model="Intel/bert-base-uncased-squadv1.1-sparse-80-1x4-block-pruneofa")
def greet(name):
return "Hello " + name + "!!"
def predict(question="How many continents are there in the world?",context="There are seven continents in the world."):
predictions = qa_pipeline(question=question,context=context)
print(f'predictions={predictions}')
return predictions
md = """
If you came looking for chatGPT, sorry to disappoint, but this is different. This prediction model is designed to answer a question about a text. It is designed to do reading comprehension. The model does not just answer questions in general -- it only works from the text that you provide. However, accomplishing accurate reading comprehension can be a very valuable task, especially if you are attempting to get quick answers from a large (and maybe boring!) document.
Training dataset: SQuADv1.1, based on the Rajpurkar et al. (2016) paper: [SQuAD: 100,000+ Questions for Machine Comprehension of Text](https://aclanthology.org/D16-1264/)
Based on the Zafrir et al. (2021) paper: [Prune Once for All: Sparse Pre-Trained Language Models](https://arxiv.org/abs/2111.05754) paper.
"""
predict()
# iface = gr.Interface(
# fn=predict,
# inputs="Input your question.",
# outputs="text",
# title = "Question & Answer with Sparse BERT using the SQuAD dataset",
# description = md
# )
# iface.launch()
|