Semantic Memory is the part of an AI agent’s long-term memory that stores facts, concepts, and general knowledge about the world, the user, and the domain it operates in. It’s the agent’s “second brain” — a persistent, searchable repository of what the agent has learned across all conversations and sessions.
CN:
语义记忆 (Semantic Memory) 是 AI Agent 长期记忆的一部分,用于存储关于世界、用户及其操作领域的事实、概念和通用知识。它是 Agent 的”第二大脑”——一个持久化、可搜索的仓库,存储 Agent 在所有对话和会话中学到的东西。
Think of Semantic Memory as a personal wiki that an AI agent builds and maintains for itself. Every time the agent learns something new — a user preference, a business rule, a technical decision — it writes a page in this wiki. Later, when the agent faces a new situation, it can search this wiki by meaning, not just by keywords, to recall relevant knowledge.
CN:
把语义记忆想象成 AI Agent 为自己建立和维护的个人维基百科。每次 Agent 学到新东西——用户偏好、业务规则、技术决策——它就在这个维基里写一页。以后当 Agent 面对新情况时,它可以通过含义(而不仅仅是关键词)搜索这个维基,回忆相关知识。
3. What’s Inside Semantic Memory
3.1 Semantic Search
Unlike keyword search (exact word matching), semantic search retrieves memories by meaning similarity using vector embeddings. A query for “UI preferences” can surface a memory written as “user prefers dark interfaces”.
CN:
与关键词搜索(精确词匹配)不同,语义检索通过向量嵌入按含义相似度检索记忆。查询”UI 偏好”可以召回一条写为”用户喜欢暗色界面”的记忆。
3.2 CRUD + Search
| 操作 | EN | CN |
|---|---|---|
| Store | Save a fact/memory with its vector embedding | 保存事实/记忆及其向量嵌入 |
| Search | Find relevant memories by semantic similarity | 按语义相似度查找相关记忆 |
| Get | Retrieve a specific memory by ID | 按 ID 获取特定记忆 |
| Update | Modify an existing memory (with versioning) | 修改已有记忆(带版本控制) |
| Delete | Remove or deprecate outdated memories | 删除或废弃过时的记忆 |
3.3 Knowledge Organization
Memories are typically organized using:
- Namespaces (like folders): e.g.,
(user_id, "preferences"),(team_id, "decisions") - Collections (like categories): e.g.,
codebase,research,gotchas - Keypath hierarchies: e.g.,
users.alice.preferences.language
CN:
记忆通常通过以下方式组织:
- 命名空间(类似文件夹):如
(user_id, "preferences")、(team_id, "decisions") - 集合(类似分类):如
codebase、research、gotchas - 键路径层级:如
users.alice.preferences.language
3.4 Advanced Features
Production semantic memory systems often include:
- Hybrid retrieval: combining vector search + keyword (BM25) search
- Decay & forgetting: memories lose relevance over time unless validated
- Consolidation: merging duplicate or related memories
- Contradiction detection: identifying conflicting facts
- Token-budget search: fitting results into LLM context limits
CN:
生产级语义记忆系统通常包含:
- 混合检索:向量搜索 + 关键词(BM25)搜索结合
- 衰减与遗忘:记忆随时间失去相关性,除非被验证
- 整合:合并重复或相关的记忆
- 矛盾检测:识别冲突的事实
- Token预算搜索:将结果适配到 LLM 上下文限制内
Key Takeaways
| 要点 | EN | CN |
|---|---|---|
| 语义记忆存储事实、概念和通用知识 | Semantic Memory stores facts, concepts, and general knowledge | 语义记忆存储事实、概念和通用知识 |
| 语义检索按含义而非关键词查找 | Semantic search finds by meaning, not keywords | 语义检索按含义而非关键词查找 |
| 嵌入是语义检索的基础 | Embeddings are the foundation of semantic search | 嵌入是语义检索的基础 |
| 命名空间提供记忆的逻辑组织 | Namespaces provide logical organization of memories | 命名空间提供记忆的逻辑组织 |
| 生产系统需要混合检索 + 衰减 + 整合 | Production systems need hybrid retrieval + decay + consolidation | 生产系统需要混合检索 + 衰减 + 整合 |
| 记忆使 Agent 从无状态变为有状态 | Memory transforms agents from stateless to stateful | 记忆使 Agent 从无状态变为有状态 |
| ChromaDB 适合本地开发和轻量级场景 | ChromaDB is suitable for local dev and lightweight scenarios | ChromaDB 适合本地开发和轻量级场景 |
| PostgreSQL + pgvector 是生产级选择 | PostgreSQL + pgvector is a production-grade choice | PostgreSQL + pgvector 是生产级选择 |

