Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use lru_cache to optimize loading of local vector store #496

Merged
merged 3 commits into from
May 30, 2023
Merged

use lru_cache to optimize loading of local vector store #496

merged 3 commits into from
May 30, 2023

Conversation

liunux4odoo
Copy link
Collaborator

问题

当前local_doc_qa的实现中,每回答一次问题都要执行一次FAISS.load_local重新加载知识库,哪怕用户选择的是同一个知识库。对于较大的知识库(1G以上),重新加载知识库带来明显的延迟。

解决建议

利用lru_cache缓存FAISS.load_local的结果,把所有调用FAISS.load_local的地方替换成load_vector_store即可实现知识库的缓存加载。用户可通过在model_config.py中设置CACHED_VC_NUM变量来调整缓存知识库的数量。

在测试中,基于1.5G的知识库,通过缓存明显地降低了LLM开始回答问题前的等待时间。如果以后开发了跨知识库查询的功能,更是能显著降低延迟。

@imClumsyPanda imClumsyPanda changed the base branch from master to dev May 30, 2023 15:05
@imClumsyPanda imClumsyPanda merged commit 88fee48 into chatchat-space:dev May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants