gtech13 commited on
Commit
328bfd7
·
verified ·
1 Parent(s): a0e5e8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -27
app.py CHANGED
@@ -88,37 +88,43 @@ with col_a:
88
  with col_b:
89
  words_per_theme = st.slider("Words to Output per Theme", 3, 10, 5)
90
 
 
91
  st.header("⚙️ Model Configuration")
92
 
93
- col1, col2 = st.columns(2)
94
- with col1:
95
- with st.expander("1️⃣ Semantic Layer (Embeddings)", expanded=True):
96
- ui_embedding = st.selectbox("Embedding Model", list(EMBEDDING_MAP.keys()))
97
- ui_pooling = st.selectbox("Pooling Strategy", list(POOLING_MAP.keys()))
98
-
99
- with col2:
100
- with st.expander("2️⃣ Geometry Layer (Dimensionality Reduction)", expanded=True):
101
- ui_algo = st.selectbox("Algorithm", ["UMAP (Complex geometry)", "PCA (Fast/Deterministic)"])
102
- ui_metric = st.selectbox("Distance Metric", ["cosine", "euclidean", "manhattan"]) if "UMAP" in ui_algo else "euclidean"
103
-
104
- col3, col4 = st.columns(2)
105
- with col3:
106
- with st.expander("3️⃣ Clustering Layer (Grouping)", expanded=True):
107
- st.markdown("""
108
- *Clustering mathematically draws boundaries around similar sentences.*
109
- * **Primary (HDBSCAN):** $\ge$ 15 sentences. Filters outliers. *(Defaults: min_cluster_size=10)*
110
- * **Fallback (K-Means):** $<$ 15 sentences. Forces buckets to prevent math crashes on tiny text.
111
- """)
112
-
113
- with col4:
114
- with st.expander("4️⃣ Vocabulary Layer (Vectorization)", expanded=True):
115
- ngram_range = st.slider("N-Gram Range", 1, 3, (1, 2))
116
- auto_noise = st.checkbox("Auto-Remove Redundant Noise", value=True, help="Mathematically deletes words appearing in >85% of documents.")
 
 
117
 
118
  with st.expander("5️⃣ Extraction Layer (Representation)", expanded=True):
119
- st.markdown("*BERTopic ALWAYS extracts baseline words using **c-TF-IDF**. Do you want to apply an advanced mathematical filter on top of it?*")
120
- ui_extraction = st.selectbox("Apply Advanced Filter:", ["None (Base c-TF-IDF only)", "KeyBERTInspired (Semantic alignment)", "MMR (Reduce redundancy)"])
121
- mmr_diversity = st.slider("MMR Diversity Penalty", 0.0, 1.0, 0.3) if "MMR" in ui_extraction else None
 
 
 
122
 
123
  st.header("📊 Evaluation Metrics")
124
  eval_metrics = st.multiselect(
 
88
  with col_b:
89
  words_per_theme = st.slider("Words to Output per Theme", 3, 10, 5)
90
 
91
+ # --- THE VERTICAL CONFIGURATION WIZARD ---
92
  st.header("⚙️ Model Configuration")
93
 
94
+ with st.expander("1️⃣ Semantic Layer (Embeddings & Pooling)", expanded=True):
95
+ st.markdown("*💡 **BERTopic Default:** Uses `all-MiniLM-L6-v2` with `Mean` pooling.*")
96
+ ui_embedding = st.selectbox("Embedding Model (Override Default):", list(EMBEDDING_MAP.keys()))
97
+ ui_pooling = st.selectbox("Pooling Strategy (Override Default):", list(POOLING_MAP.keys()))
98
+
99
+ with st.expander("2️⃣ Geometry Layer (Dimensionality Reduction)", expanded=True):
100
+ st.markdown("*💡 **BERTopic Default:** Uses `UMAP` with `Cosine` distance to reduce 384D to 5D space.*")
101
+ ui_algo = st.selectbox("Algorithm", ["UMAP (Complex geometry)", "PCA (Fast/Deterministic)"])
102
+ if "UMAP" in ui_algo:
103
+ ui_metric = st.selectbox("Distance Metric", ["cosine", "euclidean", "manhattan"])
104
+ else:
105
+ ui_metric = "euclidean"
106
+ st.info("PCA inherently uses Variance (Euclidean math), so distance metrics are bypassed.")
107
+
108
+ with st.expander("3️⃣ Clustering Layer (Grouping)", expanded=True):
109
+ st.markdown("*💡 **BERTopic Default:** Uses `HDBSCAN` exclusively (which crashes on tiny datasets).*")
110
+ st.markdown("""
111
+ *Our Engine mathematically draws boundaries around similar sentences using a smart-routing system:*
112
+ * **Primary Engine (HDBSCAN):** Runs on datasets $\ge$ 15 sentences. Automatically filters outliers and finds dense semantic clouds. *(Defaults: min_cluster_size=10)*
113
+ * **Fallback Engine (K-Means):** Runs on datasets $<$ 15 sentences. Forces all sentences into buckets to prevent math crashes on tiny text samples.
114
+ """)
115
+
116
+ with st.expander("4️⃣ Vocabulary Layer (Vectorization)", expanded=True):
117
+ st.markdown("*💡 **BERTopic Default:** Uses `Unigrams` (1 word) and does **not** filter redundant dataset noise.*")
118
+ ngram_range = st.slider("N-Gram Range", 1, 3, (1, 2), help="1=Unigrams, 2=Bigrams (e.g., 'machine learning')")
119
+ auto_noise = st.checkbox("Auto-Remove Redundant Noise (max_df)", value=True, help="Mathematically deletes words appearing in >85% of documents.")
120
 
121
  with st.expander("5️⃣ Extraction Layer (Representation)", expanded=True):
122
+ st.markdown("*💡 **BERTopic Default:** ALWAYS extracts baseline words using **c-TF-IDF** (Word Frequency).*")
123
+ ui_extraction = st.selectbox("Apply Advanced Filter on top of c-TF-IDF:", ["None (Base c-TF-IDF only)", "KeyBERTInspired (Semantic cosine)", "MMR (Reduce redundancy)"])
124
+ if "MMR" in ui_extraction:
125
+ mmr_diversity = st.slider("MMR Diversity Penalty", 0.0, 1.0, 0.3)
126
+ else:
127
+ mmr_diversity = None
128
 
129
  st.header("📊 Evaluation Metrics")
130
  eval_metrics = st.multiselect(