The $k$-nearest neighbors ($k$NN) algorithm is a cornerstone of non-parametric classification in artificial intelligence, yet its deployment in large-scale applications is persistently constrained by the computational trade-off between inference speed and accuracy. Existing approximate nearest neighbor solutions accelerate retrieval but often degrade classification precision and lack adaptability in selecting the optimal neighborhood size ($k$). Here, we present an adaptive graph model that decouples inference latency from computational complexity. By integrating a Hierarchical Navigable Small World (HNSW) graph with a pre-computed voting mechanism, our framework completely transfers the computational burden of neighbor selection and weighting to the training phase. Within this topological structure, higher graph layers enable rapid navigation, while lower layers encode precise, node-specific decision boundaries with adaptive neighbor counts. Benchmarking against eight state-of-the-art baselines across six diverse datasets, we demonstrate that this architecture significantly accelerates inference speeds, achieving real-time performance, without compromising classification accuracy. These findings offer a scalable, robust solution to the inherent inference bottleneck of $k$NN, laying an adaptive structural foundation for graph-based nonparametric learning.
翻译:$k$最近邻($k$NN)算法是人工智能中非参数分类的基石,然而其在大规模应用中的部署始终受到推理速度与精度之间计算权衡的限制。现有近似最近邻方法虽能加速检索,但常以分类精度下降为代价,且缺乏选择最优邻域大小($k$)的自适应能力。本文提出一种自适应图模型,将推理延迟与计算复杂度解耦。通过将分层可导航小世界(HNSW)图与预计算投票机制相整合,本框架将邻域选择及加权的计算负荷完全转移至训练阶段。在该拓扑结构中,高层图可实现快速导航,而低层图则通过自适应邻域数量编码精确的节点级决策边界。在六个不同数据集上与八种最先进基线方法的基准测试表明,本架构在保持分类精度的同时显著加速推理速度,实现了实时性能。这些发现为$k$NN固有的推理瓶颈提供了可扩展、鲁棒的解决方案,并为基于图的非参数学习奠定了自适应结构基础。