hnswlib
Use hnswlib 0.9.0 for CPU approximate nearest-neighbor search through its Python bindings or C++11 header-only API, including indexing, filtering, persistence, mutation, and recall checks.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- hnswlib
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use hnswlib 0.9.0 for CPU approximate nearest-neighbor search through its Python bindings or C++11 header-only API, including indexing, filtering, persistence, mutation, and recall checks.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/installation.md2.6 KB
- 参考文档references/parameter-tuning.md2.9 KB
- 参考文档references/repo-provenance.md1.6 KB
- 参考文档references/repo-routing-metadata.json316 B
- 参考文档references/troubleshooting.md4.8 KB
- 脚本scripts/environment_smoke.py1.6 KB
03 SKILL.md 正文
hnswlib
Use this repo skill when a task needs hnswlib for approximate nearest-neighbor
(ANN) indexing, querying, filtering, persistence, updates, deletion/replacement,
parameter tuning, or exact-recall comparison. The source contract is hnswlib
0.9.0. It exposes a CPU-native Python extension and a header-only C++11 API; it
does not expose CUDA, ROCm, MPS, or a service/CLI.
Route first
- For NumPy arrays,
hnswlib.Index,hnswlib.BFIndex,knn_query, Python callbacks, pickle, or Python persistence, read sub-skills/python-bindings/SKILL.md. - For C++ headers,
HierarchicalNSW,BruteforceSearch,searchKnn, filters, stop conditions, multivector/epsilon search, CMake, or thread ownership, read sub-skills/cpp-header-api/SKILL.md. - Read references/installation.md before a source build or when an import/compiler failure is involved.
- Read references/parameter-tuning.md when
choosing
M,ef_construction,ef, capacity, or a recall target. - Read references/troubleshooting.md when a failure spans installation, persistence, data validation, or concurrency.
Shared operating contract
- Identify the metric (
l2,ip, orcosine), vector dimension, capacity, label type/policy, queryk, target recall, and whether deletion, replacement, filtering, resizing, or persistence is required. - Prefer the public package install (
pip install hnswlib) when a compatible wheel exists. A source build needs NumPy, pybind11, a C++11 compiler, and the platform's native threading/OpenMP handling; use the installation reference. - Keep
k <=the eligible live population and setef >= k. ANN quality and speed depend on both construction and search parameters; validate material recall claims againstBFIndexor another exact oracle. - Treat index files as binary artifacts tied to compatible metric/dimension and
a deliberate capacity. Set
efagain after file-based loading because file persistence resets it to the default; pickle preserves Python index state. - Coordinate lifecycle phases. Do not overlap querying with adding, resizing, saving/loading, or destruction. Python filters should use one query thread; keep C++ spaces, filters, stop conditions, and buffers alive for each call.
- Use temporary or application-owned paths and bounded fixtures for smoke checks. Do not run large BigANN/SIFT downloads, benchmark-scale tests, or stress suites as a default operating workflow.
Minimum smoke checks
Python users should run the relevant bundled helper with --help and then a
small default invocation from an environment where hnswlib is installed:
sub-skills/python-bindings/scripts/python_lifecycle_smoke.py,
python_filter_smoke.py, python_mutation_smoke.py, or python_pickle_smoke.py.
C++ users should run
sub-skills/cpp-header-api/scripts/run_cpp_smoke.sh --help, then provide an
include root containing hnswlib/hnswlib.h.
Provenance and scope
Read references/repo-provenance.md when checking whether this skill matches a repository revision. Read references/repo-routing-metadata.json only as structured routing metadata; it is not an API manual.
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).