Spaces:
Runtime error
Runtime error
| 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 | |