Compresso: A PyTorch Framework for Sparse Representation Learning
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
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 compresso_pytorch-0.1.6.tar.gz.
File metadata
- Download URL: compresso_pytorch-0.1.6.tar.gz
- Upload date:
- Size: 119.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1825808c7acb051d77b37616dc43355392b258945b5bfd8181ea2a623840e0ec
|
|
| MD5 |
86b2b4a6d203b698cb5d5890bd211199
|
|
| BLAKE2b-256 |
99f1d22e722f3353d44cf1fb9ed7dc02989993f88927da126e3d9db4e5664843
|
Provenance
The following attestation bundles were made for compresso_pytorch-0.1.6.tar.gz:
Publisher:
publish.yml on zombak79/compresso
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compresso_pytorch-0.1.6.tar.gz -
Subject digest:
1825808c7acb051d77b37616dc43355392b258945b5bfd8181ea2a623840e0ec - Sigstore transparency entry: 2498389077
- Sigstore integration time:
-
Permalink:
zombak79/compresso@b187259143d5e24d77bb09e2d20024fcd63b6d37 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/zombak79
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b187259143d5e24d77bb09e2d20024fcd63b6d37 -
Trigger Event:
push
-
Statement type:
File details
Details for the file compresso_pytorch-0.1.6-py3-none-any.whl.
File metadata
- Download URL: compresso_pytorch-0.1.6-py3-none-any.whl
- Upload date:
- Size: 106.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ec51fa817f56c53001e5d00976ff055891a2fd7536561701ce35e35ad20662
|
|
| MD5 |
977a4e877feda332ea9b3b5230c79ed7
|
|
| BLAKE2b-256 |
91b4bb9abbbb2f21eef50c907b1fd8c7f3c20cd4fc08412843be65cb94f71478
|
Provenance
The following attestation bundles were made for compresso_pytorch-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on zombak79/compresso
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compresso_pytorch-0.1.6-py3-none-any.whl -
Subject digest:
18ec51fa817f56c53001e5d00976ff055891a2fd7536561701ce35e35ad20662 - Sigstore transparency entry: 2498389085
- Sigstore integration time:
-
Permalink:
zombak79/compresso@b187259143d5e24d77bb09e2d20024fcd63b6d37 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/zombak79
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b187259143d5e24d77bb09e2d20024fcd63b6d37 -
Trigger Event:
push
-
Statement type: