rag_perso / src /vectorstore /faiss_index.py
ALBERT Clement
Initial RAG
c4bf3b5
Raw
History Blame Contribute Delete
439 Bytes
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 3 15:59:06 2026
@author: ALBERT
"""
import faiss
def build_index(embeddings, index_path):
dimension = embeddings.shape[1]
index = faiss.IndexFlatL2(dimension)
index.add(embeddings)
faiss.write_index(index, index_path)
print("Index FAISS sauvegardé.")
def load_index(index_path):
print("Chargement de l'index FAISS...")
return faiss.read_index(index_path)