A Family of LZ78-based Universal Sequential Probability Assignments

Naomi Sagan, Tsachy Weissman · OpenReview

Abstract

We propose and study a family of universal sequential probability assignments on individual sequences, based on the incremental parsing procedure of the Lempel-Ziv (LZ78) compression algorithm. We show that the normalized log loss under any of these models converges to the normalized LZ78 codelength, uniformly over all individual sequences. To establish the universality of these models, we consolidate a set of results from the literature relating finite-state compressibility to optimal log-loss under Markovian and finite-state models. We also consider some theoretical and computational properties of these models when viewed as probabilistic sources. Finally, we present experimental results showcasing the potential benefit of using this family -- as models and as sources -- for compression, generation, and classification.

Introduction

In information theory, a primary goal is to predict the next symbol in a sequence without making restrictive assumptions about the underlying data-generating process—a challenge known as the "individual sequence" setting. While the Lempel-Ziv (LZ78) algorithm has been a cornerstone of lossless data compression since 1978, its application as a robust sequential probability model for prediction and generation has historically been fragmented.

This paper formalizes a flexible family of sequential probability models based on LZ78's incremental parsing. By combining this classic algorithm with Bayesian mixtures, the authors develop a framework that is mathematically "universal"—eventually matching the performance of any finite-state machine—while remaining computationally efficient enough to run on standard hardware without GPU acceleration.

Methods

The core of the proposed Sequential Probability Assignment (SPA) is the incremental parsing engine of LZ78. As a sequence is processed, the algorithm builds a prefix tree where each node represents a unique "phrase" or context encountered in the data.

The incremental parsing tree structure of LZ78 with node counts.

To assign probabilities, the authors avoid simple empirical counting, which suffers from the "zero-frequency problem" (where unseen symbols are assigned zero probability). Instead, they treat each context as a separate source and apply a Bayesian mixture with a prior distribution (such as a Dirichlet prior). This ensures that every possible symbol in the alphabet is assigned a non-zero probability at every step. The formal notation used to describe these contexts and subsequences is detailed in the table below.

Summary of notation used for LZ78-based probability modeling.

This approach defines a "family" of models parameterized by the choice of the prior distribution. A key theoretical contribution of this work is the rigorous proof that the log-loss (prediction error) of these models converges to the LZ78 codelength and, consequently, to the fundamental limits of finite-state compressibility.

Experimental Evaluation

The models were evaluated across diverse domains to test their versatility:

  • Text Generation: Using datasets like tiny-shakespeare and tinystories, the model's ability to capture linguistic structure was tested at the character level.
  • Classification: The authors applied the model to image data (MNIST and Fashion-MNIST) by flattening 2D images into 1D sequences, and to text data for sentiment analysis (IMDB) and spam detection (Enron-Spam).
  • Synthetic Analysis: A "Bernoulli LZ78 Source" was used to verify theoretical convergence limits.

Key Insights and Results

Adaptive Memory Depth

Unlike standard Markov models that require a pre-defined order (e.g., looking back $k$ symbols), the LZ78 tree naturally grows its context length as more data is observed. This allows the model to automatically adapt its memory depth to the complexity of the sequence without manual hyperparameter tuning.

Performance and Efficiency

  • Theoretical Optimality: The normalized log-loss converges to the LZ78 codelength uniformly over all sequences.
  • Classification Success: Despite being a general-purpose compression model, it achieved 98.12% accuracy on Spam detection and 75.36% on MNIST. These results were obtained with a fraction of the compute required by modern neural networks.
  • Computational Profile: The models operate in $O(n)$ time on a standard CPU with sub-linear memory growth, making them ideal for resource-constrained environments.

Limitations and Future Outlook

While powerful, the model's convergence rate slows as the alphabet size increases (e.g., moving from ASCII to full Unicode). Current effectiveness is highest on smaller alphabets like DNA sequences or quantized pixels. Future research may explore more sophisticated Bayesian priors to better capture long-range dependencies and the application of these probability sources to universal rate-distortion codes for lossy compression.

Summary updated

Abstract

We propose and study a family of universal sequential probability assignments on individual sequences, based on the incremental parsing procedure of the Lempel-Ziv (LZ78) compression algorithm. We show that the normalized log loss under any of these models converges to the normalized LZ78 codelength, uniformly over all individual sequences. To establish the universality of these models, we consolidate a set of results from the literature relating finite-state compressibility to optimal log-loss under Markovian and finite-state models. We also consider some theoretical and computational properties of these models when viewed as probabilistic sources. Finally, we present experimental results showcasing the potential benefit of using this family -- as models and as sources -- for compression, generation, and classification.
BibTeX
@inproceedings{sagan2025family,
  author = {Naomi Sagan and Tsachy Weissman},
  title = {{A Family of LZ78-based Universal Sequential Probability Assignments}},
  booktitle = {ISIT},
  year = {2025},
  doi = {10.1109/isit63088.2025.11195681},
}
Figure