ANNPack builder and tools
Project description
ANNPack
Serverless vector search: static .annpack files served over HTTP Range, searched
in the browser via WASM + Transformers.js.
Badges
TL;DR / What it is
- A portable, immutable ANN index format plus tooling for build + serve + search.
- Designed for low-ops distribution (CDN/S3/edge) and in-browser query.
- Ships a Python CLI/API and a WASM runtime for HTTP Range search.
Alpha / security posture: ANNPack is in alpha. Security hardening is in progress;
see SECURITY.md for current defaults, limits, and runtime caps.
v0.1.5 highlights:
- Deterministic tiny-dataset fallback for centroid training and pinned FAISS threads to stabilize builds.
- Hardened registry defaults (dev mode opt-in, JWT required in prod), upload/body limits, rate limiting, and path traversal protection.
- C core overflow/alloc guards plus Python metadata size caps
(
load_meta=Falsesupport), with new security workflows/docs.
When to use / When not to use
Use it when:
- You want static, cacheable search artifacts you can host anywhere.
- You need reproducible snapshots and lightweight, client-side querying.
Avoid it when:
- You need mutable, transactional, or real-time index updates.
- You want a managed vector database with server-side filtering and writes.
Quickstart (CLI)
pip install annpack
ANNPACK_OFFLINE=1 annpack build --input tiny_docs.csv --text-col text --output ./out/tiny --lists 256
annpack serve ./out/tiny --port 8000
annpack smoke ./out/tiny --port 8000
Expected output includes PASS smoke.
Installation
pip install annpack
Optional extras:
pip install annpack[embed]for real embeddings (torch + sentence-transformers)pip install annpack[registry]for the local PackHub service
Templates (plug-and-play)
annpack templates
annpack init --template text-search --out ./my-pack
Concepts
- A pack is an immutable index directory containing:
*.annpack(binary index)*.meta.jsonl(metadata rows)*.manifest.json(shard list; used by the UI)
- PackSet supports base + delta packs with tombstones for append-only updates.
- Components:
- Builder (Python CLI):
annpack build - Runtime (C/WASM):
ann_load_index,ann_searchover HTTP Range - Frontend (JS): Transformers.js embeddings + WASM ANN search
- Builder (Python CLI):
Offline mode & determinism
Set ANNPACK_OFFLINE=1 to use deterministic dummy embeddings (no model
downloads). For real embeddings, install annpack[embed] and unset
ANNPACK_OFFLINE.
Determinism notes:
- Manifests/meta are deterministic and clustering is seeded.
- Embeddings can vary by device/backend; for strict reproducibility, set
ANNPACK_DEVICE=cpuduring builds.
Demos
10-minute demo (offline, deterministic):
bash examples/quickstart_10min.sh
Expected output includes:
PASS smokeREADY: open http://127.0.0.1:<port>/
Golden demo launcher (build + serve + UI command):
bash tools/run_demo.sh
Optional medium demo assets (downloaded, not in git):
bash tools/download_demo_assets.sh ./demo_assets
Troubleshooting
- Port in use: pass
--port <free-port>toserve/smoke. - Missing manifest: ensure the output dir contains
*.manifest.json. - CORS:
annpack serveenables permissive CORS headers by default. - Offline/air-gapped builds: set
ANNPACK_OFFLINE=1(no embed deps required). - Real embeddings: install
annpack[embed]and unsetANNPACK_OFFLINE. - Small datasets:
annpack buildclamps--liststo vector count. - macOS quarantine (console scripts):
xattr -dr com.apple.quarantine "$(python -c 'import site; print(site.getsitepackages()[0])')"
- Localhost bind restrictions: set
ANNPACK_SKIP_NET_TESTS=1to skip network smoke instage_all.sh. - Avoid venvs named
#(shell treats#as a comment).
Verification / acceptance scripts
Stage 1 acceptance (build + smoke):
bash tools/stage1_acceptance.sh
Expected last line: PASS stage1 acceptance.
Stage 2 acceptance (API + determinism):
bash tools/stage2_acceptance.sh
Expected last line: PASS stage2 acceptance.
Stage 3: Delta packs (PackSet):
annpack packset build-base --input tiny_docs.csv --packset ./packset --text-col text --id-col id --lists 4 --seed 123 --offline
annpack packset build-delta --base ./packset/base --add delta_add.csv --delete-ids 1 --out ./packset/deltas/0001.delta --packset ./packset --text-col text --id-col id --lists 4 --seed 123 --offline
annpack packset status --packset ./packset
Stage 4 acceptance (distribution + portability):
bash tools/stage4_acceptance.sh
Expected last line: PASS stage4 acceptance.
Pre-talk gates (clean repo + clean checkout):
bash tools/repo_hygiene.sh
bash tools/clean_checkout_gate.sh
Repo layout
python/annpack/: primary Python package and CLI.registry/: local FastAPI-based pack registry with Range support (registry/README.md).web/: client SDK (web/packages/client) and UI app (web/apps/ui).docs/: architecture, API, CLI usage, and notes.annpack-v2/: experimental WASM demo tooling; treat as legacy.- Legacy notes:
build_fast.pyis legacy; useannpack buildwith MiniLM instead.ann_query_bytesinmain.cis retained for debugging.
Docs
docs/ARCHITECTURE.mddocs/API_USAGE.mddocs/CLI_USAGE.mddocs/WASM.mddocs/POSITIONING.mddocs/AUDIENCE_FRONTEND.mddocs/AUDIENCE_ML_INFRA.mddocs/VERIFY.mddocs/BENCHMARKS.mddocs/benchmarks/README.mdCODE_OF_CONDUCT.mdSUPPORT.mdSECURITY.mdRELEASE.mddocs/PRODUCTION.mddocs/COMPATIBILITY.mddocs/ONE_PAGER.mddocs/DISCOVERY_QUESTIONS.mddocs/DEMO_SCRIPT.md
File format
ANNPack is a portable binary format for IVF-based ANN search. The current spec
is in docs/FORMAT.md.
Format summary (unchanged):
- 72-byte header: magic, version, endian, header_size, dim, metric, n_lists, n_vectors, offset_table_ptr.
- Centroids (float32), then IVF lists:
[count:u32][ids:int64*count][vecs:float16*dim*count], then an offset table[offset:u64,length:u64]per list.
Pure Python reader/searcher example:
import numpy as np
from annpack.reader import ANNPackIndex
with ANNPackIndex.open("my_index.annpack") as idx:
dim = idx.header.dim
q = np.random.randn(dim).astype(np.float32)
q /= np.linalg.norm(q)
hits = idx.search(q, k=10)
print(hits)
Other languages can implement a reader using docs/FORMAT.md; the C/WASM runtime
is one consumer.
License / Contributing / Security
- License:
LICENSE - Contributing:
CONTRIBUTING.md - Security:
SECURITY.md
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file annpack-0.1.6.tar.gz.
File metadata
- Download URL: annpack-0.1.6.tar.gz
- Upload date:
- Size: 142.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97c7710837b2a903cbac9d3f05dc2750eb540261ca2245bd41d8822a7600dc88
|
|
| MD5 |
4f815f01380f937f58da2af77c9d0a55
|
|
| BLAKE2b-256 |
6440c4cb7b585cdadfdff99c2a5c395874d2a7577812ff0f25878e135a44565e
|
File details
Details for the file annpack-0.1.6-py3-none-any.whl.
File metadata
- Download URL: annpack-0.1.6-py3-none-any.whl
- Upload date:
- Size: 52.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58c577cf3d51c884a2315d024ebfa6370fb1f057f5b1a88eacce8b122fab7e2f
|
|
| MD5 |
5c6113d01be2bf4370ce05ed250a4120
|
|
| BLAKE2b-256 |
a1fa12040d769cd5938a7e593855ecbf0b19ee9ad28ddc8274d7e736de18e1e6
|