Spaces:
Running
Running
fix python version and requirements for streamlit cloud
Browse files- .python_version +1 -0
- .streamlit/config.toml +6 -0
- app/main.py +14 -0
- data/sample_passages.json +1 -1
- packages.txt +2 -0
- requirements.txt +9 -23
- setup.sh +1 -0
- src/question_generator.py +20 -0
.python_version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.11
|
.streamlit/config.toml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[server]
|
| 2 |
+
headless = true
|
| 3 |
+
port = 8501
|
| 4 |
+
|
| 5 |
+
[theme]
|
| 6 |
+
base = "light"
|
app/main.py
CHANGED
|
@@ -26,6 +26,20 @@ from app.components import render_question_card, render_result_card, render_sco
|
|
| 26 |
# PAGE CONFIG β must be first Streamlit call
|
| 27 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
st.set_page_config(
|
| 30 |
page_title = APP_TITLE,
|
| 31 |
page_icon = APP_ICON,
|
|
|
|
| 26 |
# PAGE CONFIG β must be first Streamlit call
|
| 27 |
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
#cache
|
| 32 |
+
|
| 33 |
+
import streamlit as st
|
| 34 |
+
|
| 35 |
+
@st.cache_resource
|
| 36 |
+
def load_pipeline():
|
| 37 |
+
from src.mcq_builder import build_quiz
|
| 38 |
+
return build_quiz
|
| 39 |
+
|
| 40 |
+
build_quiz = load_pipeline()
|
| 41 |
+
|
| 42 |
+
|
| 43 |
st.set_page_config(
|
| 44 |
page_title = APP_TITLE,
|
| 45 |
page_icon = APP_ICON,
|
data/sample_passages.json
CHANGED
|
@@ -24,4 +24,4 @@
|
|
| 24 |
"topic": "Water Cycle",
|
| 25 |
"text": "The water cycle, also known as the hydrological cycle, describes the continuous movement of water on, above, and below the Earth's surface. The main processes involved are evaporation, condensation, precipitation, and collection. Evaporation occurs when water from oceans, lakes, and rivers is heated by the sun and turns into water vapour. This vapour rises into the atmosphere and cools, forming clouds through condensation. When clouds become heavy enough, water falls back to Earth as precipitation in the form of rain, snow, or hail. The water then collects in oceans, rivers, and groundwater, and the cycle begins again."
|
| 26 |
}
|
| 27 |
-
]
|
|
|
|
| 24 |
"topic": "Water Cycle",
|
| 25 |
"text": "The water cycle, also known as the hydrological cycle, describes the continuous movement of water on, above, and below the Earth's surface. The main processes involved are evaporation, condensation, precipitation, and collection. Evaporation occurs when water from oceans, lakes, and rivers is heated by the sun and turns into water vapour. This vapour rises into the atmosphere and cools, forming clouds through condensation. When clouds become heavy enough, water falls back to Earth as precipitation in the form of rain, snow, or hail. The water then collects in oceans, rivers, and groundwater, and the cycle begins again."
|
| 26 |
}
|
| 27 |
+
]
|
packages.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
python3-dev
|
| 2 |
+
build-essential
|
requirements.txt
CHANGED
|
@@ -1,23 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
torch==2.2.1 # CPU version β change to torch==2.2.1+cu118 for GPU
|
| 11 |
-
|
| 12 |
-
# ββ Word Embeddings βββββββββββββββββββββββββββ
|
| 13 |
-
gensim==4.3.2 # Word2Vec / GloVe loading
|
| 14 |
-
|
| 15 |
-
# ββ ML utilities βββββββββββββββββββββββββββββ
|
| 16 |
-
scikit-learn==1.4.1.post1 # TF-IDF vectorizer
|
| 17 |
-
numpy==1.26.4
|
| 18 |
-
|
| 19 |
-
# ββ UI ββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
-
streamlit==1.33.0
|
| 21 |
-
|
| 22 |
-
# ββ Utilities βββββββββββββββββββββββββββββββββ
|
| 23 |
-
pandas==2.2.1 # Useful for data inspection in notebooks
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
torch
|
| 3 |
+
transformers
|
| 4 |
+
sentencepiece
|
| 5 |
+
nltk
|
| 6 |
+
scikit-learn
|
| 7 |
+
numpy
|
| 8 |
+
gensim
|
| 9 |
+
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1-py3-none-any.whl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
python -m spacy download en_core_web_sm
|
src/question_generator.py
CHANGED
|
@@ -17,6 +17,26 @@ print(f"[INFO] Loading QG model: {QG_MODEL_NAME} ...")
|
|
| 17 |
import warnings
|
| 18 |
warnings.filterwarnings("ignore") # suppress HuggingFace FutureWarnings
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
try:
|
| 21 |
qg_pipeline = pipeline(
|
| 22 |
"text2text-generation",
|
|
|
|
| 17 |
import warnings
|
| 18 |
warnings.filterwarnings("ignore") # suppress HuggingFace FutureWarnings
|
| 19 |
|
| 20 |
+
|
| 21 |
+
@st.cache_resource
|
| 22 |
+
def load_model():
|
| 23 |
+
tokenizer = AutoTokenizer.from_pretrained(QG_MODEL_NAME, use_fast=False)
|
| 24 |
+
model = T5ForConditionalGeneration.from_pretrained(QG_MODEL_NAME)
|
| 25 |
+
model.eval()
|
| 26 |
+
return tokenizer, model
|
| 27 |
+
|
| 28 |
+
tokenizer, qg_model = load_model()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
try:
|
| 41 |
qg_pipeline = pipeline(
|
| 42 |
"text2text-generation",
|