creating file
Browse files- check_faiss.py +21 -0
check_faiss.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import faiss
|
| 2 |
+
|
| 3 |
+
index_path = "my_embeddings" # Adjust if saved elsewhere
|
| 4 |
+
|
| 5 |
+
try:
|
| 6 |
+
index = faiss.read_index(index_path)
|
| 7 |
+
print(f"π FAISS index contains {index.ntotal} vectors.")
|
| 8 |
+
|
| 9 |
+
# β
Check embedding dimensions
|
| 10 |
+
d = index.d
|
| 11 |
+
print(f"β
Embedding dimension: {d}")
|
| 12 |
+
|
| 13 |
+
# β
Retrieve and print a few embeddings
|
| 14 |
+
if index.ntotal > 0:
|
| 15 |
+
vectors = index.reconstruct_n(0, min(5, index.ntotal)) # Get first 5 embeddings
|
| 16 |
+
print(f"π§ Sample embeddings: {vectors}")
|
| 17 |
+
else:
|
| 18 |
+
print("β οΈ No embeddings found in FAISS index!")
|
| 19 |
+
|
| 20 |
+
except Exception as e:
|
| 21 |
+
print(f"β ERROR: Failed to load FAISS index - {e}")
|