CRINN:基于对比强化学习的近似最近邻搜索
CRINN: Contrastive Reinforcement Learning for Approximate Nearest Neighbor Search
August 4, 2025
作者: Xiaoya Li, Xiaofei Sun, Albert Wang, Chris Shum, Jiwei Li
cs.AI
摘要
近似最近邻搜索(ANNS)算法在近期的AI应用中变得愈发关键,尤其是在检索增强生成(RAG)和基于代理的大语言模型(LLM)应用中。本文中,我们提出了CRINN,一种ANNS算法的新范式。CRINN将ANNS优化视为一个强化学习问题,其中执行速度作为奖励信号。这一方法能够在保持精度约束的同时,自动生成速度逐步提升的ANNS实现。我们的实验评估展示了CRINN在六个广泛使用的NNS基准数据集上的有效性。与当前最先进的开源ANNS算法相比,CRINN在其中三个数据集(GIST-960-Euclidean、MNIST-784-Euclidean和GloVe-25-angular)上取得了最佳性能,并在另外两个数据集(SIFT-128-Euclidean和GloVe-25-angular)上并列第一。CRINN的成功意义远不止于ANNS优化:它验证了结合强化学习的LLM可以作为自动化复杂算法优化的有效工具,这些优化通常需要专业知识和大量手动调优。代码可在https://github.com/deepreinforce-ai/CRINN获取。
English
Approximate nearest-neighbor search (ANNS) algorithms have become
increasingly critical for recent AI applications, particularly in
retrieval-augmented generation (RAG) and agent-based LLM applications. In this
paper, we present CRINN, a new paradigm for ANNS algorithms. CRINN treats ANNS
optimization as a reinforcement learning problem where execution speed serves
as the reward signal. This approach enables the automatic generation of
progressively faster ANNS implementations while maintaining accuracy
constraints. Our experimental evaluation demonstrates CRINN's effectiveness
across six widely-used NNS benchmark datasets. When compared against
state-of-the-art open-source ANNS algorithms, CRINN achieves best performance
on three of them (GIST-960-Euclidean, MNIST-784-Euclidean, and
GloVe-25-angular), and tied for first place on two of them (SIFT-128-Euclidean
and GloVe-25-angular). The implications of CRINN's success reach well beyond
ANNS optimization: It validates that LLMs augmented with reinforcement learning
can function as an effective tool for automating sophisticated algorithmic
optimizations that demand specialized knowledge and labor-intensive manual
refinement.Code can be found at https://github.com/deepreinforce-ai/CRINN