File size: 444 Bytes
c7dd5c2 1e96aac f0470a1 c7dd5c2 1e96aac c7dd5c2 1e96aac c7dd5c2 1e96aac c7dd5c2 1e96aac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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("向量資料庫建立完成 ✅")
|