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