RAG-PDF-Project / retrieval /vector_store.py
RAG PDF Assistant
Initial commit: Production-ready RAG PDF Assistant with HuggingFace integration
1b31f0c
Raw History Blame Contribute Delete
408 Bytes
import faiss
import numpy as np
def create_index(vectors):
# Handle empty vectors
if vectors.size == 0 or len(vectors.shape) == 1:
raise ValueError(
'No valid text found in PDF. '
'Ensure the PDF contains extractable text content.'
)
dimension = vectors.shape[1]
index = faiss.IndexFlatL2(dimension)
index.add(vectors)
return index