Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ d = 384 # vectors dimension
|
|
| 48 |
m = 32 # hnsw parameter. Higher is more accurate but takes more time to index (default is 32, 128 should be ok)
|
| 49 |
#index = faiss.IndexHNSWFlat(d, m)
|
| 50 |
index = faiss.IndexFlatL2(embedding_dim)
|
| 51 |
-
data.add_faiss_index(
|
| 52 |
# adds an index column that for the embeddings
|
| 53 |
|
| 54 |
print("check1")
|
|
@@ -77,7 +77,7 @@ terminators = [
|
|
| 77 |
|
| 78 |
def search(query: str, k: int = 3 ):
|
| 79 |
"""a function that embeds a new query and returns the most probable results"""
|
| 80 |
-
embedded_query = embedding_model.encode(
|
| 81 |
scores, retrieved_examples = data.get_nearest_examples( # retrieve results
|
| 82 |
"embeddings", embedded_query, # compare our new embedded query with the dataset embeddings
|
| 83 |
k=k # get only top k results
|
|
|
|
| 48 |
m = 32 # hnsw parameter. Higher is more accurate but takes more time to index (default is 32, 128 should be ok)
|
| 49 |
#index = faiss.IndexHNSWFlat(d, m)
|
| 50 |
index = faiss.IndexFlatL2(embedding_dim)
|
| 51 |
+
data.add_faiss_index(embeddings.shape[1], custom_index=index)
|
| 52 |
# adds an index column that for the embeddings
|
| 53 |
|
| 54 |
print("check1")
|
|
|
|
| 77 |
|
| 78 |
def search(query: str, k: int = 3 ):
|
| 79 |
"""a function that embeds a new query and returns the most probable results"""
|
| 80 |
+
embedded_query = embedding_model.encode(query) # create embedding of a new query
|
| 81 |
scores, retrieved_examples = data.get_nearest_examples( # retrieve results
|
| 82 |
"embeddings", embedded_query, # compare our new embedded query with the dataset embeddings
|
| 83 |
k=k # get only top k results
|