TL;DR
This paper introduces a novel, rate-optimal lossless compression method for multisets (unordered collections of items with repetitions) that completely decouples computational complexity from alphabet size. By leveraging "bits-back coding" via Asymmetric Numeral Systems (ANS), the algorithm hides the overhead of arbitrary sequencing, making the compression of large-alphabet multisets—like datasets of images or JSON files—computationally practical for the first time.
What Problem Does This Paper Address?
Standard compression algorithms are designed for sequences where the order of symbols matters. However, many real-world data types are inherently unordered collections, mathematically known as multisets. Examples include database rows, collections of files, and machine learning datasets.
If you use a standard sequence compressor on a multiset, you must choose an arbitrary order to feed the items into the encoder. This wastes bits because the compressor spends energy encoding the specific permutation of the sequence—information the receiver doesn't actually need.
While optimal multiset compression algorithms exist, their computational runtime scales linearly with the size of the symbol alphabet ($|\mathcal{X}|$). This is fine for small alphabets (like text characters), but completely breaks down for large alphabets. For instance, if a single "symbol" is a $28\times28$ grayscale image, the alphabet size is $256^{784}$—an impossibly large number. The authors set out to bridge this gap, creating an optimal-rate compressor whose complexity is independent of alphabet size.
Methods
The core strategy is to avoid encoding the multiset directly. Instead, the algorithm encodes a random proxy sequence containing the exact same elements as the multiset, using a clever cryptographic-like trick called bits-back coding implemented via Asymmetric Numeral Systems (ANS).
Here is how the interleaving process works during compression:
- Sampling (Decoding): The algorithm uses the current compressed bitstream (the ANS stack) as a source of randomness to sample an element without replacement from the remaining multiset. Because decoding from an ANS stack consumes bits, this step actually shortens the message length.
- Encoding: The sampled element is then encoded onto the ANS stack using a standard sequence compressor. This adds bits back to the stack.
- The "Bit Refund": Crucially, the number of bits consumed during the sampling step perfectly matches the information theoretical cost of ordering that element. This effectively "refunds" the bits wasted by treating the multiset as an ordered sequence.
To make sampling without replacement efficient, the authors introduce a dynamic Binary Search Tree (BST) structure (similar to a Fenwick tree) to track the frequency counts of the remaining elements. This allows lookups, insertions, and removals to happen in sub-linear time ($O(\log m)$, where $m$ is the number of unique elements), completely bypassing the massive full alphabet.
Datasets
The authors evaluated their approach across several distinct types of data:
- Synthetic Multisets: Highly skewed distributions sampled from a Dirichlet prior, used to rigorously test runtime behavior as alphabet sizes scaled up to $2^{17}$.
- MNIST Test Set: 10,000 grayscale handwritten digit images ($28 \times 28$). Images were compressed using the lossy WebP codec as the underlying symbol encoder.
- GitHub JSON Maps: Public user data from the Zstandard project repository, used to demonstrate how the method can be nested recursively to compress a "multiset of multisets."
- Binarized MNIST: Used for evaluating the method alongside a deep learning-based latent variable model for lossless neural compression.
Key Insights and Ideas
- The Order Tax Refund: The defining "aha!" moment of bits-back coding in this context is that the bits used as a random seed to pick an item out of the multiset aren't lost. Because the decoding process is perfectly invertible, the receiver can figure out exactly what random bits were used once they decode the item, allowing those bits to be recovered later.
- Decoupling via Proxy: By routing the compression through a proxy sequence, the algorithm can use any pre-existing, highly optimized sequence compressor (like WebP or neural network compressors) as a black box.
- Exploiting Sparsity: Real-world large-alphabet data is highly sparse; a dataset of images will only ever contain a tiny fraction of all mathematically possible images. The dynamic BST data structure capitalizes on this by only tracking the unique elements actually present in the multiset, rather than iterating over the entire theoretical alphabet.
Key Results
- Alphabet Independence: Experiments on synthetic data confirmed that the total encode/decode time remains entirely flat even as the alphabet size grows exponentially (see Figure 2). The time complexity scales quasi-linearly ($O(n \log m)$) with the multiset size $n$.
- MNIST + WebP: The algorithm successfully clawed back the theoretical limit of savings ($\log |M|!$), yielding a ~1.5% reduction in total file size for 10,000 images compared to standard sequential ordering.
- Lossless Neural Compression: When paired with a neural network compressor on binarized MNIST, the multiset codec achieved a 7.6% savings in total bit-length, while adding a mere 10% computational time overhead.
- Nested JSON Compression: The method successfully compressed nested structures close to the theoretical maximum savings limit by applying the sampling technique hierarchically.
Limitations and Future Work
- No Streaming or Random Access: Because ANS operates like a Last-In-First-Out (LIFO) stack, you cannot stream the data or access a single element randomly. The entire multiset must be known and processed as a whole before encoding can finish or decoding can begin.
- Worst-Case Decoding Bottlenecks: During decoding, elements are inserted in a random order. If the elements happen to arrive in a highly ordered way, the dynamic BST could become severely unbalanced, degrading the lookup time from $O(\log m)$ to $O(m)$. The authors note that implementing self-balancing trees (like AVL or Red-Black trees) would resolve this worst-case vulnerability.
- Scaling Nesting: While nested multiset compression (like the JSON experiment) works in theory, comparing large complex structures at the outer layers can become slow. The authors suggest exploring parallelized inner sampling steps to speed this up.
Summary updated