Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# β Use the correct pipeline task | |
question_generator = pipeline("text2text-generation", model="valhalla/t5-base-e2e-qg") | |
def generate_questions(text): | |
# Split text into chunks (optional) | |
chunks = text.split(". ") | |
questions = [] | |
for chunk in chunks: | |
if len(chunk.strip()) > 0: | |
result = question_generator(chunk, max_length=64)[0]['generated_text'] | |
questions.append(f"β {result}") | |
return "\n".join(questions) | |
# Gradio interface | |
interface = gr.Interface( | |
fn=generate_questions, | |
inputs=gr.Textbox(lines=15, placeholder="Paste your long text here..."), | |
outputs="text", | |
title="π Generate Questions from Text", | |
description="Uses a T5 model to generate questions from a multi-sentence paragraph." | |
) | |
interface.launch() | |