AI 记忆

AI 记忆系统指南:构建有记忆的聊天机器人与 Agent

长期记忆是 2026 年 AI Agent 的关键缺口。本指南对比 11 种最活跃的记忆方案——从 mem0 语义记忆到 Graphiti 时序图谱——教你选型、部署并接入你的 LLM 应用。

mem0 — Long-term Memory for AI Agents (2026 Guide) logo

mem0 — AI Agent 的长期记忆层(2026 指南)

mem0 是一款开源记忆层,从对话中抽取并检索用户相关事实。接入 OpenAI 或 Claude 调用后,你的聊天机器人不再"失忆"。

VectorOpen sourceManaged
Zep — Memory Service for LLM Apps with Built-in Summarization logo

Zep — 内置会话摘要与混合检索的 LLM 记忆服务

Zep 是面向生产 LLM 应用的记忆服务,负责会话存储、长历史摘要、事实抽取,并通过向量+关键字+图谱混合检索返回。

SessionHybridManaged
Letta — Agent Memory OS (formerly MemGPT) logo

Letta — Agent 记忆操作系统(原 MemGPT)

Letta 是围绕 MemGPT 分页式记忆构建的状态化 Agent 框架。Agent 通过函数调用显式读写自己的记忆——生产中最透明的记忆模型。

MemGPTAgent OSOpen source
Graphiti — Temporal Knowledge Graphs for AI Agents logo

Graphiti — 面向 AI Agent 的时序知识图谱

Graphiti 从流式数据构建时序知识图谱,每条边带有效期。Agent 不仅能查"当前事实",还能查"过去某个时点的事实"。

GraphTemporalNeo4j
MemGPT — The Paper That Started Paged Agent Memory logo

MemGPT — 分页式 Agent 记忆的开山论文

MemGPT 是 2023 年 UC Berkeley 提出的论文与开源项目,首次将操作系统式内存管理引入 LLM Agent。该项目后来演化为 Letta,但核心思想仍是后续所有长期记忆框架的起点。

Paged memoryResearch
Cognitive Weaver — Experimental Agent Memory Architecture logo

Cognitive Weaver — 实验性 Agent 记忆架构

Cognitive Weaver 是偏研究向的记忆库,探索反思式记忆整合:Agent 定期审视并重写自己的记忆,而非仅仅存储。

ExperimentalGraph
Motorhead — Lightweight Redis-Backed Chat Memory Server logo

Motorhead — 基于 Redis 的轻量聊天记忆服务

Motorhead 是一个用 Rust 实现的开源记忆服务,基于 Redis 存储对话历史并维护滚动摘要,提供极简 REST API。为 LLM 应用增加"最近 N 轮 + 摘要"记忆的最简方案。

RedisLightweight
LangMem — LangChain-Native Memory SDK logo

LangMem — LangChain 原生的记忆 SDK

LangMem 是 LangChain 官方的记忆 SDK,提供语义、情景、程序性三类记忆工具,无缝接入 LangGraph Agent 与 LangChain Chain。

LangChainOpen source
LlamaIndex Memory — Built-in Memory for RAG Pipelines logo

LlamaIndex Memory — 内置于 RAG 流水线的记忆能力

LlamaIndex 内置多种记忆模块(ChatMemoryBuffer、VectorMemory、CompositeMemory),只需一个构造参数即可给 RAG 流水线加上记忆能力。

LlamaIndexBuilt-in
ChatGPT Memory — Complete Guide (2026) logo

ChatGPT Memory 完全指南(2026)

2026 年 ChatGPT Memory 工作原理全解:存什么、忘什么、如何控制,以及什么时候应该自建记忆层。

ChatGPTGuide
Vector Memory vs Graph Memory — How to Choose (2026) logo

向量记忆 vs 图记忆 — 如何选型(2026)

两种主流 AI 记忆架构的实战对比:何时用向量嵌入,何时用知识图谱,以及何时组合使用。

ComparisonArchitecture

AI 记忆的三大技术路径

Vector-based semantic memory. Tools like mem0 extract facts from conversations, embed them, and retrieve the most relevant memories when a new prompt arrives. The dominant pattern in 2024-2025 because it piggybacks on existing vector-DB infrastructure. Best for chatbot personalization and CRM-style agents. Weakness: multi-hop relationships get fuzzy.

Temporal knowledge graphs. Graphiti builds a graph of entities and edges that are valid within specific time windows — capturing not just facts but when they were true. Queries like "what did the user prefer last month vs. today?" become trivial. The right choice for long-running assistants where facts evolve over time.

Agent-native memory OS. Letta (formerly MemGPT) treats memory as a paged OS: a small working memory in-context, plus archival memory that the LLM pages in and out via explicit function calls. More operational overhead, but the only approach that gives the agent direct control over what it remembers. Strong for autonomous agents with unbounded runtime.

For most production apps, start with mem0 (simplest), reach for Zep when you need managed infrastructure + session summaries, and escalate to Graphiti or Letta only when your retrieval accuracy on long histories genuinely breaks.

常见问题

什么是 AI 记忆?+

AI 记忆是让大模型在多次对话之间保留上下文、事实或用户偏好的机制。不是把所有历史塞进 context 窗口,而是抽取、存储、按需检索相关片段。

mem0 和 Zep 怎么选?+

mem0 是开源 SDK + 可选云服务,自己掌控存储。Zep 是托管服务,自带会话摘要和混合搜索,上手更快。自建选 mem0,业务快速验证选 Zep。

RAG 和 AI 记忆是同一回事吗?+

不是。RAG 是从知识库检索外部文档;AI 记忆是积累关于用户和对话的事实。两者可以叠加:用 RAG 回答领域问题,用记忆维持个性化。

向量记忆和图记忆的核心差异?+

向量记忆按语义相似度检索,擅长"相关内容";图记忆按实体关系遍历,擅长"多跳推理"。生产系统越来越常见两者结合。