Update app.py
Browse files
app.py
CHANGED
@@ -49,6 +49,9 @@ def search(query, top_k=5):
|
|
49 |
# Encode the query
|
50 |
query_embedding = model.encode([query])[0]
|
51 |
|
|
|
|
|
|
|
52 |
# Ensure the query embedding has the same dimension as the index
|
53 |
if query_embedding.shape[0] != index.d:
|
54 |
print(f"Query embedding dimension ({query_embedding.shape[0]}) does not match index dimension ({index.d})")
|
@@ -61,6 +64,10 @@ def search(query, top_k=5):
|
|
61 |
# Perform similarity search
|
62 |
distances, indices = index.search(np.array([query_embedding]), top_k)
|
63 |
|
|
|
|
|
|
|
|
|
64 |
results = []
|
65 |
for i, idx in enumerate(indices[0]):
|
66 |
patent_number = patent_numbers[idx]
|
|
|
49 |
# Encode the query
|
50 |
query_embedding = model.encode([query])[0]
|
51 |
|
52 |
+
# Debug: Print query embedding
|
53 |
+
print(f"Query embedding: {query_embedding}")
|
54 |
+
|
55 |
# Ensure the query embedding has the same dimension as the index
|
56 |
if query_embedding.shape[0] != index.d:
|
57 |
print(f"Query embedding dimension ({query_embedding.shape[0]}) does not match index dimension ({index.d})")
|
|
|
64 |
# Perform similarity search
|
65 |
distances, indices = index.search(np.array([query_embedding]), top_k)
|
66 |
|
67 |
+
# Debug: Print distances and indices
|
68 |
+
print(f"Distances: {distances}")
|
69 |
+
print(f"Indices: {indices}")
|
70 |
+
|
71 |
results = []
|
72 |
for i, idx in enumerate(indices[0]):
|
73 |
patent_number = patent_numbers[idx]
|