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.1.tar.gz (51.8 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.1-cp38-abi3-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

cabinet_hsh-0.1.1-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.1-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.1-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.1.tar.gz.

File metadata

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

File hashes

Hashes for cabinet_hsh-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45d3a9ad07cee06c4c745c3b67404a36e4b24d98a71d27deab005883f0819f5f
MD5 e1fe9672f61121b440a2eb03b4678759
BLAKE2b-256 b760a1308817a2d45b6e9fa99eb8fd7c578abc79bd76f6abb436aa238b9c7df1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cabinet_hsh-0.1.1-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.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9d6b01c99a0a24c7c56f27a3f55ffbe1f1094cd4bb15de1202e3878554d82391
MD5 db30c64c40fab5eccafa638a2df0c6d9
BLAKE2b-256 92374348ad74e962728ec33d92690d21748c9532a79f2ab8cf80dc15c339dc77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cabinet_hsh-0.1.1-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.1-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 706a7596116e8ab295abce46652dfb63cea13954db984ef4a58eca099265627f
MD5 6043ef17ef74c608d0ad35d5de83d204
BLAKE2b-256 a1c237c6383b1410b1cdbf05440842ca5ea57a5fe6d4e8b5b9f685f9fbeff07c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cabinet_hsh-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 210feda45e4028be4e2ff79e61f5b3419b152ba14176ac26a14bb08252737c9b
MD5 5644e8cbc4711eb3439ce4d47c8a6110
BLAKE2b-256 5f347fbf2cd053e834c066fbab6a016300cd758e6acb9ee47049edced5d6a46b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cabinet_hsh-0.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 49dffdb2430384d29dc19807cc8898065fa882d4891f168423d1551bc6a67590
MD5 a1cc380181afa6980769e1fe40e42f1b
BLAKE2b-256 4a1cc34d83ecc5c28f6db27ee0147ca42a5a684435509b3e1ddbd399dc2af0c2

See more details on using hashes here.

File details

Details for the file cabinet_hsh-0.1.1-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.1-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 81ed591848bb546ecd72ef8c46de792d234955767dda0854d4ed136c138ed15a
MD5 b37d3efdc372ae0997b179bb74854730
BLAKE2b-256 fb0c31d3a338ad12e96e3cd25c7336e29bc5d8d854f640816e74dab8d09c2c11

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