Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,16 +6,11 @@ def load_question_generator():
|
|
| 6 |
pipe = pipeline("text2text-generation", model="SinaRp/Question_generator_persian")
|
| 7 |
return pipe
|
| 8 |
|
| 9 |
-
def generate_questions(context, num_questions
|
| 10 |
try:
|
| 11 |
generator = load_question_generator()
|
| 12 |
-
questions =
|
| 13 |
-
|
| 14 |
-
for _ in range(num_questions):
|
| 15 |
-
result = generator(context, max_length=64, num_return_sequences=1)
|
| 16 |
-
questions.append(result[0]['generated_text'])
|
| 17 |
-
|
| 18 |
-
return "\n\n".join(questions)
|
| 19 |
except Exception as e:
|
| 20 |
return f"Error generating questions: {str(e)}"
|
| 21 |
|
|
@@ -30,8 +25,9 @@ iface = gr.Interface(
|
|
| 30 |
description="Generate questions from your text using AI",
|
| 31 |
examples=[
|
| 32 |
["The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, heated to incandescence by nuclear fusion reactions in its core.", 2],
|
|
|
|
| 33 |
]
|
| 34 |
)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
| 6 |
pipe = pipeline("text2text-generation", model="SinaRp/Question_generator_persian")
|
| 7 |
return pipe
|
| 8 |
|
| 9 |
+
def generate_questions(context, num_questions):
|
| 10 |
try:
|
| 11 |
generator = load_question_generator()
|
| 12 |
+
questions = generator(context, max_length=64, num_return_sequences=int(num_questions))
|
| 13 |
+
return "\n\n".join([q['generated_text'] for q in questions])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
except Exception as e:
|
| 15 |
return f"Error generating questions: {str(e)}"
|
| 16 |
|
|
|
|
| 25 |
description="Generate questions from your text using AI",
|
| 26 |
examples=[
|
| 27 |
["The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, heated to incandescence by nuclear fusion reactions in its core.", 2],
|
| 28 |
+
["Machine learning is a subset of artificial intelligence that focuses on the use of data and algorithms to imitate the way that humans learn.", 3]
|
| 29 |
]
|
| 30 |
)
|
| 31 |
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
iface.launch()
|