arXiv:2611.05791cs.AINov 2026

Manuscript Offprint

arXiv:2611.05791

FlyHash for LLM Agent Memory: An Empirical Validation and a New Application

Mohan Bheemadolu, Chrisogonas O. Odhiambo

Abstract

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.

1 Introduction

Large language model agents that operate over long or repeated interactions increasingly need memory: a way to store facts, preferences, or prior context and retrieve the relevant pieces on demand (Chhikara et al., 2025). The dominant approach embeds each memory as a dense vector and retrieves by approximate nearest-neighbor search over an index such as FAISS (Johnson et al., 2021; see also the RAG survey of Zhao et al., 2024), though hybrid retrieval architectures combining dense and lexical signals are an active and growing alternative. This works well but scales in memory and compute with the size and dimensionality of the stored embeddings, motivating interest in more

*Code: https://github.com/mohanji/flyhash-agent-memory Archive (DOI): https://doi.org/10.5281/zenodo.23903302 compact representations — in particular, hashing schemes that compress an embedding into a short binary code while preserving enough neighbor structure to remain useful for retrieval.

One such scheme, introduced by Dasgupta, Stevens, and Navlakha (2017) and directly inspired by neurobiology, computes a locality-sensitive hash the way the fruit fly's olfactory circuit is believed to encode odors: roughly 50 receptor-neuron activations are randomly and sparsely projected into approximately 2,000 "Kenyon cells," of which only the top ~5% most active are allowed to "fire," producing a sparse binary code. The original paper showed that this scheme — which we refer to as FlyHash, following subsequent literature — preserves nearest-neighbor structure better, at a matched number of output bits, than SimHash (Charikar, 2002), the standard random-hyperplane hashing baseline, on several benchmark datasets including SIFT, GloVe, and MNIST.

Despite this result and several follow-up papers extending the algorithm (surveyed in Section 2), we are not aware of any prior work applying FlyHash-style hashing specifically to LLM agent memory retrieval — a setting that is, in several respects, a natural fit: agent memories are frequently decomposed into short, numerous, semantically embedded units retrieved by similarity (Hu et al., 2026; Du, 2026; Zeng et al., 2024) — the regime this paper's evaluation targets, though we note that recent work increasingly favors structured or hierarchical retrieval over flat similarity search for longer-horizon tasks (Cao et al., 2026; Hu et al., 2026).

This paper is organized around three research questions, each answered precisely rather than in the aggregate, because — as we show below — the answers are not all the same shape:

  • RQ1. Under a protocol that correctly holds FlyHash's and SimHash's active bit counts equal (Section 3.2), does FlyHash's reported per-bit retrieval-quality advantage over SimHash hold for data representative of LLM agent memory, robustly across seeds and datasets? (Sections 4.1–4.2; answer: yes, with one specific, previously undocumented comparison pitfall that must be avoided to get there — Appendix A.)

  • RQ2. Does that quality advantage translate into an actual resource advantage — lower memory, lower query latency — in a realistic deployment, including against the dense-vector indexing methods (HNSW) practitioners use by default today? (Sections 4.3–4.4, 4.6; answer: not by default, and not relative to HNSW at ordinary scale — hashing's resource case is narrower than the quality result alone would suggest.)

  • RQ3. Does the quality advantage hold under genuine, non-circular agent-memory relevance labels, rather than the nearest-neighbor-by-embedding proxy used everywhere else in this literature (including the original FlyHash paper)? (Section 4.7; answer: yes.)

In service of these questions, the paper's contributions are: (1) the first application, to our knowledge, of FlyHash to LLM agent memory retrieval, with a working end-to-end system (Sections 3.5, 4.5); (2) the matched-active-bit protocol itself, stated precisely enough to prevent a specific conflation we discovered by reproducing a discrepancy with a published result (Section 3.2, Appendix A); (3) statistical and cross-dataset validation beyond the original paper — 10 seeds, four datasets across two modalities, a 36-configuration hyperparameter sweep, and a paired statistical analysis (Sections 4.1–4.2); and (4) an honest, multi-angle resource and deployment analysis that does not stop at the quality result — brute-force memory/latency costs, a sparse-set comparison, a direct HNSW systems baseline, and a relevance-label upgrade (Sections 4.3–4.4, 4.6–4.7).

The remainder of this paper is organized as follows. Section 2 situates this work relative to FlyHash's original paper and its algorithmic follow-ups. Section 3 describes the method, evaluation protocol, datasets, and statistical procedure. Section 4 presents results. Section 5 discusses their implications. Section 6 states limitations and future work. Appendix A gives a full account of the reproducibility investigation that motivated the corrected protocol in Section 3.2.

References (26)