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 Distribution

cabinet_hsh-0.1.2.tar.gz (59.9 kB view details)

Uploaded Source

Built Distributions

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

cabinet_hsh-0.1.2-cp38-abi3-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

cabinet_hsh-0.1.2-cp38-abi3-win32.whl (3.7 MB view details)

Uploaded CPython 3.8+Windows x86

cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

cabinet_hsh-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (8.2 MB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file cabinet_hsh-0.1.2.tar.gz.

File metadata

  • Download URL: cabinet_hsh-0.1.2.tar.gz
  • Upload date:
  • Size: 59.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for cabinet_hsh-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d66bd2ed11431b26024e48b259fcced58d6f6fa3291794e7bdf0e95484de2c2a
MD5 0be2823e79186c1f874fee6220a6eba4
BLAKE2b-256 f2abca90e712f758f67812a6ec781ac5f954bc9db1bd5d8c4fc0d616db322d8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cabinet_hsh-0.1.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.4 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.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 85fd822558fa49a6174bc00925abddd3afad42f1c9f287476b957f50f65dd71e
MD5 7a6b34c747abe8fa118524014f1e6db4
BLAKE2b-256 d77d8530de25067036f02172615577d19bb38bb02383b0586e1a75fcf4549f81

See more details on using hashes here.

File details

Details for the file cabinet_hsh-0.1.2-cp38-abi3-win32.whl.

File metadata

  • Download URL: cabinet_hsh-0.1.2-cp38-abi3-win32.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for cabinet_hsh-0.1.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 160bd2b0859317b5791d5f2b587f6806b5f60aa129d29e642088d10cec240cd2
MD5 e192578ee4e104f769cf04e5feb3b136
BLAKE2b-256 3ded502740f69c9d9dc927f1a6017d786d4cb2b7e35afe4f43f1543f1e182c9d

See more details on using hashes here.

File details

Details for the file cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 48e53533124b27a66ece1f8fbe1cd509b8e72371ae1e25f52d0bf70a621e96fc
MD5 5d6e7abfad38936dd0d64598cdf8da86
BLAKE2b-256 ad3776810354a6afd6d6c29721c413356b60a0af116f68cc67054a3882c84b72

See more details on using hashes here.

File details

Details for the file cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cabinet_hsh-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5a1b51620b78c0eac1586910081c09698b6859e99e5dcb73e34c7d37183c213b
MD5 cb40577c510634fefc9744d9298c99dc
BLAKE2b-256 1a5a61262b3b7aabd6e5d15204e932bcb00c1d54dce0b10c964c28b9cc9a7def

See more details on using hashes here.

File details

Details for the file cabinet_hsh-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for cabinet_hsh-0.1.2-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8b1ea906e7a962cc9a52f28f6d67537ad57d8c5f68b8c942e7adb2407a21bf48
MD5 c79634ea537e4b6ab58cd9cd6c9a5c1a
BLAKE2b-256 a46c0425f916cecf0343457bac4826a9670d621eabc6c0099fa67febdf2a75ac

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