360 Secure SkillHub
360 安全技能中心

Deep Memory

这是AI代理的生产级语义记忆系统,核心功能含热/温/冷分层文件存储、Qdrant向量相似检索、Neo4j实体关系管理,搭载本地qwen3-embedding模型,无API调用成本。典型场景为AI代理跨会话记忆用户偏好、历史决策,支持单语义搜索、向量+图联合查询。通过Python代码调用,输出匹配的记忆内容及评分或关联结果,需Docker与Ollama依赖,一键即可部署。

halfmoon82
halfmoon82
热度 73.47
最近更新 2026-05-11 17:32:28
分类:开发依赖:代码执行 / 读写文件 / 第三方 API应用场景:代码生成 / API 集成 / 数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add deep-memory
Metadata
name
deep-memory
version
1.0.0
description
One-click clone of a production-grade semantic memory system: HOT/WARM/COLD tiered storage + Qdrant vector DB + Neo4j graph DB + qwen3-embedding. Enables cross-session semantic retrieval and entity relationship memory for AI agents.
author
DeepEye
tags
["memory","vector-db","neo4j","qdrant","embedding","semantic-search","agent-memory"]
requires
["docker","ollama"]

Deep Memory Skill 🧠

A production-grade semantic memory system for AI agents. Combines tiered file storage with vector search and graph relationships.

Architecture

┌─────────────────────────────────────┐
│        File Layer (always-on)        │
│  HOT / WARM / COLD Markdown files   │
│  semantic_memory.json               │
└──────────────┬──────────────────────┘
               ↓
┌─────────────────────────────────────┐
│        Vector Layer (Docker)         │
│  Qdrant: semantic similarity search │
│  Collection: semantic_memories       │
│  Dimensions: 4096 (qwen3-embedding)  │
└──────────────┬──────────────────────┘
               ↓
┌─────────────────────────────────────┐
│        Graph Layer (Docker)          │
│  Neo4j: entity relationship memory  │
│  Constraints: Memory.key + Entity.id │
└─────────────────────────────────────┘
               ↓
┌─────────────────────────────────────┐
│     Embedding Model (Ollama)         │
│  qwen3-embedding:8b (4096 dims)      │
│  Local, free, no API calls          │
└─────────────────────────────────────┘

Prerequisites

  • Docker Desktop (running)
  • Ollama installed (brew install ollama on macOS)

Usage

Setup (first time)

python3 ~/.openclaw/workspace/skills/deep-memory/scripts/setup.py

Write a memory

from deep_memory import MemorySystem
mem = MemorySystem()
mem.store("user_sir", "Sir prefers direct communication, no pleasantries", tags=["preference", "communication"])

Search memories

results = mem.search("how does Sir like to communicate?", top_k=5)
for r in results:
    print(r['content'], r['score'])

Joint query (vector + graph)

results = mem.joint_query("investment strategy", entity="Sir", top_k=3)

Setup Flow

When triggered, the setup script will:

  1. Check Docker is running
  2. Check Ollama is installed and pull qwen3-embedding:8b if needed
  3. Start Qdrant container (port 6333/6334)
  4. Start Neo4j container (port 7474/7687)
  5. Create Qdrant collection (semantic_memories, 4096 dims, Cosine)
  6. Create Neo4j constraints (Memory.key, Entity.id)
  7. Create HOT/WARM/COLD directory structure
  8. Copy Python toolkit to workspace
  9. Run end-to-end verification test

Agent Integration

In your SOUL.md or AGENTS.md, add:

## Memory Retrieval
Before answering questions about prior work, decisions, or preferences:
1. Run: python3 ~/.openclaw/workspace/.lib/qdrant_memory.py search "<query>"
2. Combine with memory_search tool results
3. Use top results as context