面向LLM智能体记忆的FlyHash:实证验证与新应用

·

研究论文 · 2026/11/10

大型语言模型(LLM)智能体日益依赖外部记忆存储来跨对话保留信息,通常使用稠密向量嵌入和近似最近邻搜索。果蝇嗅觉回路通过稀疏随机投影和赢者通吃竞争计算局部敏感哈希(称为FlyHash),先前工作(Dasgupta等,2017)表明该方案在多个基准上比传统随机超平面哈希(SimHash)每比特更好地保留邻居结构。我们首次将FlyHash应用于LLM智能体记忆检索,并回答三个实践者需要的问题:在正确匹配比特协议下质量优势是否成立(成立,在10个种子和四个数据集上稳健,并识别和纠正了一个先前未记录的比较陷阱);该优势是否转化为实际内存和延迟节省,包括与当前默认的稠密向量索引(HNSW)相比(否:在等比特下FlyHash的编码更大且比较更慢,HNSW在普通规模下优于两种哈希方法;我们引入的稀疏集比较恢复了大部分但非全部朴素延迟差距,使哈希的实际应用范围比质量结果所暗示的更窄更具体);该优势是否在真实的、非循环的智能体记忆相关性标签下仍然存在(是)。我们精确报告所有三个答案,包括两个缩小而非夸大主要结果的答案,并发布我们的实现、一个可工作的智能体记忆演示以及我们发现和纠正的方法论陷阱的完整记录。

本文首次将FlyHash应用于LLM智能体记忆检索,并提供了严谨的实证验证,不仅确认了质量优势,还诚实地指出了实际应用中的局限(如延迟和内存开销),并发布了可复现的实现和演示,对智能体记忆系统的研究者和实践者具有重要参考价值。

Large language model (LLM) agents increasingly rely on external memory stores to retain information across conversations, typically via dense vector embeddings searched with approximate nearest-neighbor methods. The fruit fly's olfactory circuit computes a locality-sensitive hash of sensory input using a strikingly different mechanism - sparse random projection followed by winner-take-all competition - and prior work (Dasgupta et al., 2017) showed this scheme, dubbed FlyHash, preserves neighbor structure better per bit than conventional random-hyperplane hashing (SimHash) on several benchmarks. We apply FlyHash, to our knowledge for the first time, to LLM agent memory retrieval, and ask three questions a practitioner actually needs answered: does the quality advantage hold under a correctly matched-bit protocol (it does, robustly, across 10 seeds and four datasets spanning two modalities, with one specific, previously undocumented comparison pitfall identified and corrected along the way); does that advantage translate into real memory and latency savings, including against the dense-vector indexing (HNSW) practitioners default to today (no: at equal bits FlyHash's codes are larger and slower to compare than SimHash's, and HNSW dominates both hash methods at ordinary scale; a sparse-set comparison we introduce recovers most but not all of a naive latency gap, leaving hashing's practical case narrower and more specific than the quality result alone implies); and does the advantage survive genuine, non-circular agent-memory relevance labels rather than the nearest-neighbor-by-embedding proxy this literature otherwise relies on (it does). We report all three answers precisely, including the two that narrow rather than flatter the headline result, and release our implementation, a working agent-memory demo, and a full account of the methodological pitfalls we found and corrected.

阅读原文

参与讨论