tem.py 296 B

12345678910111213
  1. import faiss
  2. from remote_model import RemoteBGEModel
  3. import numpy as np
  4. model = RemoteBGEModel()
  5. embedding = np.array(model.encode(["hello world"]), dtype=np.float32)
  6. db = faiss.IndexFlatIP(embedding[0].shape[0])
  7. db.add(embedding)
  8. dis, idx =db.search(embedding, 5)
  9. print(dis, idx)