nuonuo/doc/findings.md
Fam Zheng d923aa1e31 NuoNuo: Hippocampal memory module prototype
Hopfield + Hebbian hybrid memory system for LLMs.
Two nights of experiments (16 iterations), validated on LongMemEval (ICLR 2025).

Architecture:
- Single-hop: Two-Stage Hopfield (NN top-20 → softmax settle)
- Multi-hop: Hebbian W matrix with WTA pattern separation
- 64% on LongMemEval (500 questions), retrieval-only, no LLM dependency
- 4ms latency @ 20K memories, ~1GB VRAM

Key findings:
- Hopfield attention solved noise tolerance (20% → 100% vs flat Hebbian)
- WTA pattern separation enables 20K+ capacity
- Multi-hop associative chains (6 hops, CosSim=1.0) — RAG can't do this
- MiniLM-L6 is optimal (discrimination gap > absolute similarity)
- Paraphrase cue augmentation: 55% → 100% on synthetic, 36% → 64% on benchmark
- SNN encoder viable (CosSim 0.99) but not needed for current architecture
2026-04-07 10:37:24 +01:00

107 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 核心发现与反直觉结论
## 最大的突破Hopfield + Hebbian 混合架构
**exp07 的转折点**Fam 指出问题在网络结构,不在 hash 函数。
引入 Modern Hopfieldsoftmax attention over stored patterns
- 1000 bg memories 下 paraphrase recall: 20% (Flat Hebbian) → **100%** (Hopfield β=16)
- 加上 cue augmentation: 70% → **95%** (20 pairs + 2000 bg)
- Multi-hop 在 Hopfield 上同样完美3 hops, sim=1.0
- 延迟可控: 4ms @ 20K memories
**关键洞察噪声容忍不是靠更好的编码hash/SNN而是靠更好的检索机制attention-based settling。**
## 一夜实验总结
### 1. SNN 的价值不在我们预期的地方
**预期**: SNN + STDP 做记忆的存储和检索核心
**实际**:
- STDP 在记忆存储上不如简单的 Hebbian outer-product
- SNN 的 LIF 阈值非线性在检索时引入不必要的失真
- **真正有价值的是 SNN encoder 的 temporal coding**CosSim 0.99)和 neuromorphic 部署前景
### 2. Pattern Separation 才是关键,不是学习规则
**WTA (Winner-Take-All) 模式分离**是整个系统最关键的组件:
- 把高维稠密向量变成极稀疏二值码
- 容量从 ~0.14N 暴涨到 20K+
- 就是这一步让简单的 outer-product Hebbian 变得能用
生物学类比完全成立海马体中齿状回DG的模式分离是 CA3 记忆功能的前提。
### 3. Consolidation 不是你想的那样
**预期**: Replay 防止遗忘homeostasis 维持稳定
**实际**:
- Pattern separation 太强了遗忘根本不发生10 晚纯 homeostasis 后仍完美)
- Replay 在容量极限附近反而**加速遗忘**(新 outer-product 干扰旧记忆)
- Consolidation 退化为简单的存储管理问题
**深层原因**: 生物海马体需要 consolidation 是因为物理容量有限。数字系统可以直接扩大网络。
### 4. Multi-hop 是杀手级特性
**A→B→C 链式联想**: 6 跳全部完美100 条链零干扰。
这是 RAG / 向量数据库**不可能做到的**事情。
RAG 只能做: query → nearest neighbor → result (单跳)
Hebbian 能做: query → association → association → ... (多跳推理链)
### 5. 噪声容忍是最大短板
WTA 对输入微扰极其敏感noise_std=0.1 就崩溃。
这意味着**纯 Hebbian 不能用来做模糊查询**。
解决方案hybrid 架构——NN lookup (噪声容忍) + Hebbian W (多跳联想)。
### 6. 更宽的 k 比更大的 code_dim 更有用
- k=50 (16384 dim): 95% paraphrase recall
- k=20 (16384 dim): 75% paraphrase recall
- k=20 (32768 dim): 70% paraphrase recall
更多 active neurons = 更多重叠 = 更好的模糊匹配,但牺牲容量。
对个人记忆系统(< 10K memories来说k=50 是最优
## 什么有用
| 组件 | 有效性 | 用在哪 |
|------|--------|--------|
| WTA Pattern Separation | ⭐⭐⭐ | 核心不可替代 |
| Hebbian outer-product | ⭐⭐⭐ | 多跳联想存储 |
| Multi-hop chaining | ⭐⭐⭐ | 独特能力 |
| NN embedding lookup | ⭐⭐⭐ | 噪声容忍检索 |
| SNN encoder | ⭐⭐ | temporal coding + 硬件部署 |
| Coarse-to-fine recall | ⭐⭐ | 实用的 hybrid 方案 |
| Unified projection | ⭐⭐ | 多跳的前提条件 |
## 什么没用
| 组件 | 问题 |
|------|------|
| STDP trace-based learning | 不如直接 outer-product |
| Separate cue/target projections | 破坏多跳 |
| Sleep consolidation (replay) | 在大网络中不必要在小网络中有害 |
| Soft WTA | 零区分度 |
| Multi-probe hashing | 完全不工作 |
| Learned separator (on random data) | 没有语义结构则无法学习 |
| Noisy replay for robustness | 效果微乎其微 |
## 下一步建议
### 短期(原型验证)
1. 实现 Hybrid MemoryKV store + Hebbian W
2. Gemma 4 APItext recall context injection
3. 在真实对话数据上测试
### 中期(优化)
1. FAISS 替代暴力 NN lookup
2. 在语义 embedding 上训练 learned separator需要真实数据
3. 测试 float16 W 矩阵节省一半显存
### 长期SNN 发挥价值)
1. 移植到 neuromorphic hardwareLoihi 2, SynSense
2. 探索 temporal coding 做时序记忆不只是 static embedding
3. Online STDP 学习对话中实时更新不需要 nightly batch