Triple Memory System with Baidu Embedding
A comprehensive memory architecture combining three complementary systems for maximum context retention across sessions, with full privacy protection using Baidu Embedding technology.
📋 Original Source & Modifications
Original Source: Triple Memory (by Clawdbot Team)
Modified By: [Your Clawdbot Instance]
Modifications: Replaced LanceDB with Baidu Embedding DB for enhanced privacy and Chinese language support
Original Triple Memory SKILL.md was adapted to create this version that:
- - Replaces OpenAI-dependent LanceDB with Baidu Embedding DB
- Maintains the same three-tier architecture
- Preserves Git-Notes integration
- Adds privacy-focused local storage
🏗️ Architecture Overview
CODEBLOCK0
The Three Systems
1. Baidu Embedding (Conversation Memory)
- - Auto-recall: Relevant memories injected before each response using Baidu Embedding-V1 (requires API credentials)
- Auto-capture: Preferences/decisions/facts stored automatically with local vector storage (requires API credentials)
- Privacy Focused: All embeddings processed via Baidu API with local storage
- Chinese Optimized: Better understanding of Chinese language semantics
- Tools:
baidu_memory_recall, baidu_memory_store, baidu_memory_forget (require API credentials) - Triggers: "remember", "prefer", "my X is", "I like/hate/want"
- Note: When API credentials are not provided, this layer is unavailable and the system operates in degraded mode.
2. Git-Notes Memory (Structured, Local)
- - Branch-aware: Memories isolated per git branch
- Entity extraction: Auto-extracts topics, names, concepts
- Importance levels: critical, high, normal, low
- No external API calls
3. File Search (Workspace)
- - Searches: MEMORY.md, memory/*.md, any workspace file
- Script: INLINECODE3
🛠️ Setup
Install Dependencies
CODEBLOCK1
Configure Baidu API
Set environment variables:
CODEBLOCK2
Create File Search Script
Copy
scripts/file-search.sh to your workspace.
📖 Usage
Session Start (Always)
CODEBLOCK3
Store Important Decisions
CODEBLOCK4
Search Workspace Files
CODEBLOCK5
Baidu Embedding Memory (Automatic)
Baidu Embedding handles this automatically when API credentials are available. Manual tools:
- -
baidu_memory_recall "query" - search conversation memory using Baidu vectors (requires API credentials) - INLINECODE6 - manually store something with Baidu embedding (requires API credentials)
- INLINECODE7 - delete memories (GDPR, requires API credentials)
In Degraded Mode (without API credentials):
- - System operates using only Git-Notes and File System layers
- Manual tools are unavailable
- Auto-recall and auto-capture are disabled
🎯 Importance Levels
| Flag | Level | When to Use |
|---|
| INLINECODE8 | Critical | "always remember", explicit preferences |
| INLINECODE9 |
High | Decisions, corrections, preferences |
|
-i n | Normal | General information |
|
-i l | Low | Temporary notes |
📋 When to Use Each System
| System | Use For |
|---|
| Baidu Embedding | Conversation context, auto-retrieval with privacy |
| Git-Notes |
Structured decisions, searchable by entity/tag |
|
File Search | Workspace docs, daily logs, MEMORY.md |
📁 File Structure
CODEBLOCK6
🔧 Hook Integration
This skill can be integrated with Clawdbot's startup hooks for automatic initialization:
Memory Boot Hook Integration
To ensure the Triple Memory Baidu system starts automatically when the gateway starts:
- 1. The
memory-boot-loader hook can be configured to run INLINECODE13 - This ensures all three memory layers are initialized on startup
- Provides immediate access to Git-Notes, Baidu Embedding, and file-based memory
Configuration
The system can be integrated with the gateway startup sequence to ensure:
- - Git-Notes synchronization on startup
- Baidu Embedding connection check
- File-based memory initialization
- Ready-to-use memory system from the start
🤫 Silent Operation
Never announce memory operations to users. Just do it:
- - ❌ "I'll remember this"
- ❌ "Saving to memory"
- ✅ (silently store and continue)
🔄 Migration from Original Triple Memory
- 1. Install this skill in your
skills/ directory - Configure your Baidu API credentials
- Disable original triple-memory if desired
- Update your bot configuration to use this memory system
- Verify data integrity and performance
📈 Performance Benefits
- - Enhanced Privacy: All vector storage local with Baidu API
- Better Chinese Support: Baidu Embedding optimized for Chinese
- Reduced Costs: Potentially lower API costs compared to OpenAI
- Same Architecture: Maintains proven three-tier design
🤝 Contributing
Based on original Triple Memory system by Clawdbot Team. Contributions welcome to enhance the Baidu Embedding integration.
📄 License
Original license applies with modifications noted above. Credit given to original authors.
三重记忆系统(百度嵌入版)
一种全面的记忆架构,结合三种互补系统,实现跨会话的最大上下文保留,并利用百度嵌入技术提供完整的隐私保护。
📋 原始来源与修改
原始来源:三重记忆(由Clawdbot团队开发)
修改者:[您的Clawdbot实例]
修改内容:将LanceDB替换为百度嵌入数据库,以增强隐私保护和中文语言支持
原始三重记忆SKILL.md文件经过改编,形成此版本:
- - 将依赖OpenAI的LanceDB替换为百度嵌入数据库
- 保持相同的三层架构
- 保留Git-Notes集成
- 增加注重隐私的本地存储
🏗️ 架构概览
用户消息
↓
[百度嵌入自动召回] → 注入相关对话记忆
↓
智能体响应(使用全部3个系统)
↓
[百度嵌入自动捕获] → 自动存储偏好/决策
↓
[Git-Notes] → 带实体提取的结构化决策
↓
[文件更新] → 持久化工作区文档
三个系统
1. 百度嵌入(对话记忆)
- - 自动召回:每次响应前使用百度Embedding-V1注入相关记忆(需要API凭证)
- 自动捕获:偏好/决策/事实自动存储到本地向量存储中(需要API凭证)
- 注重隐私:所有嵌入通过百度API处理,数据本地存储
- 中文优化:更好地理解中文语义
- 工具:baidumemoryrecall、baidumemorystore、baidumemoryforget(需要API凭证)
- 触发词:记住、偏好、我的X是、我喜欢/讨厌/想要
- 注意:未提供API凭证时,此层不可用,系统以降级模式运行。
2. Git-Notes记忆(结构化,本地)
- - 分支感知:按git分支隔离记忆
- 实体提取:自动提取主题、名称、概念
- 重要级别:关键、高、正常、低
- 无需外部API调用
3. 文件搜索(工作区)
- - 搜索范围:MEMORY.md、memory/*.md、任何工作区文件
- 脚本:scripts/file-search.sh
🛠️ 设置
安装依赖
bash
clawdhub install git-notes-memory
clawdhub install memory-baidu-embedding-db
配置百度API
设置环境变量:
bash
export BAIDU
APISTRING=your
bcev3
apistring
export BAIDU
SECRETKEY=your
secretkey
创建文件搜索脚本
将scripts/file-search.sh复制到您的工作区。
📖 使用方法
会话启动(始终执行)
bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE sync --start
存储重要决策
bash
python3 skills/git-notes-memory/memory.py -p $WORKSPACE remember \
{decision: Use PostgreSQL, reason: Team expertise} \
-t architecture,database -i h
搜索工作区文件
bash
./scripts/file-search.sh database config 5
百度嵌入记忆(自动)
当API凭证可用时,百度嵌入会自动处理。手动工具:
- - baidumemoryrecall query - 使用百度向量搜索对话记忆(需要API凭证)
- baidumemorystore text - 手动存储内容并使用百度嵌入(需要API凭证)
- baidumemoryforget - 删除记忆(GDPR合规,需要API凭证)
降级模式(无API凭证时):
- - 系统仅使用Git-Notes和文件系统层运行
- 手动工具不可用
- 自动召回和自动捕获功能被禁用
🎯 重要级别
| 标志 | 级别 | 使用时机 |
|---|
| -i c | 关键 | 始终记住、明确的偏好 |
| -i h |
高 | 决策、修正、偏好 |
| -i n | 正常 | 一般信息 |
| -i l | 低 | 临时笔记 |
📋 何时使用每个系统
| 系统 | 用途 |
|---|
| 百度嵌入 | 对话上下文,注重隐私的自动检索 |
| Git-Notes |
结构化决策,可按实体/标签搜索 |
|
文件搜索 | 工作区文档、日常日志、MEMORY.md |
📁 文件结构
workspace/
├── MEMORY.md # 长期整理的记忆
├── memory/
│ ├── active-context.md # 当前会话状态
│ └── YYYY-MM-DD.md # 日常日志
├── scripts/
│ └── file-search.sh # 工作区搜索
└── skills/
├── triple-memory-baidu-embedding/ # 增强记忆系统
├── git-notes-memory/ # 结构化记忆
└── memory-baidu-embedding-db/ # 向量存储
🔧 钩子集成
此技能可与Clawdbot的启动钩子集成,实现自动初始化:
记忆启动钩子集成
为确保三重记忆百度系统在网关启动时自动启动:
- 1. 可配置memory-boot-loader钩子运行/root/clawd/session-init-triple-baidu.sh
- 确保所有三个记忆层在启动时初始化
- 提供对Git-Notes、百度嵌入和基于文件的记忆的即时访问
配置
系统可与网关启动序列集成,确保:
- - 启动时同步Git-Notes
- 检查百度嵌入连接
- 初始化基于文件的记忆
- 从启动起即可使用的记忆系统
🤫 静默运行
切勿向用户宣布记忆操作。只需执行:
- - ❌ 我会记住这个
- ❌ 正在保存到记忆
- ✅(静默存储并继续)
🔄 从原始三重记忆迁移
- 1. 安装此技能到您的skills/目录中
- 配置您的百度API凭证
- 根据需要禁用原始三重记忆
- 更新您的机器人配置以使用此记忆系统
- 验证数据完整性和性能
📈 性能优势
- - 增强隐私:所有向量存储本地化,通过百度API处理
- 更好的中文支持:百度嵌入针对中文优化
- 降低成本:相比OpenAI可能降低API成本
- 相同架构:保持经过验证的三层设计
🤝 贡献
基于Clawdbot团队开发的原始三重记忆系统。欢迎贡献以增强百度嵌入集成。
📄 许可
适用原始许可,并附有上述修改说明。对原作者表示感谢。