File size: 1,456 Bytes
1669e40
c98a207
4e3e33d
8e1e982
5e14ce4
2775669
 
 
5e14ce4
1669e40
5e14ce4
c19b81b
 
5e14ce4
 
5128f64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
title = "Question Answer Generator"
description = "Enter a paragraph or sentence. Ask a question based on the paragraph or sentence."
examples = [
    ["However, this year I find it hard to cope with my schoolwork.", "When does the author find it hard to cope with schoolwork?"],
    ["What’s more, the only way I can keep myself awake and finish off everything I need to for the day is by consuming energy drinks. I know that some of these drinks have caffeine in them, and sometimes I feel groggy in the morning if I’ve had more than a couple the night before.", "What does 'them' refer to?"],
    ["I know that some of these drinks have caffeine in them, and sometimes I feel groggy in the morning if I’ve had more than a couple the night before.", "What word means 'sleepy'?"]
]

gr.Interface.load("huggingface/deepset/roberta-base-squad2", 
                  inputs=[gr.inputs.Textbox(lines=10, label="Paragraph or sentence", placeholder="Type a sentence or paragraph here."), 
                          gr.inputs.Textbox(lines=2, label="Question", placeholder="Ask a question based on the context.")],
                  outputs=[gr.outputs.Textbox(label="Answer"), 
                          gr.outputs.Label(label="Probability")],                  
                  title=title, description=description, examples=examples).launch(share=False)