Skip to main content

Compresso: A PyTorch Framework for Sparse Representation Learning

PyPI Python License Docs Live Demo Documentation build

Compresso logo

Compresso is an open-source PyTorch framework for sparse representation learning. It provides reusable building blocks for learning sparse neural representations, dynamic sparsification, sparse inference, and semantic analysis, enabling researchers to rapidly prototype sparse neural architectures while focusing on models rather than infrastructure.

Why Compresso?

Sparse representations are becoming increasingly important across machine learning due to their efficiency, interpretability, and ability to capture semantically meaningful concepts. Yet building sparse models often requires implementing pruning schedules, sparse kernels, training loops, device management, and visualization from scratch.

Compresso hides this complexity behind a simple, modular API.

The name is inspired by Italian espresso culture: when you order a coffee in Italy, you simply ask for a caffè. The barista handles the beans, pressure, and brewing; you just enjoy the result. Compresso follows the same philosophy: researchers should be able to train and analyze sparse representations without worrying about the underlying engineering.

Install

Using pip:

pip install compresso-pytorch

For local development:

git clone https://github.com/zombak79/compresso.git
cd compresso
pip install -e ".[test]"

Documentation

Documentation is available at https://zombak79.github.io/compresso/.

Minimal Example

You can train a sparse autoencoder through one high-level class TopKSAETrainer with a scikit-learn-style wrapper: fit trains on a dense matrix, transform returns sparse codes, and fit_transform does both. All hyperparameters live in the TopKSAEConfig dataclass.

import numpy as np
from compresso import TopKSAEConfig, TopKSAETrainer

embeddings = np.random.randn(10_000, 512).astype("float32")

trainer = TopKSAETrainer(
    TopKSAEConfig(
        hidden_dim=4096,
        k=32,
    )
)

srp = trainer.fit_transform(embeddings)
print(srp)

Clustering and cluster labeling can be run through the clustering pipeline:

from compresso import clustering as cc

cluster_graph = cc.ClusteringPipeline(
    [
        cc.DominantSignedClustering(min_cluster_size=20),
        cc.LabelClusters(...),
    ]
)(srp)

See full example at https://zombak79.github.io/compresso/clustering.html.

Recommender Systems Add-on

For recommender-system experiments, see compresso-recsys, the companion package built on top of Compresso.

It provides recommender-specific dataset loaders, checkpoint management, and retrieval metrics such as Recall and nDCG. It can be installed with:

pip install compresso-recsys

Compresso contains the general sparse representation learning components, while compresso-recsys provides the infrastructure needed to apply and evaluate them in recommender-system experiments.

Citation

If you find this project helpful or use it in your academic work, please consider citing it. This helps us continue to maintain and develop this project. You can find the citation format below.

For method-specific references, including the sparse embedding compression work behind TopKSAETrainer, see the citation guide.

@misc{compresso,
  title  = {Compresso: A PyTorch Framework for Sparse Representation Learning},
  author = {Van{\v{c}}ura, Vojt{\v{e}}ch and Giacomo Medda and Spi{\v{s}}{\'a}k, Martin and Ladislav Pe{\v{s}}ka},
  year   = {2026},
  url    = {https://github.com/zombak79/compresso}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compresso_pytorch-0.1.3.tar.gz (102.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compresso_pytorch-0.1.3-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

Details for the file compresso_pytorch-0.1.3.tar.gz.

File metadata

  • Download URL: compresso_pytorch-0.1.3.tar.gz
  • Upload date:
  • Size: 102.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for compresso_pytorch-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f2175f80aaffb314927d8739d7cc20eaa5fb227963411791d8da04f6e7bd4884
MD5 b14b34fc3b3d161b874c9ff4d79e8200
BLAKE2b-256 d8ad4ec02a35e8d444999e537b6e7e24f0a1a483a40389a8dae987564e1fb7fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for compresso_pytorch-0.1.3.tar.gz:

Publisher: publish.yml on zombak79/compresso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compresso_pytorch-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for compresso_pytorch-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a61e23950c25ec48857d1c3688f5c7b4ea626fd26a1a20a5f4953e93cc50536
MD5 4008971946af6e0b2c3216a61906d5c1
BLAKE2b-256 06b9d23745ae70583d13eb3b8dc98ae245e05343eceafba342508eb10aea3715

See more details on using hashes here.

Provenance

The following attestation bundles were made for compresso_pytorch-0.1.3-py3-none-any.whl:

Publisher: publish.yml on zombak79/compresso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page