Update app.py
Browse files
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 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
ui_metric = st.selectbox("Distance Metric", ["cosine", "euclidean", "manhattan"])
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
|
| 118 |
with st.expander("5️⃣ Extraction Layer (Representation)", expanded=True):
|
| 119 |
-
st.markdown("*BERTopic ALWAYS extracts baseline words using **c-TF-IDF**
|
| 120 |
-
ui_extraction = st.selectbox("Apply Advanced Filter:", ["None (Base c-TF-IDF only)", "KeyBERTInspired (Semantic
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 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(
|