Install
openclaw skills install qst-memory-system基於QST理論實現短期與長期混合記憶管理,支持語義檢索與毫秒級快速存取對話上下文。
openclaw skills install qst-memory-systemOpenClaw Skill - QST Matrix-based Memory System
利用 QST 理論(E8 幾何結構、DSI 層次、ICT Collapse)實現高效記憶存取。
cd /root/.openclaw/workspace/skills
git clone https://github.com/ZhuangClaw/qst-memory-system.git qst-memory
在 SKILL.md 同目錄創建 config.json:
{
"e8_dim": 16,
"top_k": 5,
"storage_type": "hybrid",
"embedding_type": "simple"
}
from qst_memory_skill import QSTMemorySkill
# 初始化
memory = QSTMemorySkill()
# 存儲對話
memory.store("用戶說的話", "user")
memory.store("AI的回覆", "assistant")
# 檢索相關記憶
results = memory.retrieve("查詢關鍵詞")
# 獲取對話上下文
context = memory.get_context()
from qst_memory import QSTMemory
# 完整初始化
memory = QSTMemory(
e8_dim=16, # E8 投影維度
top_k=5 # 檢索返回數量
)
# 存儲對話輪次
memory.store_conversation("user", "你好!", "user")
memory.store_conversation("assistant", "秦王陛下萬歲!", "assistant")
# 檢索
results = memory.retrieve("皇帝", top_k=3)
for r in results:
print(f"[{r.total_score:.3f}] {r.memory.content}")
# 整合到長期記憶
memory.consolidate()
# 獲取 coherence 狀態
info = memory.get_coherence_info()
print(info)
┌─────────────────────────────────────────────────────────┐
│ QST Memory Skill │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Short │◄──►│ QST │◄──►│ Long │ │
│ │ Memory │ │ Matrix │ │ Memory │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │Conversation │ │ ICT │ │ SQLite/ │ │
│ │ Buffer │ │ Retrieval │ │ JSON │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘
| σ 值 | 意義 |
|---|---|
| 0.7 | Working Memory |
| 0.85 | Short Memory |
| 0.95 | Medium Memory |
| 1.1 | Long Memory |
D_n = D_0 - n·φ²
n ∈ [0, 36]
φ = 1.618... (黃金比例)
P(M) ∝ |⟨Q|Ψ_M⟩|² · exp(-η·V_eth)
| 方法 | 功能 |
|---|---|
store(content, context) | 存儲記憶 |
store_conversation(speaker, content, type) | 存儲對話 |
retrieve(query, top_k) | 檢索記憶 |
get_context() | 獲取上下文 |
consolidate() | 整合到長期記憶 |
decay_all() | 衰減低 coherence 記憶 |
| 方法 | 功能 |
|---|---|
store(content, context) | 存儲 |
retrieve(query, top_k) | 檢索 |
get_context() | 上下文 |
基於 QSTv7.1 框架 作者:李斯 (丞相)