Spaces:
Sleeping
Sleeping
| 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() |