Spaces:
Build error
Build error
Update app,py
Browse files
app,py
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the Hugging Face model for question generation
|
| 5 |
+
question_generator = pipeline("text2text-generation", model="valhalla/t5-small-qg-hl")
|
| 6 |
+
|
| 7 |
+
# Function to generate MCQs
|
| 8 |
+
def generate_mcqs(content, num_questions):
|
| 9 |
+
# Generate questions
|
| 10 |
+
questions = question_generator(content, max_length=512, num_return_sequences=num_questions)
|
| 11 |
+
return questions
|
| 12 |
+
|
| 13 |
+
# Streamlit UI
|
| 14 |
+
st.title("MCQ Generator using Hugging Face")
|
| 15 |
+
|
| 16 |
+
content = st.text_area("Enter the content from which MCQs will be generated:", height=200)
|
| 17 |
+
num_questions = st.number_input("Enter the number of MCQs to generate:", min_value=1, max_value=20, value=5, step=1)
|
| 18 |
+
|
| 19 |
+
if st.button("Generate MCQs"):
|
| 20 |
+
if content:
|
| 21 |
+
mcqs = generate_mcqs(content, num_questions)
|
| 22 |
+
for i, mcq in enumerate(mcqs):
|
| 23 |
+
st.write(f"Q{i+1}: {mcq['generated_text']}")
|
| 24 |
+
else:
|
| 25 |
+
st.warning("Please enter the content to generate MCQs.")
|
| 26 |
+
|