Releases: noosphaerenbauer/tiny-knn
Releases · noosphaerenbauer/tiny-knn
Release list
v0.2.0 — 2025-08-25
Overview
- Minor release with a simplified, faster API and CLI. exact_search now returns results directly and supports Torch/NumPy arrays or file paths. Benchmarks, tests, and docs updated.
Highlights
- exact_search(arr1, arr2, k, metric) returns (indices, scores).
- Accepts Torch tensors, NumPy arrays, or .pt/.npy paths.
- Metrics: ip (inner-product) or cosine (with internal normalization).
- CLI simplified with --metric and optional --output-path.
Breaking Changes
- Removed file-writing API. Previously: returns output path; Now: returns indices and scores.
- Removed low-level CLI flags (device/dtype/batch/chunk/autotune/etc.); use defaults.
New
- NumPy support: inputs can be np.ndarray or .npy files; results come back as NumPy arrays.
- Mixed precision maintained (fp32/fp16; bf16 for Torch tensors).
- Results types mirror inputs (Torch → Torch; NumPy → NumPy).
CLI Changes
- Command: tiny-knn path/to/queries.(pt|npy) path/to/docs.(pt|npy) --k 100 --metric ip --output-path results.pt
- Output format:
- .pt/.pth: Torch dict with keys indices, scores
- .npz: NumPy arrays indices, scores
Migration
- Library:
- Before: result_path = exact_search(q_path=..., d_path=..., k=..., out_path=...)
- After: indices, scores = exact_search(arr1, arr2, k, metric="ip")
- CLI:
- Replace --normalize with --metric cosine.
- Use --output-path to persist results.
Usage
- Torch:
- indices, scores = exact_search(queries_t, docs_t, 100, metric="ip")
- NumPy:
- indices, scores = exact_search(queries_np, docs_np, 100, metric="cosine")
- Paths:
- indices, scores = exact_search("queries.pt", "docs.pt", 100, metric="ip")
Verification
- Tests updated and passing; benchmarks adapted to new signature.