npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ruvector/rabitq-wasm

v0.1.0

Published

RaBitQ 1-bit quantized vector index in WebAssembly — 32× embedding compression with high-recall rerank, for browsers, Cloudflare Workers, Deno, and Bun

Readme

@ruvector/rabitq-wasm

RaBitQ 1-bit quantized vector index in WebAssembly. Compress embeddings 32× and run approximate nearest-neighbor search in the browser, Cloudflare Workers, Deno, or Bun.

npm License

What is RaBitQ?

RaBitQ is a rotation-based 1-bit vector quantization scheme that compresses each f32 embedding into a single bit per dimension while preserving rank order under L2 distance. A small "rerank pool" of exact-distance computations on the top candidates restores recall.

For a 768-dimensional embedding (~3 KB raw), RaBitQ stores 96 bytes of quantized code plus the rotation matrix — a 32× memory reduction. Search runs in two phases:

  1. Hamming-distance scan over the 1-bit codes — fast, branch-free, ~10× more vectors per cache line than f32.
  2. Exact L2² rerank of the top rerank_factor × k candidates — restores recall.

The rotation is deterministic from (seed, dim, vectors), so the same input always produces bit-identical codes whether you build on x86_64, aarch64, or wasm32.

Install

npm install @ruvector/rabitq-wasm

Usage (browser)

import init, { RabitqIndex } from "@ruvector/rabitq-wasm";

await init();

const dim = 768;
const n = 10_000;
const vectors = new Float32Array(n * dim);
// ... populate `vectors` with your embeddings (n × dim, row-major) ...

// seed = 42 for reproducibility; rerank_factor = 20 is the typical default
const idx = RabitqIndex.build(vectors, dim, 42n, 20);

const query = new Float32Array(dim);
// ... fill query ...

const results = idx.search(query, 10);
// → [{ id: 7421, distance: 0.0023 }, { id: 9011, distance: 0.0041 }, ...]

Usage (Node.js / Bun)

import { RabitqIndex } from "@ruvector/rabitq-wasm/node/ruvector_rabitq_wasm.js";
// no `init()` needed for the node target

const idx = RabitqIndex.build(vectors, 768, 42n, 20);
const results = idx.search(query, 10);

Usage (bundlers — Vite, Webpack, Rollup)

import { RabitqIndex } from "@ruvector/rabitq-wasm/bundler/ruvector_rabitq_wasm.js";
// the bundler handles the .wasm import transparently

API

class RabitqIndex

RabitqIndex.build(vectors, dim, seed, rerankFactor)

Build an index from a flat Float32Array of length n * dim.

| Parameter | Type | Description | |---|---|---| | vectors | Float32Array | Row-major matrix of n vectors, each of length dim. | | dim | number | Vector dimensionality. | | seed | bigint | Random rotation seed. Same (seed, dim, vectors) triple → bit-identical codes. | | rerankFactor | number | Multiplier on k for the exact-L2² rerank pool. Typical: 20. |

Throws if dim == 0, vectors is empty, or vectors.length is not a multiple of dim.

idx.search(query, k)

Find the k nearest neighbors of query. Returns an array of SearchResult ordered ascending by distance.

idx.len (getter, number)

Number of vectors indexed.

idx.isEmpty (getter, boolean)

true iff no vectors have been indexed.

interface SearchResult

{
  id: number;       // caller-supplied vector id (its row index in `build`)
  distance: number; // approximate L2² distance after rerank
}

version()

Returns the crate version baked at build time.

Why use this in the browser

  • 32× smaller indices. A 100 K × 768 embedding store is ~9.6 MB instead of ~300 MB — fits comfortably in any browser tab.
  • Cache-line-friendly hamming scan. The 1-bit codes pack 64 dimensions into one u64, so the hot path runs at memory bandwidth.
  • Deterministic across architectures. Builds on your x86_64 build server, runs identically on the user's ARM phone or in a Cloudflare Worker.
  • No server. Run RAG, semantic search, or recommendation lookup entirely client-side.

Sister packages

Source

License

MIT OR Apache-2.0