api-and-indexing
Build, update, search, filter, and safely manage LEANN indexes through the Python API, including precomputed embeddings and hybrid or grep retrieval.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- api-and-indexing
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build, update, search, filter, and safely manage LEANN indexes through the Python API, including precomputed embeddings and hybrid or grep retrieval.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md8.9 KB
- 参考文档references/indexing-and-search-workflows.md8.3 KB
- 参考文档references/metadata-hybrid-and-grep.md6.6 KB
- 参考文档references/troubleshooting.md10.0 KB
- 脚本scripts/precomputed_index_smoke.py8.8 KB
03 SKILL.md 正文
LEANN API and Indexing
Use this sub-skill for the Python lifecycle around LeannBuilder,
LeannSearcher, passage metadata, precomputed vectors, low-level updates,
metadata filters, BM25/vector fusion, grep retrieval, and resource cleanup.
Route by task
- Verify constructors, method signatures, defaults, result fields, and artifact names in API reference.
- Implement a new build, precomputed-vector build, update, staged replacement, or cleanup flow with indexing and search workflows.
- Configure post-search metadata filters, pure BM25, hybrid retrieval, or grep with metadata, hybrid, and grep.
- Diagnose bad base paths, missing artifacts, dimension or ID mismatches, update duplication, BM25/grep failures, and daemon cleanup with troubleshooting.
- Prove a local installation and HNSW backend without a model download by running the bundled precomputed-index smoke.
Operating rules
- Treat
index_pathas a base path, not as the.meta.json,.index, or passage file. Keep every sibling artifact together. - Use a new staging directory for builds and critical updates. Validate it, then publish the whole directory; never overwrite unrelated files or delete a parent directory in response to an error message.
- Give every passage a unique string ID. For precomputed arrays, make the passage IDs and supplied vector IDs identical and order-aligned.
- Set build and query embedding configuration consistently. A precomputed build avoids document embedding, but semantic search still needs a query embedding; pure BM25 and grep do not.
- Configure recomputation on
LeannSearcher; the per-call search override is deprecated. Disable warmup and daemon use for offline BM25-only checks. - Always call
cleanup()or usewith LeannSearcher(...) as searcher:. - Treat filters as post-retrieval filters. Missing or unsupported fields do not raise by default; they remove the affected result.
- Choose update behavior from stored backend/index metadata. IVF supports remove-then-add; HNSW only supports low-level append on non-compact indexes.
Boundaries
- For CLI build/search, daemon commands, filesystem watching, or idempotent document builds, use CLI operations.
- For HNSW, IVF, DiskANN algorithms, storage modes, and backend tuning, use backends and storage.
- For embedding modes, model/provider credentials, prompt templates, and chat providers, use embeddings and chat.
- For document, email, browser, chat-history, or code ingestion applications, use RAG applications.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).