tanmmayyy commited on
Commit
a6cd9e3
Β·
1 Parent(s): 2b9be1d

fix python version and requirements for streamlit cloud

Browse files
.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
- # MCQ Generator β€” Python dependencies
2
- # Install with: pip install -r requirements.txt
3
-
4
- # ── Core NLP ──────────────────────────────────
5
- spacy==3.7.4
6
- nltk==3.8.1
7
-
8
- # ── Transformers (T5 for question generation) ─
9
- transformers==4.38.2
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",