Skip to main content

Python bindings for Cabinet - Hierarchical Semantic Hashing memory retrieval

Project description

pycabinet

Python bindings for Cabinet — Hierarchical Semantic Hashing (HSH) memory retrieval system for AI agents.

快速开始

pip install pycabinet
import pycabinet

# 初始化记忆库
mem = pycabinet.Memory(
    path="./agent_memory.db",
    precision="light",
    pos_threshold=50,
    max_context=4096
)

# 插入记忆
mem.insert("用户明天下午3点开会,准备PPT。")
mem.insert("用户喜欢听管弦乐。")

# 检索记忆
results = mem.query("会议准备", top_k=5)
for r in results:
    print(f"[{r.score:.2f}] doc_id={r.doc_id} match_level={r.match_level}")
    if r.match_level >= 3:
        text = mem.decode(r)
        print(f"  text: {text}")

# 快照备份
mem.snapshot("./backup/2026-06-25.db")
mem.close()

安装方式

方式 命令 说明
标准安装 pip install pycabinet 下载预编译 wheel,无需 Rust
含 GUI pip install pycabinet[gui] 额外安装可视化界面依赖
开发编译 maturin develop 从源码编译,需要 Rust 工具链

核心特性

  • 20-bit HSH 编码:用结构化整数替代 768-dim 浮点向量
  • 纯 CPU 部署:无需 GPU,O(log n) 检索复杂度
  • 增量更新:仅追加写入,无需重建索引
  • 可解释检索:检索路径完全可审计(类别→簇→词)
  • 三层记忆架构:Token / Archive / Working Memory

可选 GUI 可视化

pip install pycabinet[gui]

安装后运行可视化界面:

cabinet-gui

系统要求

  • Python ≥ 3.8(CPython 3.8 / 3.9 / 3.10 / 3.11 / 3.12)
  • Windows / macOS / Linux(x86_64, aarch64)

预编译 wheel:支持上述平台,无需额外安装 Rust。
源码编译:需要 Rust 工具链(1.72+)。

架构

pycabinet (Python API)
  └── PyO3 绑定
      └── cabinet-core (Rust 核心)
          ├── cabinet-hsh     (20-bit HSH 编码)
          ├── cabinet-index   (B-tree 索引 + LSM)
          ├── cabinet-store   (SQLite 后端)
          └── cabinet-router  (关联路由)

许可

MIT OR Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cabinet_hsh-0.1.0-cp38-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows x86-64

File details

Details for the file cabinet_hsh-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: cabinet_hsh-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.3 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cabinet_hsh-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f38f0c87faf753055ab17787d9e76a307f4a1cc0343d732f933c50d7b40c035d
MD5 adff84fcecab4486791b85e60a3798b2
BLAKE2b-256 605fa4e130a8dfe16f4b09d62be96c3c7fd935f99d358e2c7c9bb73aa2f44c52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page