How do I persist FAISS indexes?

题意:如何持久化FAISS索引?

问题背景:

In the langchain wiki of FAISS, Faiss | 🦜️🔗 LangChain, it only talks about saving indexes to files.

在FAISS的LangChain维基页面上,它只讨论了将索引保存到文件中。

db.save_local("faiss_index")

new_db = FAISS.load_local("faiss_index", embeddings)

docs = new_db.similarity_search(query)

How can I save the indexes to databases, such that we can organize and concurrently access multiple indexes?

我如何能将索引保存到数据库中,以便我们可以组织和并发访问多个索引?

Searched online but could not get much info on this. Can FAISS be used with any kind of distributed databases?

我在网上搜索过,但关于这方面的信息不多。FAISS 可以与任何类型的分布式数据库一起使用吗?

问题解决:

In fact, FAISS is considered as an in-memory database itself in order to vector search based on similarity that you can serialize and deserialize the indexes using functions like write_index and read_index within the FAISS interface directly or using save_local and load_local within the LangChain integration which typically uses the pickle for serialization.

事实上,FAISS 本身被视为一种内存数据库,用于基于相似性的向量搜索。你可以使用 FAISS 接口内的 write_index 和 read_index 函数,或者直接在 LangChain 集成中使用 save_local 和 load_local(后者通常使用 pickle 进行序列化)来序列化和反序列化索引。

If you need to store serialized files, you could manually save them in a NoSQL database like MongoDB as binary data, and then deserialize and retrieve them when needed, however, it is not the best practice!

如果你需要存储序列化后的文件,你可以手动将它们作为二进制数据保存在像 MongoDB 这样的 NoSQL 数据库中,然后在需要时再进行反序列化和检索。然而,这并不是最佳实践!

If you are looking for a vector database that is not in-memory and capable in a scalable system, you might want to consider using Milvus which is designed for this purpose.

如果你正在寻找一个不是内存内且能够在可扩展系统中使用的向量数据库,那么你可能想考虑使用 Milvus,它是为此目的而设计的。

  • 27
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据你提供的引用内容,你遇到的错误是"Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/pinia-plugin-persist.js?v=ca9d16b3' does not provide an export named 'pinaPluginPersist'"。这个错误通常是由于模块导出的名称不匹配导致的。 根据你提供的引用内容,我注意到你在Vue 3中使用了新的导入语法`import * as VueRouter from 'vue-router'`,而不是Vue 2中的`import Router from 'vue-router'`。这是因为在Vue 3中,Vue Router的导入方式发生了变化。 另外,你还提供了Vue Router的配置代码。根据你的代码,你使用了`createRouter`和`createWebHashHistory`来创建路由实例,并配置了路由规则。这些配置在Vue 3中是正确的。 然而,根据你提供的引用内容,你遇到的错误与Vue Router的配置无关。这个错误是关于一个名为'pinaPluginPersist'的导出名称的问题。根据错误信息,它指出请求的模块没有提供名为'pinaPluginPersist'的导出。 要解决这个错误,你可以检查你的代码中是否有使用'pinaPluginPersist'这个导出名称的地方。确保你正确导入和使用了这个模块,并且导出名称是正确的。如果你不确定正确的导出名称是什么,可以查看相关的文档或示例代码来获取正确的导出名称。 总结一下,你遇到的错误是由于请求的模块没有提供名为'pinaPluginPersist'的导出。你可以检查你的代码中是否正确导入和使用了这个模块,并确保导出名称是正确的。如果你需要进一步的帮助,请提供更多的代码和错误信息。 #### 引用[.reference_title] - *1* *2* [Uncaught SyntaxError: The requested module ‘/node_modules/.vite/deps/vue-router.js?v=0d658a16‘ do....](https://blog.csdn.net/weixin_55939638/article/details/129715463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值