Files
myWiki/concepts/conditional-memory.md

47 lines
1.9 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.

---
title: "Conditional Memory"
created: 2026-06-25
updated: 2026-06-25
type: concept
tags: ["sparsity", "architecture", "memory", "transformer"]
sources:
- "[[engram-conditional-memory-2026]]"
---
# Conditional Memory
Conditional Memory 是 Engram 提出的一种新稀疏轴,与 Mixture-of-Experts 的 Conditional Computation 形成互补。
## 基本定义
| 维度 | Conditional Computation (MoE) | Conditional Memory (Engram) |
|------|------|------|
| 原语 | 稀疏参数激活 | 稀疏嵌入查找 |
| 操作 | 路由到专家子网络 | 哈希索引嵌入表 |
| 开销 | 随专家数增长 | O(1) 常数 |
| 适用 | 动态推理、上下文组合 | 静态知识、局部模板 |
## 为什么需要
语言建模包含两类异质子任务:
1. **组合推理**:需要深层、动态的非线性计算
2. **知识检索**:命名实体、公式化表达等局部静态模式天然适合查找
Transformer 缺少原生的知识查找原语,被迫用计算模拟检索。例如,解析一个常见的多 token 实体需要消耗多个早期的 Attention 和 FFN 层——本质是用昂贵的计算重建一个静态查找表。
## 与 MoE 的关系
MoE 通过条件计算扩展模型容量Engram 通过条件记忆扩展模型容量。二者共享同一个稀疏参数预算,通过 [[sparsity-allocation|Sparsity Allocation]] 进行最优分配。U 形缩放律表明:纯 MoE 和纯 Engram 都不如混合——最优分配约 75-80% 给 MoE20-25% 给记忆。
## 表现形式
- **Engram**:基于 N-gram 嵌入的现代条件记忆实现(多哈希头、上下文门控、深度可分离卷积)
- **OverEncoding**:通过平均将 N-gram 嵌入融入词表嵌入(较弱的基线)
- 理论上,任何提供 O(1) 或近似常数时间查找的机制都可以是条件记忆的实例
## 参考
- [[engram-conditional-memory-2026]]
- [[mixture-of-experts]]
- [[engram]]
- [[sparsity-allocation]]