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

scalablevq

v1.0.6

Published

TypeScript implementation of ScalableVQ decoding

Readme

ScalableVQ: Scalable Vector Quantization

Project Overview

This project implements scalable vector quantization. It construct hierarchical structures through merging clusters and assign bits to these cluster centers, providing scalability in data representation.

"Scalability" refers to the encoded data being partitioned into a base layer and multiple enhancement layers. Decoding begins from the base layer, with each additional enhancement layer improving the fidelity of the reconstructed data.

💡 This project itself does not perform vector quantization. The accuracy achieved depends on the vector quantization method you choose.

Structure

  • scalablevq: Core package containing modules for hierarchical clustering, bit assignment, splitting and merging codes, and data encoding/decoding.
  • example.py: Illustrates clustering, encoding, and decoding processes using the library's main functionalities.

Key Features

Encoding

  1. Hierarchical Clustering: Iteratively merges clusters to form a hierarchical cluster tree.
  2. Bit assign: Allocates bits to clusters within the hierarchy.
  3. Splitting/Encoding: Partitions quantized data and codebook into several layers based on the cluster hierarchy and assigned bits.

Decoding

  1. Merging: Combines the encoded layers to reconstruct quantized data and the associated codebook.
  2. Decoding: Converts quantized data back to approximate the original data using the reconstructed codebook.

Install

Install from pypi:

pip install scalablevq

or from source:

pip install git+https://github.com/yindaheng98/ScalableVQ

Example Usage

💡 Refer to example.py for a complete example.

Before using this library, perform vector quantization using your preferred method (e.g. K-Means from sklearn):

data = ... # your data, shape [N, C]
from sklearn.cluster import MiniBatchKMeans as KMeans
kmeans = KMeans(n_clusters=1024, init='random', random_state=0, n_init="auto")
quantized_data = torch.from_numpy(kmeans.fit_predict(data.cpu()))
cluster_centers = torch.from_numpy(kmeans.cluster_centers_)

Encoding:

from scalablevq import encode_layers
n_bits_proposal = [4, 2, 2, 2, 2]
layers = encode_layers(data, quantized_data, cluster_centers, n_bits_proposal)

Decoding:

from scalablevq import decode_layer
context = None
for layer in layers:
    decoded, context = decode_layer(layer, context)

Visualizztion:

layerized_cluster_centers, cluster_tree = build_layers(cluster_centers, data, quantized_data, final_clusters=2**n_bits_proposal[0])
visualize_layers(cluster_centers.cpu(), layerized_cluster_centers.cpu(), cluster_tree, data=None)

💡 Use GPU acceleration if possible, as large-scale clustering can be compute-intensive.

Dependencies

  • PyTorch
  • NumPy
  • tqdm
  • scikit-learn (optional, for example.py)
  • open3d (optional, for visualization)