如何将Faiss索引写入内存?

问题描述 投票:0回答:2

我想写一个

faiss
索引来备份到云端。 我可以使用
faiss.write_index(filename, f)
将其写入本地文件。 但是,我宁愿将其转储到内存以避免不必要的磁盘 IO。

我尝试传入

StringIO
ByteIO
流,但我从
swig
层收到这些错误。

TypeError: Wrong number or type of arguments for overloaded function 'write_index'.
  Possible C/C++ prototypes are:
    faiss::write_index(faiss::Index const *,char const *)
    faiss::write_index(faiss::Index const *,FILE *)
    faiss::write_index(faiss::Index const *,faiss::IOWriter *)

关于如何

write_index
记忆有什么想法吗?

python swig stringio faiss
2个回答
3
投票

在这里找到了这个

chunk = faiss.serialize_index(index)

0
投票

来自Github问题

您可以使用以下内容:

faiss.write_index(index, filename)
© www.soinside.com 2019 - 2024. All rights reserved.