软件环境
- paddlepaddle:2.6.0
- paddlepaddle-gpu:
- paddlenlp: 2.6.1
重复问题
- 我已搜索现有的问题
错误描述
当删除数据之后再增加数据时,vector_id会重复,导致SQL更新冲突
稳定复现步骤 & 代码
在更新embeddings新增数据时,vector_id会根据当前文档的数量依次递增:vector_id = sum([index.ntotal for index in self.faiss_indexes.values()])
> vector_id_map = {}
> for doc in document_batch:
> vector_id_map[str(doc.id)] = str(vector_id) + "_" + index
> vector_id += 1
> self.update_vector_ids(vector_id_map, index=index)
当删除数据后再增加数据时,vector_id可能会重复,导致SQL更新冲突:
(sqlite3.IntegrityError) UNIQUE constraint failed: document.vector_id
[SQL: UPDATE document SET vector_id=CASE document.id WHEN ? THEN ? WHEN ? THEN ? WHEN ? THEN ? END WHERE document.id IN (?, ?, ?) AND document."index" = ?]
[parameters: ('a11c96f3f9729487bb584f52e404a5a', '275_faiss_index', 'cd10279366bb16cd8a48696b179bdd3', '276_faiss_index', 'd81e0d6d84af695310371c6d915e2293', '277_faiss_index', 'a11c96f3f9729487bb584f52e404a5a', 'cd10279366bb16cd8a48696b179bdd3', 'd81e0d6d84af695310371c6d915e2293', 'faiss_index')]
(Background on this error at: https://sqlalche.me/e/14/gkpj)
3条答案
按热度按时间i7uaboj41#
提供一下最小复现代码,方便我们快速定位
5jvtdoz22#
在使用FAISSDocumentStore中的delete_documents方法删除了向量库中的部分文档后,faiss向量库会自动更新vector_id,使id保持连续。但是,SQL存储的文档库meta中的vector_id并没有更新,导致对应不上。
eqfvzcg83#
这个问题已经过时了,因为它已经开放了60天,没有任何活动。当前的问题在60天内没有活动,被标记为过时。