Welcome to Compresso’s documentation!

Compresso is a small PyTorch library for fixed-k sparse representations, sparse autoencoders, sparse parameters, and sparse-representation clustering.

The project distribution is named compresso-pytorch and the Python package is imported as compresso.

import numpy as np
from compresso import TopKSAEConfig, TopKSAETrainer

embeddings = np.random.randn(10_000, 512).astype("float32")
srp = TopKSAETrainer(TopKSAEConfig(hidden_dim=4096, k=32, epochs=50)).fit_transform(embeddings)
print(srp)   # SRPTensor(shape=(10000, 4096), k=32, ...)

New here? Read Getting Started for the concepts, then A First Example: Seeing What an SAE Learns to see what a sparse autoencoder learns.

Indices and Tables