Spaces:
Runtime error
Runtime error
Fix: Update UI, Shards (16), and Router Logic
Browse files9 unmodified lines1011121314151673 unmodified lines90919293949596979899100101102103153 unmodified lines2572582592602612622632642652662672682692702712721 unmodified line2742752762772782792802812822832842852862872883 unmodified lines2922932942952962972988 unmodified lines3073083093103113123139 unmodified lines# --- Configuration ---COLLECTION_NAME = "dashVector_v1"VECTOR_SIZE = 384 # MiniLM-L6-v2NUM_CLUSTERS = 32EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"# --- Initialize Backend ---73 unmodified lines<header class="bg-white border-b border-slate-200 sticky top-0 z-40 shadow-sm w-full"><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between"><div class="flex items-center gap-2"><!-- User Logo --><img src="file/logo.png" alt="dashVector Logo" class="h-8 w-auto" /><h1 class="text-xl font-bold tracking-tight text-slate-900">dashVector</h1></div><div class="flex items-center gap-4"><div class="hidden md:flex items-center gap-1.5 px-3 py-1 bg-slate-100 rounded-full border border-slate-200"><span class="material-symbols-outlined text-slate-500 text-sm">database</span><span class="text-xs font-medium text-slate-600">Dataset: <span class="font-bold text-slate-800">MS Marco</span></span></div></div></div>153 unmodified lines# Router Predictionif router:print("DEBUG: Predicting cluster...")target_cluster, confidence = router.predict(query_vec)print(f"DEBUG: Predicted cluster {target_cluster} with confidence {confidence}")else:print("DEBUG: No router loaded, using mock.")target_cluster, confidence = 0, 0.95 # Mock# Searchprint("DEBUG: Searching Qdrant...")results, mode = vector_db.search_hybrid(query_vec, target_cluster, confidence)print(f"DEBUG: Search complete. Found {len(results)} results.")end_total = time.time()1 unmodified line# Construct Data Rows# Live Row (MiniLM + LightGBM)# Mocking shards searched based on confidence for demo visualshards_searched = 2 if confidence > 0.8 else 33total_shards = 33direct_time = latency_ms * (total_shards / shards_searched) * 1.2 # Estimate baselinelive_row = {"embedding": "MiniLM-L6-v2 (Active)","router": "LightGBM","optimizedTime": f"{latency_ms:.1f} ms","shardsSearched": f"{shards_searched} / {total_shards}","totalShards": total_shards,3 unmodified lines"efficiency": f"+{((1 - latency_ms/direct_time)*100):.1f}%"}# Reference Rows (Static)ref_rows = [{"embedding": "Gemma 300M",8 unmodified lines},{"embedding": "Qwen 600M","router": "XGBoost","optimizedTime": "109 ms","shardsSearched": "7 / 16","totalShards": 16,9 unmodified lines1011121314151673 unmodified lines90919293949596979899100101102153 unmodified lines2562572582592602612622632642652662672682692702712722731 unmodified line2752762772782792802812822832842852862872882892902913 unmodified lines2952962972982993003018 unmodified lines3103113123133143153169 unmodified lines# --- Configuration ---COLLECTION_NAME = "dashVector_v1"VECTOR_SIZE = 384 # MiniLM-L6-v2NUM_CLUSTERS = 16EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"# --- Initialize Backend ---73 unmodified lines<header class="bg-white border-b border-slate-200 sticky top-0 z-40 shadow-sm w-full"><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between"><div class="flex items-center gap-2"><!-- User Logo Removed --><h1 class="text-xl font-bold tracking-tight text-slate-900">dashVector</h1></div><div class="flex items-center gap-4"><div class="hidden md:flex items-center gap-1.5 px-3 py-1 bg-slate-100 rounded-full border border-slate-200"><span class="material-symbols-outlined text-slate-500 text-sm">database</span><span class="text-xs font-medium text-slate-600">Dataset: <span class="font-bold text-slate-800">MS Marco (25k)</span></span></div></div></div>153 unmodified lines# Router Predictionif router:print("DEBUG: Predicting clusters...")# Now returns list of clusters and cumulative confidencetarget_clusters, confidence = router.predict(query_vec)print(f"DEBUG: Predicted clusters {target_clusters} with cumulative confidence {confidence}")else:print("DEBUG: No router loaded, using mock.")target_clusters, confidence = [0], 0.95 # Mock# Searchprint("DEBUG: Searching Qdrant...")# Now accepts list of clustersresults, mode = vector_db.search_hybrid(query_vec, target_clusters, confidence)print(f"DEBUG: Search complete. Found {len(results)} results.")end_total = time.time()1 unmodified line# Construct Data Rows# Live Row (MiniLM + Logistic Regression)shards_searched = len(target_clusters)total_shards = 16 # Updated to 16# Estimate baseline time (mock calculation for demo if we don't run full scan)# Or we could actually run full scan if we wanted true comparison, but for speed we estimatedirect_time = latency_ms * (total_shards / max(shards_searched, 1)) * 1.1live_row = {"embedding": "MiniLM-L6-v2 (Active)","router": "Logistic Regression", # Updated label"optimizedTime": f"{latency_ms:.1f} ms","shardsSearched": f"{shards_searched} / {total_shards}","totalShards": total_shards,3 unmodified lines"efficiency": f"+{((1 - latency_ms/direct_time)*100):.1f}%"}# Reference Rows (Static - Updated)ref_rows = [{"embedding": "Gemma 300M",8 unmodified lines},{"embedding": "Qwen 600M","router": "Tiny MLP","optimizedTime": "109 ms","shardsSearched": "7 / 16","totalShards": 16,
app.py+20-17