Issurance_Agent_Rag / embedder.py
Rivalcoder
Add application file
ec96972
raw
history blame
343 Bytes
import faiss
from sentence_transformers import SentenceTransformer
import numpy as np
model = SentenceTransformer("all-MiniLM-L6-v2")
def build_faiss_index(chunks):
embeddings = model.encode(chunks)
dimension = embeddings.shape[1]
index = faiss.IndexFlatL2(dimension)
index.add(np.array(embeddings))
return index, chunks