Random Permutation Codes: Lossless Source Coding of Non-Sequential Data

Daniel SeveroarXiv 2024 · DOI

Introduction

Traditional lossless compression algorithms, such as ZIP, PNG, or Zstd, are fundamentally designed for sequential data. They operate under the assumption that the specific order of symbols carries information; consequently, changing the sequence changes the data. However, many modern datasets are inherently non-sequential. Examples include multisets of images, social network graphs, and cluster assignments in vector databases. In these cases, the order in which data points are stored is often arbitrary and carries no semantic meaning.

When a standard sequential compressor is applied to a set of $n$ items, it inadvertently "pays" for one specific ordering out of $n!$ possible permutations. For a dataset containing 10,000 items, this wasted "order information" accounts for approximately 14 kilobytes of unnecessary overhead. This paper introduces Random Permutation Codes (RPCs), a family of algorithms designed to eliminate this waste by treating data ordering as a source of randomness that can be exploited through "bits-back" coding.

Theoretical Framework: Combinatorial Random Variables

The core of this research is the development of Combinatorial Random Variables (CRVs). This framework allows for the formal treatment of data structures where the underlying representation is a permutation of elements. By leveraging Asymmetric Numeral Systems (ANS)—a modern entropy coder that functions as a Last-In-First-Out (LIFO) stack—the author implements a technique known as Bits-Back Coding.

In bits-back coding, the encoder does not choose an arbitrary order for the data. Instead, it uses the current state of the compressed message as a random seed to "sample" the next item to be encoded. Because the decoder has access to the same compressed state, it can replicate this sampling process exactly. This allows the bits used to determine the sequence order to be effectively recovered during decoding, "shaving off" the cost of the permutation and reaching the information-theoretic limit of the non-sequential object.

The RPC Family of Algorithms

The thesis develops three specialized algorithms to handle different non-sequential structures:

  1. Random Order Coding (ROC): Designed for multisets. ROC samples elements without replacement using a dynamic Binary Search Tree (BST). This approach ensures that the computational complexity is quasi-linear and, crucially, independent of the alphabet size. This allows ROC to compress sets of complex objects, such as high-resolution images, as efficiently as simple integers.
  2. Random Cycle Coding (RCC): Designed for cluster assignments. RCC exploits the mathematical property that any permutation can be decomposed into disjoint cycles. By using these cycles to represent clusters, RCC achieves optimal theoretical savings for grouping data.
  3. Random Edge Coding (REC): Designed for graphs. Paired with a parameter-free "Polya’s Urn" model, REC compresses sparse, small-world networks by sampling edges and vertices in a way that respects the graph's topology.

Experimental Evaluation

The RPC framework was evaluated across several diverse benchmarks to demonstrate its versatility and efficiency:

  • Neural Compression (MNIST): When applied to 10,000 binarized images of handwritten digits, ROC achieved a 7.6% reduction in file size compared to standard sequential encoding. This improvement came with only a modest 10% increase in computational overhead.
  • Vector Databases (FAISS): Using the SIFT1M and BigANN datasets, RCC demonstrated optimal theoretical savings, significantly outperforming previous bits-back variants in both compression ratio and execution time.
  • Graph Compression: On the YouTube social network graph (3.2M nodes), REC proved more efficient than several specialized ad-hoc graph compressors. In synthetic tests, REC achieved a 0.0% gap to the theoretical information-theoretic limit.
  • Structured Data: The algorithms successfully handled nested structures, such as multisets of multisets found in public GitHub JSON metadata.

Key Insights and Connections

A profound theoretical contribution of this work is the bridge it builds between classical source coding and modern machine learning. The author proves that the bit-rate achieved by RPCs is mathematically equivalent to the Negative Evidence Lower Bound (NELBO). This connection suggests that the process of "shaving off" order information is fundamentally a form of variational inference.

Limitations and Future Directions

Despite their efficiency, RPCs face certain constraints. Because they rely on the LIFO nature of ANS, they do not support random access; a user cannot decode a specific item without decoding all subsequent items in the stack. Additionally, the current implementation requires the entire dataset to be available before encoding begins, which precludes real-time streaming applications.

Future work may explore "coarser" equivalence relations, such as unlabelled graphs where node identities can be permuted. Furthermore, while this work focuses strictly on lossless compression, extending these techniques to lossy environments remains a significant open challenge for the field.

Summary updated

BibTeX
@misc{severo2024random,
  author = {Daniel Severo},
  title = {{Random Permutation Codes: Lossless Source Coding of Non-Sequential Data}},
  year = {2024},
  eprint = {2411.14879},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.14879},
}
Figure