File size: 397 Bytes
cbbe164
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from sentence_transformers import SentenceTransformer
import faiss, os, pickle

model = SentenceTransformer("all-MiniLM-L6-v2")
index = faiss.IndexFlatL2(384)
docs = []

def ingest(text):
    emb = model.encode([text])
    index.add(emb)
    docs.append(text)

    faiss.write_index(index, "rag/vectorstore/index.faiss")
    pickle.dump(docs, open("rag/vectorstore/docs.pkl", "wb"))