Skip to main content

mykb

本地知识库搜索引擎 CLI,支持 BM25 全文搜索 + 向量语义搜索的混合检索。

特性

  • Hybrid Search: BM25 全文 + 向量语义混合搜索
  • 本地 Embedding: 使用 embeddinggemma-300m 本地生成 embedding,无需 API
  • 多数据源: 目前支持 Obsidian vault,可扩展 Twitter、Telegram 等
  • 增量索引: 基于内容 hash,只索引变化的文档
  • 可插拔后端: 支持 Meilisearch 和 SeekDB

安装

# 基础安装(Meilisearch 后端)
pip install mykb

# 带 SeekDB 支持
pip install mykb[seekdb]

依赖

  • Meilisearch 后端: 需要运行 Meilisearch 服务
  • SeekDB 后端: 嵌入式模式无需外部服务(macOS 15+ / Linux)

快速开始

# 1. 配置 Meilisearch
mykb config set meilisearch.url http://localhost:7700

# 2. 添加 collection(Obsidian vault)
mykb collection add my-notes --path ~/Documents/Obsidian --source obsidian

# 3. 索引(含 embedding)
mykb index my-notes --embed

# 4. 搜索
mykb search "机器学习"          # BM25 全文
mykb vsearch "AI 技术趋势"      # 向量语义
mykb query "深度学习入门" --ratio 0.5  # 混合搜索

配置

配置文件: ~/.mykb/config.toml

[backend]
type = "meilisearch"  # 或 "seekdb"

[backend.meilisearch]
url = "http://localhost:7700"
api_key = ""

[backend.seekdb]
path = "~/.mykb/seekdb.db"  # 嵌入式模式
fulltext_analyzer = "ik"     # ik | space | ngram

[embedding]
model = "google/embeddinggemma-300m"
chunk_size = 800
chunk_overlap = 0.15

[collections.my-notes]
source = "obsidian"
path = "/path/to/vault"
mask = "**/*.md"
exclude = [".obsidian/**", ".trash/**"]

命令

命令 说明
mykb collection add/ls/rm 管理 collection
mykb index [--embed] [--full] 索引文档
mykb embed [--full] 补充 embedding
mykb search <query> BM25 全文搜索
mykb vsearch <query> 向量语义搜索
mykb query <query> [--ratio] 混合搜索
mykb status 查看状态

后端对比

特性 Meilisearch SeekDB
部署 独立服务 嵌入式 / 服务
BM25 速度 ⚡ 快 (~2ms) 慢 (~30ms)
Vector 速度 快 (~3ms) ⚡ 更快 (~1ms)
Hybrid 速度 ⚡ 快 (~4ms) 慢 (~33ms)
资源占用 低 高

建议:

  • 通用场景用 Meilisearch
  • 纯向量搜索场景可考虑 SeekDB

开发

# 安装开发依赖
uv sync --all-extras

# 运行测试
uv run pytest

# Benchmark
uv run python scripts/benchmark_seekdb.py --backend meilisearch -n 1000

License

MIT

Metadata

Release files for mykb 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mykb 0.2.0
File Size Uploaded Provenance
mykb-0.2.0.tar.gz 23.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mykb 0.2.0
File Interpreter ABI Platform
mykb-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 56.7 kB

Release files / mykb-0.2.0.tar.gz

Download URL mykb-0.2.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1639db8bbe739ccbc4daf036f4a627aecd54ea084d5b9b1d71974a923da80cde
BLAKE2b-256 checksum
How to use checksums
a8e3f8625e5ccd2f6dd922d3bb8b178b1311aa3b2d7bbee0483216dedd877649
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mykb-0.2.0-py3-none-any.whl

Download URL mykb-0.2.0-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d852c2cbc8ba13109526950a9dbd10e6de2483ab382cdb37fd60e60a9c9f88e0
BLAKE2b-256 checksum
How to use checksums
6212d2bebb3511f9d2051f65cd82dc912e42bdaf50b709a46e53003a6a1e9c02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mykb 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page