Stust / build_vector_store.py
Alexend's picture
Update build_vector_store.py
1e96aac verified
raw
history blame contribute delete
444 Bytes
from sentence_transformers import SentenceTransformer
import faiss
import json
with open("chunks.json", "r", encoding="utf-8") as f:
chunks = json.load(f)
model = SentenceTransformer("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
embeddings = model.encode(chunks)
index = faiss.IndexFlatL2(embeddings.shape[1])
index.add(embeddings)
faiss.write_index(index, "vector_store.index")
print("向量資料庫建立完成 ✅")