Spaces:
Running
Running
File size: 455 Bytes
ec96972 eb87b3b ec96972 eb87b3b 1e94164 eb87b3b ec96972 eb87b3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from sentence_transformers import SentenceTransformer
import numpy as np
import time
from embedder import get_model
# Use the preloaded model from embedder instead of creating a new instance
def retrieve_chunks(index, texts, query, k=15):
model = get_model() # Use the preloaded model
query_vec = model.encode([query])
distances, indices = index.search(np.array(query_vec), k)
results = [texts[i] for i in indices[0]]
return results
|