#5606·faiss

clone_index() 丢失了 ArrayInvertedListsPanorama 存储

作者: leemeii创建于 2026年9月8日更新于 2026年9月8日

□ 环境

  • 财务信息系统`v1.15.0'
  • `faiss-cpu==1.1.5.0'

□ 说明

在训练有素和人口密集的IndexIVFFlatPanorama'上呼叫faiss.clone index ()' API,返回的物体的Python类型仍然是IndexIVFFlatPanorama',但其倒数列表被降级为普通ArrayInvertedLists'。

克隆无法执行正常的“ 搜索( ) ” 方法并生成:

页:1 运行时错误: IndexIVFFlatPanorama 需要矩阵 逆变列表 Panorama


原始索引搜索成功并返回精确的零距离。 这是决定性的克隆/API正确性失败,而不是ANN召回错失,量化效应,平分,或容忍问题.

□ 最小复制

[Python]
导入窗体
将数字导入为 np

d = 4个
x = np.array ([[1, 1, 1], [11, 11, 11, 11]], "float32")
列车=np.array ([[0, 0, 0, 0]]]] * 2 + [[10, 10, 10, 10, 10]]] * 2,"浮行32").

指数=faiss.index factory(d,"IVF2,FlatPanorama2 2") 互联网档案馆的存檔,存档日期2014-12-2.
指数.cp.min points per centroid=1
指数.nprobe = 2
index.train(火车)
索引.add(x)

print(type (index).). name ,类型 (index.invlists). name .
print(index.search(x, 1)[0].ravel (.tolist ()) 页面存档备份.

克隆 = faiss.clone index(index)
print( type (clone) ). . name , type (clone.invlists). . name .
clone.search(x, 1) (中文(简体) ).

观察:

页:1 IndexIVFFlatPanorama 矩阵 倒置列表 倒置列表 倒置列表 倒置列表 [0.0、0.0] 索引IVFFlatPanorama 矩阵 运行时错误: IndexIVFFlatPanorama 需要矩阵 逆变列表 Panorama

□ 根源

`cloone-IndexIVF'明确承认`IndexIVFFlatPanorama',但一般`clone-InvertedLists'的帮助者首先检查基准等级:

翻译:
如果(自动 * AILs = 动态  cast < contray InvertedLists > (invlists)) {
返回新的矩阵倒转列表( * ails);
{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?

由于 " Array InvertedLists Panorama " 来源于 " Array InvertedLists " ,基级分支胜出并被复制的存储被降级为 " Array InvertedLists " .

克隆物体后来到达了“IndexIVFFlatPanorama:get InvertedListScanner”,这需要“ArrayInvertedListsPanorama”。 动态投放失败并投出.

□ 建议修正

处理Array InvertedListsPanorama'之前的Array InvertedLists',在`clone InvertedLists'中,或提供专用的全景存储克隆辅助器。

请添加一个回归测试, 验证:

  1. 有效的 " IndexIVFFlatPanorama " 可被 " faiss.clone index() " 复制;
  2. 克隆人保留 " Array InvertedLists Panorama " ;
  3. 原作和克隆都可以执行 " 搜索() " ;
  4. 返回相同距离和身份证.

内容来源: facebookresearch/faiss