File size: 697 Bytes
7626126
 
 
 
206b8c3
7626126
 
 
 
f4ce619
7626126
 
 
 
 
 
 
 
 
 
06e57dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from transformers import pipeline
import gradio as gr

# Load the question generation pipeline
qg_pipeline = pipeline("text2text-generation", model="valhalla/t5-base-qg-hl")

def generate_questions(text):
    # Add highlight tokens around a sentence to guide the model
    input_text = "generate questions: " + text
    result = qg_pipeline(input_text, max_length=128, num_return_sequences=5, num_beams=7)
    return [q['generated_text'] for q in result]

# Gradio Interface
iface = gr.Interface(
    fn=generate_questions,
    inputs=gr.Textbox(lines=10, label="Enter lesson or paragraph"),
    outputs=gr.List(label="Generated Questions"),
    title="Auto-Generated Quiz Maker"
)

iface.launch()