Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,6 @@ def load_entries(path):
|
|
| 44 |
|
| 45 |
|
| 46 |
def init_models():
|
| 47 |
-
"""Initialize all models and load data"""
|
| 48 |
# 1. Load embedding model for semantic search
|
| 49 |
embed_model = SentenceTransformer("all-MiniLM-L6-v2", device=cfg.DEVICE)
|
| 50 |
|
|
@@ -72,7 +71,6 @@ embed_model, tokenizer, model, entries, vectors = init_models()
|
|
| 72 |
|
| 73 |
|
| 74 |
def search_chunks(query, top_k=cfg.TOP_K, batch_size=512):
|
| 75 |
-
"""Memory-efficient cosine similarity search."""
|
| 76 |
import heapq
|
| 77 |
|
| 78 |
# Encode query as normalized float32 vector
|
|
@@ -144,7 +142,6 @@ QUESTION: {question}
|
|
| 144 |
|
| 145 |
|
| 146 |
def qa_pipeline(question):
|
| 147 |
-
"""Unified pipeline that streams search results first, then LLM answer."""
|
| 148 |
results = search_chunks(question)
|
| 149 |
|
| 150 |
# Build top results HTML immediately
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
def init_models():
|
|
|
|
| 47 |
# 1. Load embedding model for semantic search
|
| 48 |
embed_model = SentenceTransformer("all-MiniLM-L6-v2", device=cfg.DEVICE)
|
| 49 |
|
|
|
|
| 71 |
|
| 72 |
|
| 73 |
def search_chunks(query, top_k=cfg.TOP_K, batch_size=512):
|
|
|
|
| 74 |
import heapq
|
| 75 |
|
| 76 |
# Encode query as normalized float32 vector
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
def qa_pipeline(question):
|
|
|
|
| 145 |
results = search_chunks(question)
|
| 146 |
|
| 147 |
# Build top results HTML immediately
|