llama 索引向量存储查询与特定过滤

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

我有这个简单的代码可以从保存在色度矢量存储中的文件中查询。现在,如果每个文件属于某个用户,并且每个用户只能查询自己文件中的数据,而不能查询其他文件中的数据,我该如何实现这一点?我想也许将 userId 保存为每个文档的元数据,并使用 userId 作为过滤器进行查询,任何帮助将不胜感激。谢谢!

chroma_client = chromadb.PersistentClient(path="chroma")
chroma_collection = chroma_client.get_collection("quickstart")

vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
index = VectorStoreIndex.from_vector_store(vector_store=vector_store)

retriever = index.as_retriever(retriever_mode='embedding')
query_engine = RetrieverQueryEngine(retriever)
query_engine = index.as_query_engine()
response = query_engine.query("what's the persons name")
print(response)

我尝试从他们的网站询问助手,但它只是给出随机答案。目前正在查看他们的文档,也许可以获得一些线索。

python embedding llm llama-index chromadb
© www.soinside.com 2019 - 2024. All rights reserved.