File size: 928 Bytes
d4b57d9
 
6ada24f
 
ade1e2f
6ada24f
 
 
 
 
 
 
ade1e2f
6ada24f
 
 
 
ade1e2f
6ada24f
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

# Load the question generation model
question_gen = gr.load("models/allenai/t5-small-squad2-question-generation")

# Define a function to generate questions
def generate_questions(text, num_questions=5):
    questions = []
    for i in range(num_questions):
        output = question_gen.predict(text)
        questions.append(output["generated_text"])
    return questions

# Define the input and output interfaces
input_text = gr.inputs.Textbox(label="Enter some text:")
num_questions = gr.inputs.Number(default=5, label="Number of questions to generate:")
output_text = gr.outputs.Textbox(label="Generated questions:")

# Create the interface
iface = gr.Interface(
    generate_questions, 
    inputs=[input_text, num_questions], 
    outputs=output_text,
    title="Question Generator",
    description="Generate questions from text using the T5-SQuAD2 model.",
)

# Launch the interface
iface.launch()