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.

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.

@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.2.tar.gz (99.3 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.2-py3-none-any.whl (96.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for compresso_pytorch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c9a41d35de0704724ba8cc71f3ca0a5d2b0b1c2de02c84324989714ef2222e45
MD5 7c136b46a1eb31aba19fbcee49223422
BLAKE2b-256 4b673ae18212bca36c50fba7e7a59450a5e99d045be8285dbf524f117c065b32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for compresso_pytorch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 001c0d12124efcfcbb8844f8b9b6c5072f4f534ab7de76c1e99446853d5728ac
MD5 eb04e2b34856ec7a2d70ed9fca627326
BLAKE2b-256 f049ec515c5fcd5680520aec5ebba29c8ea369a6ce78f3d43953eba2440c7434

See more details on using hashes here.

Provenance

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

0.1.3

2 files

This release

0.1.2 This release

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