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)

To train a denoising SAE, enable Gaussian corruption. The trainer adds noise only to training inputs and still reconstructs the original clean embeddings:

trainer = TopKSAETrainer(
    TopKSAEConfig(
        hidden_dim=4096,
        k=32,
        noise_type="gaussian",
    )
)
srp = trainer.fit_transform(embeddings)

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.5.tar.gz (110.4 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.5-py3-none-any.whl (102.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for compresso_pytorch-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a83a149e29b39e3cf557aee744bfd053217e12d6eae125c0d1ca5dc87b7db569
MD5 28834db189209977589121d99e79b7c0
BLAKE2b-256 bccaa9628ae2caf60c6d48075996f05bdad412ceaaaddcfb4a3e278241b44294

See more details on using hashes here.

Provenance

The following attestation bundles were made for compresso_pytorch-0.1.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for compresso_pytorch-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 589fb4dc15afddc81e49d5acaec8f6e1d96a8b1cc6edf42e832d532606f3a491
MD5 d9d7cc509ef97fcf84db82bb351ce817
BLAKE2b-256 f35f6e78f24d21b50be35962471c0a9c1d3ac174ede1c7df901dab06fe01f8bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for compresso_pytorch-0.1.5-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

This release

0.1.5 This release

2 files

0.1.3

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