| # -*- 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) |