Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files
app.py
CHANGED
@@ -1,26 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
question_generator = pipeline("text2text-generation", model="valhalla/t5-base-e2e-qg")
|
6 |
|
7 |
def generate_questions(text):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
for chunk in chunks:
|
12 |
-
if len(chunk.strip()) > 0:
|
13 |
-
result = question_generator(chunk, max_length=64)[0]['generated_text']
|
14 |
-
questions.append(f"β {result}")
|
15 |
-
return "\n".join(questions)
|
16 |
|
17 |
-
|
18 |
-
interface = gr.Interface(
|
19 |
fn=generate_questions,
|
20 |
-
inputs=gr.Textbox(lines=
|
21 |
outputs="text",
|
22 |
-
title="π Generate Questions from Text"
|
23 |
-
description="Uses a T5 model to generate questions from a multi-sentence paragraph."
|
24 |
)
|
25 |
|
26 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Correct pipeline task
|
5 |
question_generator = pipeline("text2text-generation", model="valhalla/t5-base-e2e-qg")
|
6 |
|
7 |
def generate_questions(text):
|
8 |
+
inputs = f"generate questions: {text}"
|
9 |
+
outputs = question_generator(inputs, max_length=256, do_sample=False)
|
10 |
+
return outputs[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
iface = gr.Interface(
|
|
|
13 |
fn=generate_questions,
|
14 |
+
inputs=gr.Textbox(lines=10, label="Enter your paragraph"),
|
15 |
outputs="text",
|
16 |
+
title="π Generate Questions from Text"
|
|
|
17 |
)
|
18 |
|
19 |
+
iface.launch()
|