HHR: Hierarchical Hash Retrieval for Efficient LLM Generation
作者: Lianjun Liu, Tiantian Zheng, You Huang, Weiqi Yan, Mingte Qiu, Huazhong Liu, Xiaofeng Zhu, Yunshan Zhong
分类: cs.AI
发布日期: 2026-10-01
🔗 代码/项目: GITHUB
💡 一句话要点
提出层次哈希检索以解决大语言模型生成效率问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 哈希检索 大语言模型 长上下文推理 几何感知 学习哈希投影 稀疏注意力 模型优化
📋 核心要点
- 现有的哈希检索方法在处理长上下文时,存在汉明距离与注意力相关性不匹配的问题,导致检索准确性下降。
- 本文提出层次哈希检索(HHR),通过几何感知键路由和学习哈希投影,逐步提高检索的准确性和效率。
- 在多项实验中,HHR在LongBench上平均得分提高1.10分,并在128K上下文长度下实现了3.30倍的解码加速。
📝 摘要(中文)
高效的长上下文推理对于大语言模型(LLMs)至关重要,但这带来了严重的计算瓶颈。基于哈希的检索通过将查询和键编码为二进制代码并使用汉明距离进行键选择,提供了一种高效的替代方案。然而,这导致了汉明距离与注意力相关性之间的关键不匹配。为了应对这些问题,本文提出了层次哈希检索(HHR),通过几何感知键路由(GKR)和学习哈希投影(LHP)逐步提高检索准确性。实验表明,HHR在多个LLM和基准测试中表现优越,显著提高了哈希稀疏注意力的保真度。
🔬 方法详解
问题定义:本文旨在解决现有哈希检索方法在长上下文推理中面临的汉明距离与注意力相关性不匹配的问题。这种不匹配导致低置信度键的误检和高置信度键的遗漏,影响了检索的准确性。
核心思路:HHR通过引入几何感知键路由(GKR)和学习哈希投影(LHP)来逐步提高检索的准确性。GKR通过学习头级正交变换来重新分配特征幅度,从而提高页面级的判别性,而LHP则对哈希距离进行细粒度的调整,以更好地与真实的查询-键相关性排名对齐。
技术框架:HHR的整体架构包括两个主要模块:几何感知键路由(GKR)和学习哈希投影(LHP)。GKR负责特征幅度的重分配和低置信度键的有效修剪,而LHP则通过学习投影空间来优化哈希距离与查询-键相关性的对齐。
关键创新:HHR的核心创新在于结合了GKR和LHP,使得哈希检索不仅能够抑制误检,还能恢复漏检,从而显著提高了哈希稀疏注意力的保真度。这与传统方法的本质区别在于,传统方法往往忽略了特征幅度的信息。
关键设计:在设计上,GKR采用了头级正交变换来优化特征幅度,而LHP则通过学习的方式来构建投影空间。具体的损失函数和网络结构细节在实验中进行了验证,以确保模型的有效性和鲁棒性。
🖼️ 关键图片
📊 实验亮点
HHR在多项实验中表现出色,特别是在LongBench基准测试中,平均得分提高了1.10分。在128K上下文长度下,HHR实现了3.30倍的解码速度提升和2.83倍的端到端速度提升,显著优于现有方法。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理、信息检索和对话系统等。通过提高大语言模型在长上下文推理中的效率,HHR能够在实际应用中显著提升用户体验,尤其是在需要快速响应的场景中。未来,该方法可能会推动更高效的模型设计和应用开发。
📄 摘要(原文)
Efficient long-context inference is essential for large language models (LLMs), yet it poses a severe computational bottleneck. Hash-based retrieval offers an efficient alternative by encoding queries and keys into binary codes and using Hamming distance for key selection. However, this leads to a critical mismatch between Hamming distance and attention relevance. Query-Key logits depend jointly on directional similarity and feature magnitudes, whereas hash binarization discards magnitude information, causing both false-positive retrieval of low-logit keys and false-negative omission of high-logit keys. To address these failures, we propose Hierarchical Hash Retrieval (HHR), a coarse-to-fine framework that progressively improves retrieval accuracy through Geometry-Aware Key Routing (GKR) and Learned Hash Projection (LHP). GKR learns a head-wise orthogonal transformation to redistribute feature magnitudes and derive more discriminative page-level logit bounds, enabling effective pruning of low-logit keys while preserving important candidates. LHP then learns a head-wise projection space that aligns Hamming distance with the true Query-Key relevance ranking for fine-grained retrieval. By combining GKR and LHP, HHR suppresses false positives and recovers false negatives, substantially improving the fidelity of hash-based sparse attention. Extensive experiments across diverse LLMs and benchmarks demonstrate that HHR achieves superior performance over existing methods. For example, on LongBench, HHR improves the average score by 1.10 points and, at a context length of 128K, achieves up to a 3.30x decoding speedup and a 2.83x end-to-end speedup for Llama-3.1-8B-Instruct. The code is publicly available at https://github.com/lianjunl13-sudo/HHR.