如何将Faiss索引写入内存?

huangapple go评论75阅读模式
英文:

How ot write a Faiss index to memory?

问题

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

我尝试传递StringIOByteIO流,但我从swig层得到以下错误。

TypeError: 重载函数'write_index'的参数数量或类型错误
  可能的C/C++原型是
    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写入内存的任何想法吗?

英文:

I want to write a faiss index to back it up on the cloud.
I can write it to a local file by using faiss.write_index(filename, f).
However, I would rather dump it to memory to avoid unnecessary disk IO.

I tried passing in a StringIO or ByteIO stream, but I'm getting these error from the swig layer.

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 *)

Any idea on how to write_index to memory?

答案1

得分: 2

这里找到了这个代码部分:

chunk = faiss.serialize_index(index)
英文:

Found this here

chunk = faiss.serialize_index(index)

huangapple
  • 本文由 发表于 2023年6月1日 23:46:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76383659.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定