Spaces:
Build error
Build error
alyxx commited on
Commit ·
720c9e9
1
Parent(s): fa25309
adding app.py and requirements.txt
Browse files- app.py +20 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
question_answerer = pipeline("question-answering",
|
| 5 |
+
model='kaiku03/Q-andA-bert-finetuned-squad-accelerate',
|
| 6 |
+
tokenizer='kaiku03/Q-andA-bert-finetuned-squad-accelerate')
|
| 7 |
+
|
| 8 |
+
examples = [
|
| 9 |
+
["The capital of France is Paris.", "What is the capital of France?"],
|
| 10 |
+
["J.K. Rowling is the author of Harry Potter books.", "Who is the author of Harry Potter?"],
|
| 11 |
+
["The largest mammal is the blue whale.", "What is the largest mammal?"]
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
interface = gr.Interface.from_pipeline(question_answerer,
|
| 15 |
+
title='Question Answering demo with transformers and gradio',
|
| 16 |
+
theme="peach",
|
| 17 |
+
description='Enter a context and a related question, and this demo will provide an answer.',
|
| 18 |
+
article='This demo was trained on the SQuAD dataset using only 5% of the training data and 2% of the validation data for the sake of speed',
|
| 19 |
+
|
| 20 |
+
examples=examples).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|