File size: 439 Bytes
c4bf3b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- 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)