ANNS
1.0.0
这是ANNS SOTA算法的非常基本的库。它用C ++/C ++标准性诽谤编写,可用于在高维空间中构建和查询一个点索引。该库提供了各种用于构建和查询索引的算法。该图书馆旨在易于使用并提供相对较高的性能。
对于您来说,这是一个非常有用的工具,可以构建自己的ANNS索引杂物,而无需太多努力。
这是如何使用ANN库来构建和查询索引的一个示例。
DataSetWrapper< data_t > base, query;
GroundTruth gt;
base.load( " data/sift-128-euclidean.train.fvecs " );
query.load( " data/sift-128-euclidean.test.fvecs " );
gt.load( " data/sift-128-euclidean.cover.uniform-0-1.ivecs " );
const size_t k = 1 ;
utils::Timer timer;
// build index
HNSW< data_t , metrics::euclidean> index ( 32 , 128 );
index.set_num_threads( 24 );
timer.start();
index.build(base);
timer.stop();
cout << " Build time: " << timer.get() << endl;
// query with different parameters
ofstream out ( " hnsw_postfilter.csv " );
for ( size_t ef = 1 ; ef <= 128 ; ef++)
{
timer. reset ();
matrix_id_t knn;
matrix_di_t dis;
timer. start ();
index . search (query, k, ef, knn, dis);
timer. stop ();
out << timer. get () << " , " << gt. recall (k, knn) << endl;
}该库中使用的所有数据集都在VECS -Format中,您可以从此处下载。我已经在ANN基准标准上建立了一个框架基础,以下载数据集并将其转换为VECS -Format。您可以在ANN/数据集中找到代码。
如果您对ANN算法的三角洲开发感兴趣,则可以从基于索引的类中吸入并实现自己的算法来保留原始API。例如
template < typename data_t , typename label_t , float (*distance)( const data_t *, const data_t *, size_t )>
class PostFilterHCNNG : public HCNNG < data_t , distance>
/* ... */