Memory V2

# Memory V2 Skill

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Memory V2" with this command: npx skills add yuyonghao-123/yuyonghao-memory-v2

Memory V2 Skill

version: 0.1.0

OpenClaw 记忆系统 v2 - 向量记忆 + 知识图谱 + 实体提取 + 自动管理

功能特性

  • 向量记忆: LanceDB + BGE 嵌入,语义相似度搜索
  • 知识图谱: 轻量图存储,实体关系管理
  • 实体提取: 中文 NER,自动链接到图谱
  • 记忆管理: 优先级评分、自动遗忘、压缩归档

安装

cd skills/memory-v2
npm install

快速开始

import MemorySystem from './src/memory-system.js';

// 创建实例
const memory = new MemorySystem({
  dbPath: './vector-db',
  embedModel: 'Xenova/bge-large-zh-v1.5',
  nerModel: 'Xenova/bert-base-chinese-ner'
});

// 初始化
await memory.initialize();

// 添加记忆
await memory.addMemory({
  id: 'mem_001',
  content: '蒲萄爸喜欢喝普洱茶,住在上海浦东新区',
  metadata: { importance: 0.8 }
});

// 语义搜索
const results = await memory.search('蒲萄爸住在哪里', 5);
console.log(results);

// 获取统计
const stats = await memory.getStats();
console.log(stats);

API 参考

MemorySystem

构造函数

new MemorySystem(config)

参数:

  • config.dbPath - 向量数据库路径(默认:./vector-db)
  • config.embedModel - 嵌入模型(默认:Xenova/bge-large-zh-v1.5)
  • config.nerModel - NER 模型(默认:Xenova/bert-base-chinese-ner)
  • config.llm - LLM 接口(用于摘要,可选)
  • config.forgetThreshold - 遗忘阈值(默认:0.2)

方法

addMemory(memory)

添加记忆(自动提取实体并链接到图谱)

await memory.addMemory({
  id: 'mem_001',
  content: '记忆内容',
  metadata: { importance: 0.8 }
});
search(query, topK)

语义搜索记忆

const results = await memory.search('查询文本', 10);
getMemory(id)

获取记忆详情(包含关联实体)

const memory = await memory.getMemory('mem_001');
deleteMemory(id)

删除记忆

await memory.deleteMemory('mem_001');
runMaintenance()

运行记忆管理(遗忘、压缩低优先级记忆)

const stats = await memory.runMaintenance();
getStats()

获取系统统计

const stats = await memory.getStats();
close()

关闭系统

await memory.close();

独立组件

也可以单独使用各个组件:

import VectorStore from './src/vector-store.js';
import GraphStore from './src/graph-store.js';
import NERExtractor from './src/ner-extractor.js';
import MemoryManager from './src/memory-manager.js';

性能指标

操作目标延迟实际表现
嵌入生成<100ms/文档~80ms
语义搜索<200ms (Top-10)~150ms
实体提取<100ms/文档~90ms
图遍历<50ms (2 跳)~30ms

技术栈

  • 向量数据库: LanceDB
  • 嵌入模型: BGE-large-zh-v1.5(中文 SOTA)
  • NER 模型: BERT-base-Chinese-NER
  • 图存储: 自研轻量图(JSONL 格式)
  • 缓存: LRU 内存缓存

注意事项

  1. 首次运行: 会自动下载模型(~500MB),需要网络连接
  2. 存储空间: 向量数据库会随记忆数量增长
  3. 内存使用: 嵌入缓存默认 1000 条,可配置
  4. 中文优化: 使用中文专用模型,英文效果可能不佳

开发计划

  • 支持多模态记忆(图像、音频)
  • 图查询语言(类似 Cypher)
  • 分布式存储支持
  • 记忆可视化界面

License

MIT

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

gitlab-mr-reviewer

当需要审核 GitLab 合并请求、检查 MR diff 风险、发布 GitLab 审查评论、执行 approve/request changes,或发送 MR 审查通知时使用。

Registry SourceRecently Updated
1490whrime
General

Voice Transcriber Toolkit

Voice-to-Text Transcription Toolkit - 语音识别转文字,支持Whisper/Vosk引擎,批量处理,字幕导出 | Speech recognition & transcription with Whisper/Vosk engines, batch processing, su...

Registry SourceRecently Updated
General

Gigo Lobster Taster

🦞 GIGO · gigo-lobster-taster: 正式试吃模式:跑完整评测,默认上传云端、生成个人结果页并进入排行榜。 Triggers: 试吃我的龙虾 / 品鉴我的龙虾 / lobster taste / lobster taster.

Registry SourceRecently Updated
General

Gigo Lobster Local

🦞 GIGO · gigo-lobster-local: 本地模式:跑完整评测,但不上云、不注册个人结果页,证书二维码回到官网首页。 Triggers: 本地试吃龙虾 / 离线试吃龙虾 / local lobster taste / offline lobster taste.

Registry SourceRecently Updated