Skip to content

Menu

WorksComputer Science

Language Modeling is Monotone Compression

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_buwws747. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

A long-standing hypothesis in artificial intelligence and neuroscience posits that intelligence is closely related to compression: the ability to compress information efficiently intuitively reflects capacities associated with intelligence and learning. Indeed, recent experimental works verify this intuition by showing connections between the capabilities of large language models (LLMs) and their ability as compressors: for instance, Deletang et al. (ICLR'24) demonstrate that LLMs can be used as powerful compressors, and Huang et al. (COLM'24) show that the compression ability of LLMs is highly correlated with their performance on benchmarks for knowledge and reasoning. In this work, we initiate a theoretical study of this connection. Our main result is that LLMs (formally modeled as next-token predictors) are equivalent to monotone (a.k.a. order-preserving) compression algorithms—namely, compression algorithms where the encoding process preserves the ordering of the inputs—in the sense that the one can be constructed from the other while preserving the same error up to an additive gap of 2. We next show that the monotonicity is required for this equivalence to hold if and only if cryptographic (infinitely-often) one-way functions exist. As a direct corollary, we get a cryptographic result of independent interest: the notion of next-bit pseudoentropy (a computational analogue of entropy) of a distribution is equivalent to monotone incompressibility of the distribution. (Previously, it was only known (Haitner et al., ITCS'23) that incompressibility implies next-bit pseudoentropy.)

Introduction

A central question in the study of artificial intelligence is: can “intelligence” be defined? Turing’s classic “imitation game” [19], which posits that a machine should be considered intelligent if a human is unable to distinguish it from another human given a transcript of a conversation, gives an elegant answer, but one that depends on human judgment. Towards a more mathematical and quantitative definition of intelligence, the work of Shannon [15, 16] laid the groundwork for a line of research suggesting that learning or understanding something is closely related to being able to process and describe it in a simple way [11 HO98]—that is, intelligence, intuitively, corresponds to the ability to succinctly compress information.

Recently, autoregressive models such as large language models (LLMs) have made this suggested connection more explicit. Such models are trained on data sampled from a distribution DD to predict the next token in a sequence: given a prefix of tokens t1,t2,…,tkt_1,t_2,\ldots,t_k, they output a probability distribution that is supposed to approximate the conditional distribution {tk+1∣t1,…,tk}\{t_{k+1} \mid t_1,\ldots,t_k\}. A model is considered “good” if its loss, measured as the expected negative log-likelihood on data drawn from DD, or equivalently, the cross-entropy between DD and the model’s predicted distribution, is close to minimal.

It is well known that good compression schemes can be constructed from good autoregressive models by leveraging arithmetic encoding [15, 3]: arithmetic encoding is known to produce a near-optimal compression rate for a given distribution, so, intuitively, applying it to the distribution of a model’s autoregressively sampled outputs should likewise give a near-optimal compression rate for DD if the model is good. This was first empirically studied using neural network predictors [13] (see also, e.g., [14, 12, 17]), but subsequently has been applied to LLMs, with recent research suggesting not only that compression rivaling state-of-the-art algorithms can be constructed from LLMs (e.g., [1, 23, 18]), but also that compression ability of LLMs is highly correlated with performance on benchmarks measuring knowledge, reasoning, and coding abilities [9].

Given that compression can be constructed from LLMs, a natural question is whether the converse may also hold—that is, whether one can construct accurate next-token predictors from good compression algorithms. This idea was originally empirically explored in the work of [2] constructing models for text categorization from compression algorithms, and is of particular interest because it would imply an intuitive equivalence between predictive modeling and compression. More recently, Delétang et al. [1] suggest and evaluate a heuristic construction of an autoregressive next-token prediction model from compression, leading them to their titular assertion that “language modeling is compression”.

However, when one compares the results in each direction of this proposed empirical equivalence, there is a clear difference in terms of the empirical quality of results: compression algorithms constructed from LLMs exhibit competitive compression ratios, whereas works constructing autoregressive models from compression exhibit relatively poor predictive ability compared to state-of-art LLMs. While there are certainly plausible intuitive explanations for this disparity—for instance, the difference in computational power between state-of-the-art LLMs and state-of-the-art compression algorithms—it nonetheless raises a fundamental question:

Is there a formal connection between autoregressive models (i.e., LLMs) and compression?

In this work, we address this question, initiating a theoretical study of the intuitive connection between autoregressive models and compression. Our main result shows that, intuitively, “good” autoregressive models are equivalent to “good” monotone compression schemes. (Furthermore, this equivalence holds quantitatively up to a constant additive accuracy gap between the cross-entropy loss of the autoregressive model and the compression loss of the monotone compressor.) We additionally show that the monotonicity condition is necessary if and only if cryptographic (infinitely-often) one-way function (ioOWFs) exist; this explains the disparity observed above.

Our Results

We formalize LLMs as autoregressive models which, given a string of tokens as a prefix, output a probability distribution over possible next tokens. We consider a setting where the objective of an LLM is, given a “training” distribution DD (e.g., random files selected from the Internet), to learn a model M\mathcal{M} that minimizes the expected negative log-likelihood Et←D[−∑i∈[ℓ(t)]log⁡M(ti∣t<i)]\mathbb{E}_{t\leftarrow D}\left[-\sum_{i\in[\ell(t)]}\log\mathcal{M}(t_i\mid t_{<i})\right], which is in fact equivalent to the cross-entropy H(D,DM)=H(D)+KL(D∥DM)H(D,D_{\mathcal{M}})=H(D)+KL(D\mathbin\Vert D_{\mathcal{M}}) (where H(D)H(D) is Shannon entropy and KLKL represents Kullback-Leibler divergence) between DD and the distribution DMD_{\mathcal{M}} of outputs autoregressively sampled from M\mathcal{M}. As the minimum achievable cross-entropy is H(D)H(D), we say that a model M\mathcal{M} is δ\delta-optimal with respect to DD if its cross-entropy is at most H(D)+δH(D)+\delta.

A compression scheme is specified by a pair of algorithms (Enc, Dec) where Enc encodes an input from a distribution DD into its compressed form (which we assume throughout to be binary), and Dec is the respective inverse. We assume throughout that Enc is prefix-free with respect to DD: for any xx in the support of DD, no codeword for a different input is a prefix of Enc⁡(x)\operatorname{Enc}(x).

The goal of compression is to minimize the expected compression length Ex←D[∣Enc⁡(x)∣]\mathbb{E}_{x\leftarrow D}[\lvert\operatorname{Enc}(x)\rvert]; by Shannon’s source coding theorem [15], this is lower-bounded by H(D)H(D), and so we say that compression is δ\delta-optimal with respect to DD if its expected compression length is at most H(D)+δH(D)+\delta (in other words, the compression loss is at most δ\delta). Finally, compression is monotone if it preserves a lexicographic ordering ≺\prec over inputs, induced by an efficiently computable ordering of the tokens: that is, given inputs x,yx,y, Enc⁡(x)<Enc⁡(y)\operatorname{Enc}(x) < \operatorname{Enc}(y) if and only if x≺yx \prec y, where << is the lexicographic ordering of binary codewords.

For all of our results, we require autoregressive models and compression schemes to be efficiently computable: encoding, decoding, and computing next-token probabilities must run in polynomial time. Furthermore, when discussing cross-entropy and expected compression length, we consider them over complete samples from the distribution DD.

Autoregressive modeling is monotone compression. We first present our main result, showing the equivalence between autoregressive modeling and monotone compression:

Theorem 1.1 (Theorem 3.2 and Theorem 3.3, informal). Given a distribution DD consisting of strings of tokens from an alphabet Σ\Sigma, for any δ\delta:

  • *Given an efficiently computable δ\delta-optimal autoregressive model for DD, one can construct an efficiently computable monotone compression scheme which is (δ+2)(\delta+ 2)-optimal with respect to DD.1*

  • Given an efficiently computable monotone compression scheme which is δ\delta-optimal with respect to DD, one can construct a δ\delta-optimal autoregressive model for DD.

In other words, autoregressive models and monotone compressors are equivalent up to an additive gap of 2; we additionally demonstrate this equivalence through an explicit efficient transformation in both directions.

The monotonicity requirement. While the added condition of monotonicity may seem surprising at first glance, it sheds light on the discrepancy we noted earlier between empirical results converting autoregressive models to compression and vice versa. Known constructions of compression from autoregressive models use arithmetic encoding, which is monotone; meanwhile, as monotonicity is not necessarily inherent in compression algorithms, it explains why constructions of autoregressive models from compression tend to have worse empirical performance. Indeed, our next result formally demonstrates that the requirement of monotonicity is not merely coincidental: given a fundamental and widely conjectured cryptographic assumption, the existence of infinitely-often one-way functions (ioOWFs)2^{2}, monotonicity is necessary for any strong autoregressive model-compression equivalence:

Theorem 1.2 (Theorem 4.3 and Theorem 4.8, informal). The following are true:

  • If one-way functions (respectively, infinitely-often one-way functions) exist, then there exists an efficiently samplable distribution family D={Dn}D = \{D_n\} and a non-monotone compression scheme (Enc⁡,Dec⁡)(\operatorname{Enc}, \operatorname{Dec}) with efficient encoding and decoding whose expected encoding length on DnD_n is exactly H(Dn)H(D_n), but for which every efficiently computable autoregressive model has excess cross-entropy loss at least linear in the output length. This lower bound holds for all sufficiently large lengths (respectively, infinitely many lengths).

  • If infinitely-often one-way functions do not exist, then, given a δ\delta-optimal compression scheme (Enc⁡,Dec⁡)(\operatorname{Enc}, \operatorname{Dec}) with efficient encoding and decoding for an efficiently samplable distribution family D={Dn}D = \{D_n\}, one can construct an efficiently computable autoregressive model which is statistically close to a δ\delta-optimal autoregressive model for DD.

That is, given ioOWFs, one could not hope to prove Theorem 1.1, or even any weaker analogue with an additive gap constant sublinear in the length of a sample from the distribution DD, without requiring monotonic compression. Interestingly, the same is not true if ioOWFs do not exist: in that case, using a classic result from [10], we show that one can drop the monotonicity condition from Theorem 1.1 at a cost of a small amount of statistical error. Thus, in essence, whether modeling is equivalent to monotone compression or (approximately) equivalent to all compression depends on the truth of this assumption; that said, one-way functions (which in turn imply ioOWFs) are widely conjectured to exist, implying the former equivalence and a corresponding separation between monotone and non-monotone compression.

Pseudoentropy and incompressibility. Lastly, we show a corollary of Theorem 1.1 that provides interesting implications to cryptography. There has been a considerable line of research relating the compressibility of a distribution to its pseudoentropy [5], a computational analogue of entropy. In particular, Haitner et al. [HMS23] demonstrate that, if a family of distributions D\mathcal{D} is incompressible [22] to some length k(n)k(n), then it has next-bit pseudoentropy at least (k(n)−2)(k(n)-2)—that is, the total pseudoentropy of the conditional next-bit distributions of each bit of D\mathcal{D} is at least (k(n)−2)(k(n)-2). 3 However, the converse is false: if one-way functions exist, then pseudoentropy cannot imply incompressibility. As our final result, we obtain a tight version of this characterization by combining Theorem 1.1 with a corollary from [21] to show that, similarly to the equivalence between autoregressive models and compression, both directions are true if we specifically require monotone incompressibility, or inability to be compressed through specifically monotone schemes:

Corollary 1.3 (Corollary 5.3 and Corollary 5.4, informal). Given a family of distributions D\mathcal{D}, the following are equivalent for any function k(n)k(n) (to within an additive gap of 2):

  • D\mathcal{D} cannot be efficiently monotonically compressed to length k(n)k(n).

  • D\mathcal{D} has next-bit pseudoentropy at least k(n)k(n).

Technical Overview

Monotone Compression from Autoregressive Models. To construct monotone compression for a distribution DD from an autoregressive model M\mathcal{M}, we can use arithmetic encoding relative to the model’s output distribution DMD_{\mathcal{M}}. As discussed above, the expected negative log-likelihood used to train M\mathcal{M} is exactly the cross-entropy H(D,DM)H(D,D_{\mathcal{M}}): multiplying the next-token probabilities gives the probability of a complete output, and taking its negative logarithm gives the sum of the next-token losses. Arithmetic encoding connects this same quantity to compression by assigning each output xx a codeword Enc⁡(x)\operatorname{Enc}(x) such that

len⁡(Enc⁡(x))≤−log⁡DM(x)+2.\operatorname{len}(\operatorname{Enc}(x)) \le-\log D_{\mathcal{M}}(x)+2.

Since this bound holds for each xx, we can average it over the correct distribution DD, even though the code is constructed using the approximation given by DMD_{\mathcal{M}}:

Ex←D[len⁡(Enc⁡(x))]≤Ex←D[−log⁡DM(x)]+2=H(D,DM)+2.\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] \le\mathbb{E}_{x\leftarrow D}[-\log D_{\mathcal{M}}(x)]+2 = H(D,D_{\mathcal{M}})+2.

Furthermore, as mentioned above,

KL(D∥DM)=Ex←D[log⁡D(x)DM(x)]=H(D,DM)−H(D).KL(D\mathbin\Vert D_{\mathcal{M}})=\mathbb{E}_{x\leftarrow D}\left[\log\frac{D(x)}{D_{\mathcal{M}}(x)}\right]=H(D,D_{\mathcal{M}})-H(D).

so

Ex←D[len⁡(Enc⁡(x))]≤H(D)+KL(D∥DM)+2.\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] \le H(D)+KL(D\mathbin\Vert D_{\mathcal{M}})+2.

In other words, the expected compression length is at most the entropy of DD, plus the same KL-divergence that measures the model’s excess prediction loss, plus the overhead of 2 bits from arithmetic encoding. δ\delta-optimality of M\mathcal{M} thus implies (δ+2)(\delta+2)-optimality of the compression scheme.

Arithmetic encoding is monotone by definition: it arranges the probability intervals associated with outputs in lexicographic order and assigns codewords in that same order.

Efficiency of arithmetic encoding, however, requires that the cumulative distribution function (CDF) of the model’s output distribution can be computed efficiently. For a polynomial-size alphabet, this is possible using a standard recursive algorithm (see, e.g., [HMS23,DRD+24]). Specifically, to determine the probability Pr⁡x←DM[x≺y]\Pr_{x\leftarrow D_M}[x \prec y] of an output being lexicographically smaller than a given string yy, one can decompose this into

Pr⁡x←DM[x≺y]=∑i(Pr⁡x←Dm[x<i=y<i]Pr⁡x←Dm[xi≺yi∣x<i=y<i])=∑i(Pr⁡x←Dm[x<i=y<i]∑z≺yiPr⁡x←Dm[xi=z∣x<i=y<i])\begin{aligned} \Pr_{x\leftarrow D_M}[x \prec y] = \sum_i \left(\Pr_{x\leftarrow D_m}[x_{<i}=y_{<i}] \Pr_{x\leftarrow D_m}[x_i \prec y_i \mid x_{<i}=y_{<i}]\right) \\ &= \sum_i \left(\Pr_{x\leftarrow D_m}[x_{<i}=y_{<i}] \sum_{z\prec y_i}\Pr_{x\leftarrow D_m}[x_i=z\mid x_{<i}=y_{<i}]\right) \end{aligned}

and thus recursively determine the overall probability by, for each possible prefix length where xx might first diverge from yy, multiplying the probability of matching the preceding prefix by the conditional probability of choosing a smaller token at that position, and summing these disjoint possibilities. Adding DM(y)D_M(y) then gives the CDF Pr⁡x←DM[x⪯y]\Pr_{x\leftarrow D_M}[x\preceq y]. This process requires only polynomially many next-token probability evaluations; thus, as long as the next-token probabilities of M\mathcal{M} are efficiently computable, arithmetic encoding with respect to DMD_M is as well.

Autoregressive Models From Monotone Compression. For the converse, given a prefix-free, monotone encoding Enc\mathrm{Enc} over a distribution DD, we demonstrate a construction of an autoregressive model M\mathcal{M} whose output distribution satisfies

DM(x)≥2−len⁡(Enc(x))D_M(x) \ge2^{-\operatorname{len}(\mathrm{Enc}(x))}

for every xx in the support of DD. This probability bound suffices because taking negative logarithms gives

−log⁡DM(x)≤len⁡(Enc(x)).-\log D_M(x) \le\operatorname{len}(\mathrm{Enc}(x)).

Thus, the model’s loss on each output is at most its encoding length, and taking the expectation over DD gives a bound on the cross-entropy:

H(D,DM)=Ex←D[−log⁡DM(x)]≤Ex←D[len⁡(Enc(x))].H(D,D_M)=\mathbb{E}_{x\leftarrow D}[-\log D_M(x)]\le\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\mathrm{Enc}(x))].

In particular, if Enc\mathrm{Enc} is δ\delta-optimal, the right-hand side is at most H(D)+δH(D)+\delta, so M\mathcal{M} is also δ\delta-optimal.

We proceed in two steps. First, we construct an efficiently monotone sampler Sample\mathrm{Sample} for the desired output distribution which, at a high level, samples outputs by decoding uniformly random bits. Let ℓ\ell be a polynomial upper bound4 on the output length of Enc\mathrm{Enc}: Sample\mathrm{Sample} will draw a uniformly random string c∈{0,1}ℓc\in\{0,1\}^{\ell}, examine the prefixes of cc in increasing order of length, and decode the first one that is a valid codeword. Since Enc\mathrm{Enc} is monotone, we can always decode efficiently through binary search, and, as there are only polynomially many prefixes to examine, this step is efficient. If no prefix of cc is a valid codeword, Sample\mathrm{Sample} instead returns the smallest input xx with Enc(x)⪯c\mathrm{Enc}(x)\preceq c (or the smallest possible input xx if no such xx exists); monotonicity of Enc\mathrm{Enc} allows us to again find such an input efficiently by binary search. We observe that this process assigns an output to every random string and, importantly, is weakly monotone: if c≺c′c\prec c', then Sample(c)⪯Sample(c′)\mathrm{Sample}(c)\preceq\mathrm{Sample}(c').

Next, we construct an efficiently computable autoregressive model M\mathcal{M} whose output distribution DMD_M is exactly the distribution of Sample(c)\mathrm{Sample}(c) when c←{0,1}ℓc\leftarrow\{0,1\}^{\ell} is uniform. To show that M\mathcal{M} satisfies the necessary probability bound, fix any xx in the support of DD; whenever the random string cc begins with Enc(x)\mathrm{Enc}(x), the sampler must return exactly xx, since prefix-freeness ensures that no shorter prefix of cc can be a valid codeword. This event has probability exactly 2−len⁡(Enc(x))2^{-\operatorname{len}(\mathrm{Enc}(x))}, so

DM(x)=Pr⁡c←{0,1}ℓ[Sample(c)=x]≥2−len⁡(Enc(x)).D_M(x)=\Pr_{c\leftarrow\{0,1\}^{\ell}}[\mathrm{Sample}(c)=x]\ge2^{-\operatorname{len}(\mathrm{Enc}(x))}.

Thus, by our original argument, M\mathcal{M} is δ\delta-optimal as long as Enc is.

However, we must still show that M\mathcal{M}'s next-token probabilities can be computed efficiently. Towards this, the key observation is that it suffices to show that the CDF of DMD_{\mathcal{M}} can be computed efficiently, which, leveraging weak monotonicity of Sample, can once again be done by binary search. Specifically, fix an output yy and identify the ℓ\ell-bit random strings with the integers 0,…,2ℓ−10,\ldots,2^\ell-1. By weak monotonicity, the random strings cc satisfying Sample(c)⪯y(c)\preceq y correspond to a subset c<k(y)c<k(y) of this set, and we can determine k(y)k(y) using binary search by finding the smallest cc with Sample(c)≻y(c)\succ y. Since the corresponding subset contains k(y)k(y) elements, each of which is chosen with probability exactly 2−ℓ2^{-\ell}, the CDF is exactly

F(y):=Pr⁡x←DM[x⪯y]=k(y)2ℓ.F(y) := \Pr_{x\leftarrow D_{\mathcal{M}}}[x\preceq y] = \frac{k(y)}{2^\ell}.

Finally, to recover next-token probabilities from the CDF, we use the standard observation that strings sharing a prefix form a contiguous interval in a lexicographic ordering; thus, prefix probabilities can be computed by subtracting two CDF values (see Figure 1 for a visualization), and next-token probabilities can be computed by taking ratios of prefix probabilities. We have thus demonstrated that the model M\mathcal{M} we constructed has both efficiently computable next-token probabilities and δ\delta-optimality with respect to DD, as desired.

Figure 1. Computing prefix probabilities from a monotone sampler. Outputs beginning with a fixed prefix t<it_{<i} form an interval in lexicographic order (horizontal band). The labels t<i∥σ1…t_{<i}\Vert\sigma_1\ldots, t<i∥σ2…t_{<i}\Vert\sigma_2\ldots, and t<i∥σ3…t_{<i}\Vert\sigma_3\ldots illustrate outputs with this common prefix, where σ1≺σ2≺σ3\sigma_1 \prec\sigma_2 \prec\sigma_3 are possible next tokens. By weak monotonicity of Sample, the random strings producing these outputs also form an interval (highlighted on the horizontal axis). Two binary searches locate its endpoints. The prefix probability is the number of seeds in this interval divided by 2ℓ2^\ell. The staircase is schematic; the vertical axis represents output order.

Comparison with [1]. Delétang et al. [1] present a heuristic construction of next-token prediction from compression; however, in contrast to our construction, which “looks ahead” and retrieves next-token probabilities relative to the complete output distribution reconstructed from the compression, they instead compute next-token probabilities myopically by examining the difference in length between the compression of the prefix and the compression of the prefix with each possible subsequent token appended.5 The advantage of this construction is that, unlike ours, monotonicity of the compression scheme Enc is not needed. However (as the authors themselves acknowledge in their work), because their approach approximates the next-token distribution using partial compressions every time they sample a next token, it risks introducing a constant amount of error to the sampling process every time a token is generated, whereas, with our construction, using a consistent distribution over complete outputs allows us to sample all tokens relative to that output distribution and only incur the error once.6

Definitions

Let N={1,2,3,…}\mathbb{N} = \{1, 2, 3, \ldots\} and [n]={m∈N∣m≤n}={1,2,…,n}[n] = \{m \in\mathbb{N} \mid m \le n\} = \{1, 2, \ldots, n\}. For some symbol σ\sigma in an alphabet Σ\Sigma, take σn\sigma^n to be the string consisting of nn copies of σ\sigma. Let 1P\mathbf{1}_P be the indicator function of a logical statement PP, defined as being 1 when PP is true and 0 otherwise. Given a set XX, we define Δ(X)\Delta(X) to be the set of probability distributions over elements in XX. Given some string x∈Σ∗x \in\Sigma^* over a vocabulary Σ\Sigma, we will denote substrings with notation such as x≤ix_{\le i} (representing the prefix consisting of the first ii symbols), and the length of a string x∈Σ∗x \in\Sigma^* by len⁡(x)\operatorname{len}(x). We use similar notation to denote, e.g., Σ≤n=⋃i=0nΣi\Sigma^{\le n} = \bigcup_{i=0}^{n} \Sigma^i as the set of strings of tokens from an alphabet Σ\Sigma with at most length nn.

We say a statement is true for “sufficiently large n∈Nn \in\mathbb{N}” if there exists N∈NN \in\mathbb{N} such that the statement holds for all n≥Nn \ge N. We shall call a function ϵ(⋅)\epsilon(\cdot) negligible if, for any polynomial p(⋅)p(\cdot), ϵ(n)<1/p(n)\epsilon(n) < 1/p(n) for sufficiently large n∈Nn \in\mathbb{N}; conversely, a function is non-negligible or polynomial if the above is not true.

In this work, we assume that algorithms are non-uniform: to enable computation for arbitrary input sizes parameterized by some n∈Nn \in\mathbb{N}, they receive an additional “advice” string of size polynomial in nn (which, unless otherwise specified, can be taken to be the string 1n1^n of nn ones to specify nn). We refer to a non-uniform algorithm as efficient if its running time is polynomial in the parameter nn. We define an oracle-aided algorithm ΠO\Pi^O as an algorithm Π\Pi that is given access to another algorithm OO as a black box, and may make many calls to its oracle OO on potentially many different inputs before determining its own output. We say that such an algorithm is efficient if its running time (excepting calls made to OO) and the number of calls it makes to the oracle OO are both polynomial in its input size—that is, as long as OO is efficient, the total running time of Π\Pi, including that taken by calls made to OO, is polynomial in its input size.

Unless otherwise indicated, any logarithm denoted by log⁡\log will be base 2 (as opposed to the base-ee natural logarithm ln⁡\ln). Given a discrete distribution DD, we denote by sup⁡(D)\operatorname{sup}(D) its support and define the (Shannon) entropy of DD to be the quantity

H(D)=∑x∈sup⁡(D)−D(x)log⁡D(x)H(D) = \sum_{x \in\operatorname{sup}(D)} -D(x) \log D(x)

Given two discrete distributions DD, D′D', we denote the statistical distance (or total variation distance) between DD and D′D' by Δ(D,D′)\Delta(D,D') and the Kullback-Leibler (KL) divergence between the two distributions by

KL(D∥D′)=∑x∈sup⁡(D)D(x)log⁡D(x)D′(x)KL(D\mathbin\Vert D') = \sum_{x \in\operatorname{sup}(D)} D(x) \log\frac{D(x)}{D'(x)}

Compression

We consider the problem of (lossless) data compression from a particular source distribution, where the goal is to achieve a uniquely decodable encoding over samples from the source distribution with the property that the expected encoding length of a sample drawn from the distribution is as small as possible. Formally:

Definition 2.1 ([4, 20]). Given finite families of alphabets Σ={Σn}n∈N\Sigma= \{\Sigma_n\}_{n\in\mathbb{N}} and Σ′={Σn′}n∈N\Sigma' = \{\Sigma'_n\}_{n\in\mathbb{N}} where ∣Σn∣|\Sigma_n| and ∣Σn′∣|\Sigma'_n| are polynomial in nn, functions m(⋅),ℓ(⋅)m(\cdot),\ell(\cdot) where m(n)m(n) is polynomial in nn, and an ensemble of distributions D={Dn}n∈N\mathcal{D} = \{D_n\}_{n\in\mathbb{N}}, where supp⁡(Dn)⊆Σnm(n)\operatorname{supp}(D_n) \subseteq\Sigma_n^{m(n)}, we say that a family of injective functions Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} is an encoding, or compression scheme7. Enc⁡\operatorname{Enc} compresses D\mathcal{D} to length ℓ(⋅)\ell(\cdot) if, for any n∈Nn \in\mathbb{N}, Enc⁡n:Σnm(n)→Σn′∗\operatorname{Enc}_n : \Sigma_n^{m(n)} \to\Sigma_n^{\prime*} is such that

Ex←Dn[len⁡(Enc⁡n(x))]≤ℓ(n)\mathbb{E}_{x\leftarrow D_n}[\operatorname{len}(\operatorname{Enc}_n(x))] \leq\ell(n)

Unless otherwise specified, we shall assume that the output of the compression is binary (Σn′={0,1}\Sigma'_n = \{0,1\} for all n∈Nn \in\mathbb{N}). We also define some useful properties of compression functions:

Definition 2.2 (Properties of compression). Given finite alphabets Σ\Sigma and Σ′\Sigma', let Enc⁡:Σ∗→Σ′∗\operatorname{Enc} : \Sigma^* \to\Sigma^{\prime*} be a function defined with respect to some distribution DD with supp⁡(D)⊆Σ∗\operatorname{supp}(D) \subseteq\Sigma^*.

We refer to Enc⁡\operatorname{Enc} as prefix-free if there do not exist elements x≠yx \ne y and i∈Ni \in\mathbb{N} such that x∈Σ∗x \in\Sigma^*, y∈supp⁡(D)y \in\operatorname{supp}(D), and Enc⁡(x)=(Enc⁡(y))<i\operatorname{Enc}(x) = (\operatorname{Enc}(y))_{<i} (i.e., Enc⁡(x)\operatorname{Enc}(x) is a prefix of Enc⁡(y)\operatorname{Enc}(y)); we note, however, that this definition does allow an encoding of y∈supp⁡(D)y \in\operatorname{supp}(D) to be a prefix of an encoding of x∉supp⁡(D)x \notin\operatorname{supp}(D)).

We refer to Enc⁡\operatorname{Enc} as monotone if there exist efficiently computable orderings ≺Σ\prec_\Sigma over Σ\Sigma and ≺Σ′\prec_{\Sigma'} over Σ′\Sigma' such that, for any x,y∈Σ∗x,y \in\Sigma^*, x≺Σ∗yx \prec_{\Sigma^*} y if and only if Enc⁡(x)≺Σ′∗Enc⁡(y)\operatorname{Enc}(x) \prec_{\Sigma^{\prime*}} \operatorname{Enc}(y), where ≺Σ∗\prec_{\Sigma^*} is the lexicographic ordering8 induced by ≺Σ\prec_\Sigma on Σ∗\Sigma^* and respectively for ≺Σ′∗\prec_{\Sigma^{\prime*}}.

We consider any of the above properties to apply to a family of functions Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} as defined in Definition 2.1, where Enc⁡n\operatorname{Enc}_n is defined with respect to a distribution DnD_n for which supp⁡(Dn)⊆Σnm(n)\operatorname{supp}(D_n) \subseteq\Sigma_n^{m(n)}, if they apply to Enc⁡n\operatorname{Enc}_n and DnD_n for each n∈Nn \in\mathbb{N}.

Furthermore, we say that such a family of functions has efficient encoding if there exists a polynomial p(⋅)p(\cdot) such that Enc⁡n\operatorname{Enc}_n runs in time at most p(n)p(n) for any n∈Nn \in\mathbb{N}, and efficient decoding if there exists a polynomial p′(⋅)p'(\cdot) and a function family Dec⁡={Dec⁡n}n∈N\operatorname{Dec} = \{\operatorname{Dec}_n\}_{n\in\mathbb{N}} such that, for each n∈Nn \in\mathbb{N}, Dec⁡n\operatorname{Dec}_n computes the inverse Enc⁡n−1(c)\operatorname{Enc}_n^{-1}(c) of Enc⁡n\operatorname{Enc}_n for any codeword in its image (or returns ⊥\perp if the input is not in the image) and additionally runs in time at most p′(n)p'(n).

We also note the following useful fact about efficient encoding and decoding:

Fact 2.3. Any monotone and efficiently encodable family of encodings Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} is also efficiently decodable.

Proof. Consider a decoding algorithm that, given a codeword, performs binary search over the possible inputs in Σnm(n)\Sigma_n^{m(n)}. This is possible due to monotonicity—it can be determined whether the correct decoding is lower or higher than a given input by comparing the respective codewords. Additionally, since there are ∣Σn∣m(n)|\Sigma_n|^{m(n)} possible inputs in Σnm(n)\Sigma_n^{m(n)}, binary search requires at most O(m(n)log⁡∣Σn∣)O(m(n)\log|\Sigma_n|) iterations of Enc⁡\operatorname{Enc}. Since by definition m(n)m(n) and ∣Σn∣|\Sigma_n| are polynomial in nn, and since Enc⁡\operatorname{Enc} is itself efficient, this decoding process must likewise be efficient. □

We shall generally restrict our focus to monotone and prefix-free encodings. Shannon’s source coding theorem [15] implies a lower bound for the expected length of any prefix-free encoding Enc⁡\operatorname{Enc} over a source distribution DD in terms of its Shannon entropy H(D)H(D):

Corollary 2.4 ([15]). Given finite alphabets Σ\Sigma and Σ′\Sigma' and distribution DD over Σ\Sigma, let ℓ∗(D)\ell^*(D) be the minimal expected length Ex←D[len⁡(Enc⁡(x))]\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] over any prefix-free encoding Enc⁡:Σ→Σ′\operatorname{Enc} : \Sigma\to\Sigma'. Then:

H(D)log⁡∣Σ′∣≤ℓ∗(D)\frac{H(D)}{\log|\Sigma'|} \leq\ell^*(D)

For binary encodings (Σ′={0,1}\Sigma' = \{0,1\}), this bound simply becomes ℓ∗(D)≥H(D)\ell^*(D) \geq H(D).

Arithmetic Encoding

Towards constructing compression with the properties that are necessary for our results, we start with the classical notion of arithmetic encoding, which essentially maps each element of a distribution DD to a binary representation of the element’s cumulative distribution function with respect to DD with sufficient precision to be unique.

Definition 2.5 (Arithmetic encoding [15, 3]). Let DD be a discrete distribution and let ≺\prec be a total order over sup⁡(D)\operatorname{sup}(D). Let F:sup⁡(D)→[0,1]F : \operatorname{sup}(D) \to[0,1] by F(x)=(∑a≺xD(a))+1/2⋅D(x)F(x) = \left(\sum_{a \prec x} D(a)\right) + 1/2 \cdot D(x). Then the arithmetic encoding Enc⁡:sup⁡(D)→{0,1}∗\operatorname{Enc} : \operatorname{sup}(D) \to\{0,1\}^{*} is defined such that, for x∈sup⁡(D)x \in\operatorname{sup}(D), Enc⁡(x)\operatorname{Enc}(x) is the first (⌈−log⁡D(x)⌉+1)(\lceil-\log D(x)\rceil+ 1) bits of F(x)F(x).

We note the following fact that shows that, when restricted to the support of the distribution DD, arithmetic encoding is prefix-free and monotone, and additionally provides near-optimal data compression:

Fact 2.6 (Properties of arithmetic encoding, lemma 2.8 in [20]). For every distribution family D={Dn}n∈ND = \{D_n\}_{n\in\mathbb{N}} and ordering ≺\prec over the corresponding input alphabet Σn\Sigma_n, the functions Enc⁡n\operatorname{Enc}_n given by applying Definition 2.5 to DnD_n and ≺\prec (for any n∈Nn \in\mathbb{N}) are one-to-one and monotone, and the scheme Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} is prefix-free and compresses DD to length H(Dn)+2H(D_n) + 2.

This is not quite what we need to show monotonicity and prefix-freeness with respect to the entire input space Σnm(n)\Sigma_n^{m(n)}—in fact, it is not necessarily clear how to define Enc⁡\operatorname{Enc} outside the support of DD since (⌈−log⁡Dn(x)⌉+1)(\lceil-\log D_n(x)\rceil+ 1) (the number of bits in Enc⁡n(x)\operatorname{Enc}_n(x)) is undefined when Dn(x)=0D_n(x) = 0. However, we show that one can transform arithmetic encoding to guarantee the stronger versions of these properties, and additionally show that arithmetic encoding, including our augmented version, is efficiently computable as long as the cumulative distribution function (CDF) ∑a⪯xDn(a)\sum_{a\preceq x} D_n(a) is likewise efficiently computable for any x∈Σnm(n)x \in\Sigma_n^{m(n)}.

Claim 2.7. For any alphabet {Σn}n∈N\{\Sigma_n\}_{n\in\mathbb{N}}, any distribution family D={Dn}n∈ND = \{D_n\}_{n\in\mathbb{N}} where sup⁡(Dn)⊆Σnm(n)\operatorname{sup}(D_n) \subseteq\Sigma_n^{m(n)} and −log⁡(Dn(x))≤ℓ(n)-\log(D_n(x)) \le\ell(n) for any x∈sup⁡(Dn)x \in\operatorname{sup}(D_n) and some polynomial ℓ(⋅)\ell(\cdot), and any ordering ≺n\prec_n over Σn\Sigma_n, if the cumulative distribution function ∑a⪯xDn(a)\sum_{a\preceq x} D_n(a) can be efficiently computed for any x∈Σnm(n)x \in\Sigma_n^{m(n)}, then there exists a prefix-free, monotone, and efficiently computable encoding Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} that additionally compresses DD to length H(Dn)+2H(D_n) + 2.

Proof. Let Enc⁡n′\operatorname{Enc}'_n be the arithmetic encoding given in Definition 2.5. Define Enc⁡n(x)=Enc⁡n′(x)\operatorname{Enc}_n(x) = \operatorname{Enc}'_n(x) for all x∈sup⁡(Dn)x \in\operatorname{sup}(D_n); for x∈Σnm(n)∖sup⁡(Dn)x \in\Sigma_n^{m(n)} \setminus\operatorname{sup}(D_n), let Enc⁡n(x)\operatorname{Enc}_n(x) be the first (ℓ(n)+2)(\ell(n) + 2) bits of the CDF ∑a≺xD(a)\sum_{a\prec x} D(a) (or 1ℓ(n)+21^{\ell(n)+2} if the CDF is 11, i.e., x≻yx \succ y for all y∈sup⁡(Dn)y \in\operatorname{sup}(D_n)) with the binary representation of xx ordered by ≺n\prec_n appended.

Prefix-freeness holds because, by Fact 2.6, Enc⁡n\operatorname{Enc}_n is prefix-free when restricted to sup⁡(Dn)\operatorname{sup}(D_n), and furthermore there cannot exist x∈Σnm(n)∖sup⁡(Dn)x \in\Sigma_n^{m(n)} \setminus\operatorname{sup}(D_n) and y∈sup⁡(Dn)y \in\operatorname{sup}(D_n) where Enc⁡n(x)\operatorname{Enc}_n(x) is a prefix of Enc⁡n(y)\operatorname{Enc}_n(y) because, by definition, Enc⁡n(x)\operatorname{Enc}_n(x) must be strictly longer than Enc⁡n(y)\operatorname{Enc}_n(y).

To show monotonicity, consider some x,y∈Σnm(n)x,y \in\Sigma_n^{m(n)} with x≺nyx \prec_n y. If x,y∈sup⁡(Dn)x,y \in\operatorname{sup}(D_n), we conclude that Enc⁡n(x)<Enc⁡n(y)\operatorname{Enc}_n(x) < \operatorname{Enc}_n(y) by Fact 2.6. If the first (ℓ(n)+2)(\ell(n) + 2) bits of Enc⁡n(x)\operatorname{Enc}_n(x) and Enc⁡n(y)\operatorname{Enc}_n(y) are identical (which can only happen when x,y∉sup⁡(Dn)x,y \notin\operatorname{sup}(D_n) and furthermore there is no z∈Dnz \in D_n with x≺nz≺nyx \prec_n z \prec_n y), we conclude that Enc⁡n(x)<Enc⁡n(y)\operatorname{Enc}_n(x) < \operatorname{Enc}_n(y) by the definition of Enc⁡n\operatorname{Enc}_n (since the following part of each Enc⁡n(x)\operatorname{Enc}_n(x) and Enc⁡n(y)\operatorname{Enc}_n(y) is the binary representation of xx and yy, respectively). Otherwise, it must be the case that xx and yy do not have the same CDF with respect to DnD_n, and so we conclude that Enc⁡n(x)<Enc⁡n(y)\operatorname{Enc}_n(x) < \operatorname{Enc}_n(y) because the respective prefixes of the encodings (which are prefixes of the respective CDFs) must be strictly ordered.

To show that Enc⁡n\operatorname{Enc}_n can be efficiently computed: if ∑a⪯xDn(a)\sum_{a\preceq x} D_n(a) can be efficiently computed, then so can

Dn(x)=∑a⪯xDn(a)−∑a≺xDn(a)D_n(x) = \sum_{a\preceq x} D_n(a) - \sum_{a\prec x} D_n(a)

(where x−x^{-} is the predecessor of xx under ≺\prec) and consequently

∑a<xDn(a)=∑a≤xDn(a)−Dn(x)\sum_{a<x} D_n(a) = \sum_{a\leq x} D_n(a) - D_n(x)

and thus Enc⁡n′(x)\operatorname{Enc}'_n(x) must be efficiently computable as well, which demonstrates efficient computability of Enc⁡n\operatorname{Enc}_n for x∈sup⁡(Dn)x \in\operatorname{sup}(D_n). For x∉sup⁡(Dn)x \notin\operatorname{sup}(D_n), it suffices that the CDF ∑a≺xD(a)\sum_{a\prec x} D(a) is efficiently computable. Finally, we remark that the encoding length of every x∈sup⁡(Dn)x \in\operatorname{sup}(D_n) is identical between Enc⁡n′\operatorname{Enc}'_n and Enc⁡n\operatorname{Enc}_n; therefore, the expected encoding length with respect to DnD_n must remain unchanged.

Remark. We note the assumption in the above claim that we have an effective a priori bound of p(n)+1p(n)+1 on the length of the arithmetic encoding Enc⁡n′(x)\operatorname{Enc}'_n(x). Without such a bound, one can still prove a similar result by truncating the arithmetic encoding to a suitably large polynomial length ℓ(n)\ell(n) and appending the binary representation of xx to any truncated encoding, even for x∈sup⁡(Dn)x \in\operatorname{sup}(D_n) with non-zero Dn(x)D_n(x). Since any x∈sup⁡(Dn)x \in\operatorname{sup}(D_n) must have Dn(x)≤2−ℓ(n)D_n(x) \leq2^{-\ell(n)} for its encoding to be affected, and there are at most ∣Σn∣m(n)|\Sigma_n|^{m(n)} possible codewords, as long as ℓ(n)\ell(n) is selected so that 2ℓ(n)≫∣Σn∣m(n)2^{\ell(n)} \gg|\Sigma_n|^{m(n)}, this will lose at most an exponentially small fraction of a bit in the output length. We, however, choose instead to assume an a priori bound ℓ(n)\ell(n) since, in the setting we consider, any efficiently computable family of autoregressive models must produce a distribution family D={Dn}n∈N\mathcal{D} = \{D_n\}_{n\in\mathbb{N}} where the arithmetic encoding length is polynomially bounded anyway.

KL-divergence and Compression Loss

One intuitive interpretation of the KL-divergence KL(D∥D′)KL(D \mathbin\Vert D') between two distributions is as the expected number of additional bits that would be needed to encode samples from DD using compression optimized for the distribution D′D' as opposed to using compression optimized for DD. We restate this for schemes, such as arithmetic encoding, which are “close to optimal” in the sense that the encoding length of a sample is additively close to the empirical entropy of that sample:

Claim 2.8. Let D,D′D, D' be distributions on Σm\Sigma^m and Enc⁡\operatorname{Enc} be an encoding such that, for any element x∈sup⁡(D′)x \in\operatorname{sup}(D'):

len⁡(Enc⁡(x))≤log⁡(1/D′(x))+α\operatorname{len}(\operatorname{Enc}(x)) \leq\log(1/D'(x)) + \alpha

Then, for any distribution DD (with sup⁡(D)⊆sup⁡(D′))\operatorname{sup}(D) \subseteq\operatorname{sup}(D')):

Ex←D[len⁡(Enc⁡(x))]≤H(D)+KL(D∥D′)+α\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] \leq H(D) + KL(D \mathbin\Vert D') + \alpha

Proof. By the definition of KL-divergence:

KL(D∥D′)=Ex←D[log⁡(1/D′(x))]−Ex←D[log⁡(1/D(x))]≥(Ex←D[len⁡(Enc⁡(x))]−α)−H(D)\begin{aligned} KL(D \mathbin\Vert D') = \mathbb{E}_{x\leftarrow D}[\log(1/D'(x))] - \mathbb{E}_{x\leftarrow D}[\log(1/D(x))] \\ &\geq\left(\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] - \alpha\right) - H(D) \end{aligned}

which directly implies the conclusion.

By definition, the family Enc⁡={Enc⁡D}\operatorname{Enc} = \{\operatorname{Enc}_D\} where Enc⁡D\operatorname{Enc}_D is the arithmetic encoding relative to DD has this property for α=2\alpha= 2 and thus satisfies:

Ex←D[len⁡(Enc⁡D′(x))]≤H(D)+KL(D∥D′)+2\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}_{D'}(x))] \leq H(D) + KL(D \mathbin\Vert D') + 2

Cross Entropy and LLM Training Objectives

We recall the definition of cross-entropy:

Definition 2.9. The cross-entropy of a distribution D2D_2 relative to a distribution D1D_1 is given by:

H(D1,D2)=−Ex←D1[log⁡D2(x)]=−∑x∈sup⁡(D1)D1(x)log⁡D2(x)H(D_1,D_2) = -\mathbb{E}_{x\leftarrow D_1}[\log D_2(x)] = - \sum_{x\in\operatorname{sup}(D_1)} D_1(x)\log D_2(x)

Cross-entropy is closely related to KL-divergence by the following fact:

Fact 2.10. For any distributions D1D_1, D2D_2:

H(D1,D2)=KL(D1∥D2)+H(D1)H(D_1,D_2) = KL(D_1\mathbin\Vert D_2) + H(D_1)

Proof.

H(D1,D2)=−∑x∈sup⁡(D1)D1(x)log⁡D2(x)=∑x∈sup⁡(D1)D1(x)log⁡D1(x)D2(x)−∑x∈sup⁡(D1)D1(x)log⁡D1(x)=KL(D1∥D2)+H(D1).\begin{aligned} H(D_1,D_2) &= -\sum_{x\in\operatorname{sup}(D_1)}D_1(x)\log D_2(x) \\ &= \sum_{x\in\operatorname{sup}(D_1)}D_1(x)\log\frac{D_1(x)}{D_2(x)}-\sum_{x\in\operatorname{sup}(D_1)}D_1(x)\log D_1(x) \\ &= KL(D_1\mathbin\Vert D_2)+H(D_1). \end{aligned}

Autoregressive Models

We shall generally treat LLMs in a black-box way and consider the process of training an LLM in terms of the objective function that it attempts to optimize. Let us assume that an LLM is being trained on some distribution DD over sequences of tokens t∈Σ∗t\in\Sigma^* from a vocabulary Σ\Sigma. During pretraining, the majority of the training process, an LLM is given samples from the distribution DD and attempts to “learn” the distribution DD by building an autoregressive model M\mathcal{M} that maps any sequence of tokens t<i∈Σ∗t_{<i}\in\Sigma^* to a distribution Mt<i\mathcal{M}_{t_{<i}} over next tokens that assigns each possible next token tit_i some probability M(ti∣t<i)\mathcal{M}(t_i\mid t_{<i}). Formally:

Definition 2.11. Given an alphabet Σ\Sigma and a maximum output length mm,9 we define an autoregressive model M\mathcal{M} over Σm\Sigma^m to be a collection of distributions {Mt}t∈Σ<m\{\mathcal{M}_t\}_{t\in\Sigma^{<m}} where every distribution Mt\mathcal{M}_t has support sup⁡(Mt)⊆Σ\operatorname{sup}(\mathcal{M}_t)\subseteq\Sigma. We define the induced distribution DMD_{\mathcal{M}} to be the distribution of complete outputs resulting from the process of starting with an empty string tt and iteratively appending a sample from Mt\mathcal{M}_t to tt mm times to construct a length-mm string t∈Σmt\in\Sigma^m.

The objective of this training process, then, is to minimize the expectation over samples t←Dt\leftarrow D of the loss function

L(M,t)=−∑i∈[len⁡(t)]log⁡M(ti∣t<i)(1)L(\mathcal{M},t)=-\sum_{i\in[\operatorname{len}(t)]}\log\mathcal{M}(t_i\mid t_{<i}) \tag*{(1)}

which is known as cross-entropy loss or negative log-likelihood. We refer to an autoregressive model as δ\delta-optimal with respect to a distribution DD if, for any autoregressive model M∗\mathcal{M}^* defined over the same alphabet:

Et←D[L(M,t)]−Et←D[L(M∗,t)]≤δ\mathbb{E}_{t\leftarrow D}[L(\mathcal{M},t)]-\mathbb{E}_{t\leftarrow D}[L(\mathcal{M}^*,t)]\leq\delta

that is, the expected loss of M\mathcal{M} over DD is no more than δ\delta worse than the minimum achievable loss. An important observation about this loss function is the following:

Claim 2.12. For alphabet Σ\Sigma, maximum length mm, and a fixed training distribution DD with support sup⁡(D)⊆Σm\operatorname{sup}(D)\subseteq\Sigma^m, if there exist an autoregressive model M\mathcal{M} over Σm\Sigma^m and constant δ\delta such that M\mathcal{M} is δ\delta-optimal with respect to DD, then, for any autoregressive model M∗\mathcal{M}^* defined over Σm\Sigma^m:

KL(D∥DM)−KL(D∥DM∗)≤δKL(D\mathbin\Vert D_{\mathcal{M}})-KL(D\mathbin\Vert D_{\mathcal{M}^*})\leq\delta

Proof. Let mm be the maximum output length of a sample from DD. We can apply the chain rule and Fact 2.10 to show:

KL(D∥DM)=∑i∈[m]Et<i:t←D[KL(Dt<i∥Mt<i)]KL(D\mathbin\Vert D_{\mathcal{M}})=\sum_{i\in[m]}\mathbb{E}_{t_{<i}:t\leftarrow D}\left[KL(D_{t_{<i}}\mathbin\Vert\mathcal{M}_{t_{<i}})\right]
=∑i∈[m]Et<i:t←D[H(Dt<i,Mt<i)−H(Dt<i)]=\sum_{i\in[m]}\mathbb{E}_{t_{<i}:t\leftarrow D}\left[H(D_{t_{<i}},\mathcal{M}_{t_{<i}})-H(D_{t_{<i}})\right]

where Dt<iD_{t_{<i}} is defined analogously to Mt<i\mathcal{M}_{t_{<i}} (i.e., the next-token distribution given prefix t<it_{<i}) for the training distribution DD. Furthermore:

∑i∈[m]Et<i←t∼D[H(Dt<i∥Mt<i)]=−∑i∈[m]Et≤i←t∼D[Eti←Dt<i[log⁡M(ti∣t<i)]]=−∑i∈[m]Et≤i←t∼D[log⁡M(ti∣t<i)]=Et←D[−∑i∈[m]log⁡M(ti∣t<i)]=Et←D[−∑i∈[len⁡(t)]log⁡M(ti∣t<i)]=Et←D[L(M,t)].\begin{aligned} \sum_{i\in[m]} \mathbb{E}_{t_{<i}\leftarrow t\sim D}\left[H\left(D_{t_{<i}}\Vert\mathcal{M}_{t_{<i}}\right)\right] = -\sum_{i\in[m]} \mathbb{E}_{t_{\leq i}\leftarrow t\sim D}\left[\mathbb{E}_{t_i\leftarrow D_{t_{<i}}}\left[\log\mathcal{M}(t_i\mid t_{<i})\right]\right] \\ &= -\sum_{i\in[m]} \mathbb{E}_{t_{\leq i}\leftarrow t\sim D}\left[\log\mathcal{M}(t_i\mid t_{<i})\right] \\ &= \mathbb{E}_{t\leftarrow D}\left[-\sum_{i\in[m]}\log\mathcal{M}(t_i\mid t_{<i})\right] = \mathbb{E}_{t\leftarrow D}\left[-\sum_{i\in[\operatorname{len}(t)]}\log\mathcal{M}(t_i\mid t_{<i})\right] = \mathbb{E}_{t\leftarrow D}[L(\mathcal{M},t)]. \end{aligned}

Importantly, since the training distribution DD is fixed, the entropy H(Dt<i)H(D_{t_{<i}}) is constant, as is its expectation over t←Dt\leftarrow D, which provides that KL(D∥DM)KL(D\parallel D_{\mathcal{M}}) and Et←D[L(M,t)]\mathbb{E}_{t\leftarrow D}[L(\mathcal{M},t)] are separated by the same additive constant for any model M\mathcal{M}, implying the conclusion since we have

Et←D[L(M,t)]−Et←D[L(M∗,t)]≤δ\mathbb{E}_{t\leftarrow D}[L(\mathcal{M},t)]-\mathbb{E}_{t\leftarrow D}[L(\mathcal{M}^{*},t)]\leq\delta

by assumption of δ\delta-optimality.

This intuitively means that training an LLM by attempting to minimize the expected loss Et←D[L(M,t)]\mathbb{E}_{t\leftarrow D}[L(\mathcal{M},t)] is equivalent to minimizing the KL-divergence KL(D∥DM)KL(D\parallel D_{\mathcal{M}}).

One final result that will be useful to us is demonstrating that the cumulative distribution function of a distribution DMD_{\mathcal{M}} induced by an autoregressive model M\mathcal{M} can be efficiently computed:

Claim 2.13. Given a polynomial-sized alphabet family Σ={Σn}n∈N\Sigma=\{\Sigma_n\}_{n\in\mathbb{N}} with lexicographical ordering ≺\prec, polynomial maximum length m(⋅)m(\cdot), and family of autoregressive models M={Mn}n∈N\mathcal{M}=\{\mathcal{M}_n\}_{n\in\mathbb{N}} over Σnm(n)\Sigma_n^{m(n)}, the following statements are equivalent:

  1. For any t∈Σnm(n)t\in\Sigma_n^{m(n)}, Mn(ti∣t<i)\mathcal{M}_n(t_i\mid t_{<i}) is efficiently computable on all prefixes with Pr⁡x←DMn[x<i=t<i]>0\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x_{<i}=t_{<i}]>0.

  1. For any n∈Nn\in\mathbb{N} and a∈Σnm(n)a\in\Sigma_n^{m(n)}, the cumulative distribution function Pr⁡x←DMn[x⪯a]\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq a] is efficiently computable.

Proof. (1) →\rightarrow (2). Consider the following procedure for computing Pr⁡x←DMn[x⪯a]\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq a]:

  • Let p=0p=0, p′=1p'=1, and i=1i=1.

  • Let M=(Mn)a<i\mathcal{M}=(\mathcal{M}_n)_{a_{<i}}, the next-token distribution for the ithi^{\mathrm{th}} token of aa.

  • Set p←p+p′(∑t∈sup⁡(M):t≺aiM(t))p\leftarrow p+p'\left(\sum_{t\in\operatorname{sup}(\mathcal{M}):t\prec a_i}\mathcal{M}(t)\right) and set p′←p′⋅M(ai)p'\leftarrow p'\cdot\mathcal{M}(a_i).

  • Repeat the previous two steps incrementing ii until i=m(n)i=m(n) or p′=0p'=0, then take p←p+p′p\leftarrow p+p', terminate and return pp.

Correctness holds because each iteration adds the probability that x←DMnx\leftarrow D_{\mathcal{M}_n} has x<i=a<ix_{<i}=a_{<i} but xi≺aix_i\prec a_i (and the final step p←p+p′p\leftarrow p+p' adds the probability that x=ax=a), and the sum of those probabilities is precisely Pr⁡x←DMn[x⪯a]\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq a].

Efficiency holds because, since ∣Σ∣|\Sigma| is polynomial, we compute M(t)=Mn(t∣a<i)\mathcal{M}(t)=\mathcal{M}_n(t\mid a_{<i}) at most a polynomial number of times in each iteration of the loop, which itself iterates a polynomial number p(n)p(n) of times.

(2) →\rightarrow (1). This follows since

Mn(ti∣t<i)=Pr⁡x←DMn[x≤i=t≤i]Pr⁡x←DMn[x<i=t<i]=Pr⁡x←DMn[x⪯t≤i⊤]−Pr⁡x←DMn[x⪯t≤i⊥]Pr⁡x←DMn[x⪯t<i⊤]−Pr⁡x←DMn[x⪯t<i⊥]\mathcal{M}_n(t_i \mid t_{<i}) = \frac{\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x_{\le i}=t_{\le i}]}{\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x_{<i}=t_{<i}]} = \frac{\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq t_{\le i}^{\top}]-\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq t_{\le i}^{\perp}]}{\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq t_{<i}^{\top}]-\Pr_{x\leftarrow D_{\mathcal{M}_n}}[x\preceq t_{<i}^{\perp}]}

where t<i⊤t_{<i}^{\top} is the ≺\prec-greatest element of Σnm(n)\Sigma_n^{m(n)} with t<it_{<i} as a prefix and t<i⊥t_{<i}^{\perp} is the ≺\prec-greatest element of Σnm(n)\Sigma_n^{m(n)} with a prefix (t⊥)<i≺t<i(t^{\perp})_{<i}\prec t_{<i}, and respectively for t≤i⊤t_{\le i}^{\top} and t≤i⊥t_{\le i}^{\perp}.

Autoregressive Models and Compression

In this section, we formally prove the equivalence (up to an additive constant) that we informally stated in Theorem 1.1 between the notions of optimal compression of a distribution and learning an accurate autoregressive model for that distribution. Using the facts about compression and cross entropy stated in the previous section, we demonstrate that near-optimal compression can be constructed from a nearly-accurate autoregressive model of a distribution, and subsequently that a nearly-accurate autoregressive model can be constructed from near-optimal compression. Intuitively, this means that training a model such as an LLM to learn a model that minimizes the loss function L(M,t)L(\mathcal{M}, t) given in Equation (1) (i.e., pretraining) is equivalent to training it to learn near-optimal compression via an encoding scheme (such as arithmetic encoding) meeting the requirements of Claim 2.8.

Accurate Autoregressive Models Imply Near-Optimal Compression

We begin with the first direction: given an autoregressive model M\mathcal{M} for a given distribution such that the expectation of L(M,t)L(\mathcal{M}, t) over samples from the distribution is close to its optimum, one can use a near-optimal encoding scheme (e.g., arithmetic encoding) to construct efficient compression that is similarly near-optimal with respect to coding length.

Lemma 3.1. Let DD be a distribution over Σm\Sigma^m, M\mathcal{M} be an autoregressive model with induced distribution DMD_{\mathcal{M}}, and Enc⁡\operatorname{Enc} be a prefix-free encoding scheme such that there exists constant α\alpha for which, for any x∈sup⁡(D)x \in\operatorname{sup}(D), len⁡(Enc⁡(x))≤log⁡(1/DM(x))+α\operatorname{len}(\operatorname{Enc}(x)) \le\log(1/D_{\mathcal{M}}(x))+\alpha. Then, if M\mathcal{M} is δ\delta-optimal with respect to DD, Enc⁡\operatorname{Enc} satisfies:

Ex←D[len⁡(Enc⁡(x))]≤H(D)+δ+α\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] \le H(D)+\delta+\alpha

Proving this lemma is in fact immediate, since we have already demonstrated the necessary groundwork as part of our discussion of compression and KL-divergence in § 2:

Proof. By Claim 2.12, we have KL(D∥DM)≤δKL(D\mathbin\Vert D_{\mathcal{M}})\le\delta (as the optimum is attained at D=DMD=D_{\mathcal{M}} which results in a divergence of 0). By Claim 2.8:

Ex←D[len⁡(Enc⁡(x))]≤H(D)+KL(D∥DM)+α≤H(D)+δ+α\mathbb{E}_{x\leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))]\le H(D)+KL(D\mathbin\Vert D_{\mathcal{M}})+\alpha\le H(D)+\delta+\alpha

Note that, due to Shannon’s lower bound from Corollary 2.4, we know that this bound on the expected encoding length must be no greater than δ+α\delta+\alpha away from the optimal expected encoding length over all prefix-free encodings. We can instantiate this using Claim 2.7, which gives α=2\alpha=2, for the following theorem as a direct corollary, noting that Claim 2.13 gives the requisite property that the cumulative distribution function is efficiently computable10:

Theorem 3.2. Given a polynomial-sized alphabet family Σ={Σn}n∈N\Sigma=\{\Sigma_n\}_{n\in\mathbb{N}} with respective ordering {≺n}n∈N\{\prec_n\}_{n\in\mathbb{N}} and polynomial maximum length m(⋅)m(\cdot), there exists an oracle-aided algorithm Enc⁡(⋅)\operatorname{Enc}(\cdot) so that, for any family of distributions D={Dn}n∈ND=\{D_n\}_{n\in\mathbb{N}}, family of autoregressive models M={Mn}n∈N\mathcal{M}=\{\mathcal{M}_n\}_{n\in\mathbb{N}} over Σnm(n)\Sigma_n^{m(n)} where Mn(ti∣t<i)\mathcal{M}_n(t_i\mid t_{<i}) is

efficiently computable for any t∈Σ≤m(n)t \in\Sigma^{\leq m(n)} and induces a distribution DMnD_{M_n} such that there exists polynomial11 ℓ(⋅)\ell(\cdot) for which −log⁡(DMn(x))≤ℓ(n)-\log(D_{M_n}(x)) \leq\ell(n) for all x∈supp⁡(DMn)x \in\operatorname{supp}(D_{M_n}), and function δ(⋅)\delta(\cdot) so that, for any n∈Nn \in\mathbb{N}, MnM_n is δ(n)\delta(n)-optimal with respect to DnD_n, the family of encodings Enc⁡={Enc⁡Mn,≺n(1n,ℓ(n),⋅)}n∈N\operatorname{Enc} = \{\operatorname{Enc}_{M_n,\prec_n}(1^n,\ell(n),\cdot)\}_{n\in\mathbb{N}} is prefix-free, monotone (with respect to ≺\prec), and efficient, and additionally, for any n∈Nn \in\mathbb{N}:

Ex←Dn[len⁡(Enc⁡n(x))]≤H(Dn)+δ(n)+2\mathbb{E}_{x\leftarrow D_n}[\operatorname{len}(\operatorname{Enc}_n(x))] \leq H(D_n) + \delta(n) + 2

Near-Optimal Compression Implies Accurate Autoregressive Models

Next, we show the other direction: if one has an encoding that compresses a given distribution near-optimally, it is possible to create an autoregressive model that is close to optimal in terms of the expected next-token cross entropy loss Et←D[L(M,t)]\mathbb{E}_{t\leftarrow D}[\mathcal{L}(M,t)]. Formally:

Theorem 3.3. Given a polynomial-sized alphabet family Σ={Σn}n∈N\Sigma= \{\Sigma_n\}_{n\in\mathbb{N}} and polynomial maximum length m(⋅)m(\cdot), there exists an oracle-aided algorithm M(⋅)M(\cdot) such that, for any family of distributions D={Dn}n∈ND = \{D_n\}_{n\in\mathbb{N}}, any function δ(⋅)\delta(\cdot), and any prefix-free, monotone (with respect to an ordering {≺n}n∈N\{\prec_n\}_{n\in\mathbb{N}}) and efficiently encodable family of encodings Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n\in\mathbb{N}} such that, for any n∈Nn \in\mathbb{N},

Ex←Dn[len⁡(Enc⁡n(x))]≤H(Dn)+δ(n)\mathbb{E}_{x\leftarrow D_n}[\operatorname{len}(\operatorname{Enc}_n(x))] \leq H(D_n) + \delta(n)

M(⋅)M(\cdot) defines a family of autoregressive models {Mn}n∈N\{M_n\}_{n\in\mathbb{N}} where, for any n∈Nn \in\mathbb{N} and t∈Σn≤m(n)t \in\Sigma_n^{\leq m(n)}, Mn(ti∣t<i)M_n(t_i \mid t_{<i}) is given by MEnc⁡n,≺n(1n,ti,t<i)M_{\operatorname{Enc}_n,\prec_n}(1^n,t_i,t_{<i}), M(⋅)M(\cdot) is efficiently computable, and the respective model MnM_n is δ(n)\delta(n)-optimal with respect to DnD_n.

Proof. (For ease of notation, we omit the parameter nn and demonstrate the following for any n∈Nn \in\mathbb{N}.) We wish to define a model MEnc⁡M_{\operatorname{Enc}} that induces a distribution DMD_M with a corresponding efficient random sampler Sample⁡:{0,1}∗→Σm(n)\operatorname{Sample}:\{0,1\}^* \to\Sigma^{m(n)} to be defined subsequently (that is, DM={c←{0,1}∗:Sample⁡(c)}D_M = \{c \leftarrow\{0,1\}^*:\operatorname{Sample}(c)\}). We will start by making the simplifying assumption that we know a bound ℓ(⋅)\ell(\cdot) such that len⁡(Enc⁡n(x))≤ℓ(n)\operatorname{len}(\operatorname{Enc}_n(x)) \leq\ell(n) for all x∈Σm(n)x \in\Sigma^{m(n)} (note that such a polynomial ℓ\ell exists since Enc⁡\operatorname{Enc} is efficient). Sample⁡\operatorname{Sample}, given a string c∈{0,1}ℓ(n)c \in\{0,1\}^{\ell(n)}, does as follows:

  • Find the largest x∈Σm(n)x \in\Sigma^{m(n)} with Enc⁡(x)≤c\operatorname{Enc}(x) \leq c. (findable by binary search over Σm(n)\Sigma^{m(n)}).12

  • Find the smallest ii such that Dec⁡(c≤i)≠⊥\operatorname{Dec}(c_{\leq i}) \ne\perp (where, leveraging monotonicity of Enc⁡\operatorname{Enc}, we define Dec⁡\operatorname{Dec} per Fact 2.3).

  • If there is no such ii, output xx. Otherwise output Dec⁡(c≤i)\operatorname{Dec}(c_{\leq i}).

By Fact 2.3 and monotonicity of Enc⁡\operatorname{Enc}, Dec⁡\operatorname{Dec} is efficiently computable, and thus Sample⁡\operatorname{Sample} is as well. Furthermore, we make the following claim that Sample⁡\operatorname{Sample} is weakly monotone (which nonetheless is sufficient for our proof):

Claim 3.4. Sample⁡\operatorname{Sample} is weakly monotone: for any c1,c2∈{0,1}ℓ(n)c_1,c_2 \in\{0,1\}^{\ell(n)}, if c1<c2c_1 < c_2, then Sample⁡(c1)≤Sample⁡(c2)\operatorname{Sample}(c_1) \leq\operatorname{Sample}(c_2).

Proof. This follows from the fact that, since Enc⁡\operatorname{Enc} is monotonic and Dec⁡\operatorname{Dec} inverts Enc⁡\operatorname{Enc} on its domain, Dec⁡\operatorname{Dec} must also be monotonic. If both c1c_1 and c2c_2 have prefixes (c1)≤i1(c_1)_{\leq i_1} and (c2)≤i2(c_2)_{\leq i_2} with valid decodings, then (c1)≤i1≤(c2)≤i2(c_1)_{\leq i_1} \leq(c_2)_{\leq i_2}, and the same is true of the respective decodings by monotonicity. In the case where no prefix of c2c_2 has a valid decoding, Sample⁡\operatorname{Sample} returns the last valid input whose encoding is smaller than c1c_1, which by monotonicity cannot be larger than Dec⁡(c2)\operatorname{Dec}(c_2) (or, in the case that c2c_2 also has no prefix with a valid decoding, the last valid input whose encoding is smaller than c2c_2) without contradicting the assumption that c1<c2c_1 < c_2. Finally, if no prefix of c2c_2 has a valid decoding but there is such a prefix for c1c_1, then Enc⁡(Sample⁡(c1))≤c1<c2\operatorname{Enc}(\operatorname{Sample}(c_1)) \leq c_1 < c_2. Thus Sample⁡(c1)\operatorname{Sample}(c_1) is a candidate in the search for the largest xx satisfying Enc⁡(x)≤c2\operatorname{Enc}(x) \le c_2. Since Sample⁡(c2)\operatorname{Sample}(c_2) returns that largest candidate, we obtain Sample⁡(c1)⪯Sample⁡(c2)\operatorname{Sample}(c_1) \preceq\operatorname{Sample}(c_2).

We first need to argue that KL(D∥DM)≤δKL(D \mathbin\Vert D_{\mathcal{M}}) \le\delta; towards that, we first observe that, for any x∈supp⁡(D)x \in\operatorname{supp}(D), DM(x)≥2−len⁡(Enc⁡(x))D_{\mathcal{M}}(x) \ge2^{-\operatorname{len}(\operatorname{Enc}(x))}. This is true because, whenever cc is drawn such that it has Enc⁡(x)\operatorname{Enc}(x) as a prefix (which happens with precisely probability 2−len⁡(Enc⁡(x))2^{-\operatorname{len}(\operatorname{Enc}(x))}), that prefix is shorter than the maximum length ℓ(n)\ell(n) by assumption, and it is also the shortest correctly decodable prefix by prefix-freeness of Enc⁡\operatorname{Enc}, and thus xx will be sampled. From here, Fact 2.10 implies:

KL(D∥DM)=H(D,DM)−H(D)KL(D \mathbin\Vert D_{\mathcal{M}}) = H(D,D_{\mathcal{M}}) - H(D)

But for any x∈supp⁡(D)x \in\operatorname{supp}(D), since DM(x)≥2−len⁡(Enc⁡(x))D_{\mathcal{M}}(x) \ge2^{-\operatorname{len}(\operatorname{Enc}(x))}:

−log⁡DM(x)≤len⁡(Enc⁡(x))-\log D_{\mathcal{M}}(x) \le\operatorname{len}(\operatorname{Enc}(x))

and thus, by our original assumption about the compression loss of Enc⁡\operatorname{Enc}:

−Ex←D[log⁡DM(x)]≤Ex←D[len⁡(Enc⁡(x))]≤H(D)+δ-\mathbb{E}_{x \leftarrow D}[\log D_{\mathcal{M}}(x)] \le\mathbb{E}_{x \leftarrow D}[\operatorname{len}(\operatorname{Enc}(x))] \le H(D) + \delta

But −Ex←D[log⁡DM(x)]-\mathbb{E}_{x \leftarrow D}[\log D_{\mathcal{M}}(x)] is exactly the cross-entropy H(D,DM)H(D,D_{\mathcal{M}}), so:

KL(D∥DM)≤(H(D)+δ)−H(D)=δKL(D \mathbin\Vert D_{\mathcal{M}}) \le(H(D) + \delta) - H(D) = \delta

as desired.

Thus far, we have given a description of the induced distribution DMD_{\mathcal{M}} in terms of the random sampler Sample⁡\operatorname{Sample}, but not constructed the actual model MEnc⁡\mathcal{M}^{\operatorname{Enc}} nor shown that it is efficiently computable. Fortunately, Claim 2.13 provides both of these as long as we can efficiently compute Pr⁡x←DM[x⪯y]\Pr_{x \leftarrow D_{\mathcal{M}}}[x \preceq y] for any y∈Σm(n)y \in\Sigma^{m(n)}.13 However, we claim that, using the efficiency of Sample⁡\operatorname{Sample} and Claim 3.4, we can do precisely this:

Claim 3.5. For any y∈Σm(n)y \in\Sigma^{m(n)}, Pr⁡x←DM[x⪯y]\Pr_{x \leftarrow D_{\mathcal{M}}}[x \preceq y] can be efficiently computed.

Proof. If we can efficiently determine the largest c∈{0,1}ℓ(n)c \in\{0,1\}^{\ell(n)} such that Sample⁡(c)⪯y\operatorname{Sample}(c) \preceq y (taking c=0ℓ(n)c = 0^{\ell(n)} if there is no such cc), then we can immediately determine that (taking cc as an integer) Pr⁡x←DM[x⪯y]=(c+1)/2ℓ(n)\Pr_{x \leftarrow D_{\mathcal{M}}}[x \preceq y] = (c+1)/2^{\ell(n)}, as sampling from DMD_{\mathcal{M}} is by definition equivalent to sampling Sample⁡(c)\operatorname{Sample}(c) for uniformly random c∈{0,1}ℓ(n)c \in\{0,1\}^{\ell(n)}. And weak monotonicity from Claim 3.4 is sufficient to show that we can find such a cc using binary search over {0,1}ℓ(n)\{0,1\}^{\ell(n)}, which must run in time polynomial in nn since it requires at most ℓ(n)\ell(n) iterations (which we know is polynomial) and each iteration requires computing Sample⁡\operatorname{Sample} and comparing elements of Σm(n)\Sigma^{m(n)}, both of which are efficient.

Thus, by Claim 2.13, we have constructed an efficiently computable autoregressive model M\mathcal{M} with induced distribution DMD_{\mathcal{M}} that, as we have argued, suffices to complete the argument given an a priori bound of ℓ\ell on the length of Enc⁡(x)\operatorname{Enc}(x).

Removing ℓ\ell. Next, we explain how to remove the assumption that ℓ\ell is known. First, we modify Sample⁡\operatorname{Sample} to, rather than sampling c←{0,1}ℓ(n)c \leftarrow\{0,1\}^{\ell(n)}, instead lazily sample c←{0,1}∗c \leftarrow\{0,1\}^*; specifically, during the binary search, each time Sample⁡\operatorname{Sample} compares cc to some output Enc⁡(y)\operatorname{Enc}(y) for y∈Σmy \in\Sigma^m, if the length of the sampled cc is shorter than len⁡(Enc⁡(y))\operatorname{len}(\operatorname{Enc}(y)), Sample⁡\operatorname{Sample} draws new uniformly random bits of cc up to length ∣Enc⁡(y)∣|\operatorname{Enc}(y)|. We argue that the output of Sample⁡\operatorname{Sample} is identical. Letting xx be the largest x∈Σmx \in\Sigma^m such that Enc⁡(x)≤c\operatorname{Enc}(x) \le c, we notice that number of bits of cc sampled by Sample⁡\operatorname{Sample} is at least ∣Enc⁡(x)∣|\operatorname{Enc}(x)| by construction. Moreover, if (the ℓ\ell-bit long) cc has a prefix c≤ic_{\le i} which is a valid codeword, then by monotonicity c≤ic_{\le i} is a prefix of Enc⁡(x)\operatorname{Enc}(x) (otherwise, Enc⁡(x)<c≤i≤c\operatorname{Enc}(x) < c_{\le i} \le c, contradicting xx being the largest x∈Σmx \in\Sigma^m such that Enc⁡(x)≤c\operatorname{Enc}(x) \le c). Thus, in this case, Sample⁡\operatorname{Sample} must return Dec⁡(c≤i)\operatorname{Dec}(c_{\le i}) as before; if there is no such prefix, then Sample⁡\operatorname{Sample} by construction finds and returns xx, as desired. Similarly, when computing the CDF in Claim 3.5, finding the largest cc such that Sample⁡(c)≤y\operatorname{Sample}(c) \le y is done by binary search where the length of the string cc is determined by the number of random bits Sample reads during its execution on cc. In the ithi^{\text{th}} step of the binary search, we know the prefix c<ic_{<i}, and we learn the ithi^{\text{th}} bit by comparing the output of Sample⁡(c<i∥10∗)\operatorname{Sample}(c_{<i}\Vert10^*) to yy (if yy is smaller, the next bit is 0, where if yy is larger or equal the next bit is 1). We terminate the search when, on the current prefix of cc, the execution of Sample halts on the prefix without drawing any additional random bits. After ∣c∣|c| steps, we learn the entire string cc, and can then compute the CDF Pr⁡x←DM[x⪯y]\Pr_{x \leftarrow D_M}[x \preceq y] as before by setting ℓ=∣c∣\ell= |c|.

As a final note, the random sampler Sample we constructed gives the following corollary, which intuitively states that, given δ\delta-optimal compression Enc for a distribution, it can be efficiently and δ\delta-approximately sampled:

Corollary 3.6. Given a polynomial-sized alphabet family Σ={Σn}n∈N\Sigma= \{\Sigma_n\}_{n \in\mathbb{N}} and polynomial maximum length m(⋅)m(\cdot), there exists an oracle-aided sampling algorithm Sample⁡(⋅)\operatorname{Sample}(\cdot) such that, for any family of distributions D={Dn}n∈ND = \{D_n\}_{n \in\mathbb{N}}, function δ(⋅)\delta(\cdot), and prefix-free, monotone, and efficiently encodable family of encodings Enc⁡={Enc⁡n}n∈N\operatorname{Enc} = \{\operatorname{Enc}_n\}_{n \in\mathbb{N}} where, for any n∈Nn \in\mathbb{N},

Ex←Dn[len⁡(Enc⁡n(x))]≤H(Dn)+δ(n)\mathbb{E}_{x \leftarrow D_n}[\operatorname{len}(\operatorname{Enc}_n(x))] \le H(D_n) + \delta(n)

Sample⁡(⋅)\operatorname{Sample}(\cdot) defines an efficiently computable family of randomized algorithms {Sample⁡n}n∈N\{\operatorname{Sample}_n\}_{n \in\mathbb{N}} such that there exists a family of distributions {Dn∗}n∈N\{D_n^*\}_{n \in\mathbb{N}} where, for any n∈Nn \in\mathbb{N}, Sample⁡n\operatorname{Sample}_n samples from Dn∗D_n^* and KL⁡(Dn∥Dn∗)≤δ(n)\operatorname{KL}(D_n \mathbin\Vert D_n^*) \le\delta(n).

One-Way Functions and the Monotonicity Requirement

Given that our results in the previous section show equivalence between next-token prediction and specifically monotone compression, the question arises of whether one can show a similar equivalence for non-monotone compression, or more specifically whether there are certain conditions under which one can (or cannot) show such an equivalence. In this section, we demonstrate such conditions based on a standard cryptographic assumption: the existence of one-way functions. Whereas Theorem 3.3 shows that monotone compression can be used to construct an autoregressive model with the same loss, we show in § 4.2 that, given the existence of one-way functions, there exists a family of distributions with non-monotone compression where no efficiently computable autoregressive model can even achieve a cross-entropy loss within an arbitrary constant of the compression loss; the transformation necessarily incurs a loss linear in the input length nn. Thus, if one-way functions exist, there is a distinct separation between the results that can be achieved with monotone compression compared to non-monotone compression.

Conversely, we show in § 4.3 that, if one-way functions do not exist, classic results on next-bit prediction [10] can be leveraged to show an analogue of Theorem 3.3 without the requirement for monotonicity. At a high level, if one-way functions do not exist, [10] shows that any (binary) distribution must admit an approximately accurate next-bit predictor. The transformation is not a perfect equivalence, as it creates a small amount of additional statistical distance loss in contrast to Theorem 3.3 (where there is only cross-entropy loss equal to the compression loss); nonetheless, it still constitutes a significant difference compared to what is attainable if one-way functions exist.

Preliminaries

In order to formally state our results, we first precisely define one-way functions.

Definition 4.1. A family of functions F={fn}n∈N\mathcal{F} = \{f_n\}_{n \in\mathbb{N}}, where fn:{0,1}n→{0,1}nf_n : \{0,1\}^n \to\{0,1\}^n, is one-way if F\mathcal{F} is efficiently computable but, for any non-uniform polynomial-time inverter A\mathcal{A}, there is a negligible function ϵ(⋅)\epsilon(\cdot) such that for any n∈Nn \in\mathbb{N}:

Pr⁡x←{0,1}n[f(A(1n,f(x)))=f(x)]≤ϵ(n)\Pr_{x \leftarrow\{0,1\}^n}[f(\mathcal{A}(1^n,f(x))) = f(x)] \le\epsilon(n)

If the above instead holds for only infinitely many n∈Nn \in\mathbb{N} for any non-uniform polynomial-time inverter AA, we say that FF is infinitely-often one-way.

That is, one-way functions are efficiently computable, but “hard to invert” in the sense that no computationally efficient algorithm, given the image of a uniformly selected input, can find any inverse of that image with probability significantly better than brute force. The existence of one-way functions is a long-standing open conjecture as it would imply P≠NPP \ne NP, but they are nonetheless widely used as a fundamental building block of modern cryptography. The existence of one-way functions is also well-known to imply the existence of pseudorandom generators:

Definition 4.2. For some output length ℓ(n)>n\ell(n) > n, a family of efficiently computable functions G={gn}n∈NG = \{g_n\}_{n \in\mathbb{N}} is referred to as a family of pseudorandom generators (PRGs) if, for any polynomial-time distinguisher DD with output in {0,1}\{0,1\}, there exists a negligible function ϵ(⋅)\epsilon(\cdot) such that for any n∈Nn \in\mathbb{N}:

∣Pr⁡x←Un[D(1n,gn(x))=1]−Pr⁡y←Uℓ(n)[D(1n,y)=1]∣≤ϵ(n)\left|\Pr_{x \leftarrow U_n}[D(1^n,g_n(x))=1]-\Pr_{y \leftarrow U_{\ell(n)}}[D(1^n,y)=1]\right| \le\epsilon(n)

where UkU_k represents the uniform distribution over {0,1}k\{0,1\}^k.

That is, the output of a PRG on a uniform input should be computationally indistinguishable from uniform randomness.

One-Way Functions Imply Separation

We can, in fact, use PRGs to show a separation between monotone and non-monotone compression: in contrast to Theorem 3.3, which shows that any monotone compression scheme for a distribution can be transformed into a next-bit predictor for that distribution whose negative log-likelihood is identical to the compression loss, we can show that, assuming the existence of infinitely-often one-way functions (and thus PRGs), there is a family of distributions DD and a non-monotone compression scheme that is optimal for DD but is such that no efficiently computable autoregressive model exists that can predict DD with even an arbitrary constant negative log-likelihood:

Theorem 4.3. Assuming the existence of one-way functions (respectively, infinitely-often one-way functions), there exists a family of efficiently samplable distributions D={Dn}n∈ND = \{D_n\}_{n \in\mathbb{N}} and a prefix-free family of encodings Enc={Encn}n∈N\mathrm{Enc} = \{\mathrm{Enc}_n\}_{n \in\mathbb{N}} with efficient encoding and decoding such that Ex∼Dn[len⁡(Encn(x))]=H(Dn)\mathbb{E}_{x \sim D_n}[\operatorname{len}(\mathrm{Enc}_n(x))] = H(D_n) for any n∈Nn \in\mathbb{N}, but, given any efficiently computable family of autoregressive models {Mn}n∈N\{M_n\}_{n \in\mathbb{N}}, for any constant ϵ>0\epsilon> 0 and all sufficiently large (resp., infinitely many) n∈Nn \in\mathbb{N}, the respective output distribution DMnD_{M_n} is such that KL(Dn∥DMn)≥(1−ϵ)nKL(D_n \mathbin\Vert D_{M_n}) \ge(1-\epsilon)n.14

Below we prove the theorem assuming the existence of one-way functions. We note that the proof holds nearly identically for the case of infinitely-often OWFs, with the exception that it applies only to infinitely many n∈Nn \in\mathbb{N} rather than all sufficiently large nn; we note the distinctions during the proof.

Proof. As the existence of one-way functions implies the existence of PRGs (respectively, infinitely-often OWFs imply infinitely-often PRGs, or PRGs where the condition holds for only infinitely many n∈Nn \in\mathbb{N}), let G={gn}n∈NG = \{g_n\}_{n \in\mathbb{N}} be a PRG with output length ℓ(n)=2n\ell(n) = 2n. Take our alphabet of tokens to be Σ={0,1}\Sigma= \{0,1\}. Let DD be given by Dn={x←Un:gn(x)}D_n = \{x \leftarrow U_n : g_n(x)\}.\footnote{This implies that, for any constant δ\delta, MM cannot be δ\delta-optimal with respect to DD.} Let Enc\mathrm{Enc} be given by Encn(gn(x),x)=x\mathrm{Enc}_n(g_n(x),x) = x.15 Clearly, Enc\mathrm{Enc} satisfies prefix-freeness (since every codeword has the same length), efficient encoding and decoding, and has Ex∼Dn[len⁡(Encn(x))]=H(Dn)=n\mathbb{E}_{x \sim D_n}[\operatorname{len}(\mathrm{Enc}_n(x))] = H(D_n) = n.

Now fix ϵ>0\epsilon> 0 and assume for the sake of contradiction that there exists a family of autoregressive models {Mn}n∈N\{M_n\}_{n \in\mathbb{N}} such that KL(Dn∥DMn)<(1−ϵ)nKL(D_n \mathbin\Vert D_{M_n}) < (1-\epsilon)n for infinitely many (resp., all sufficiently large) n∈Nn \in\mathbb{N}. We use this to construct a distinguisher A\mathcal{A} as follows: Take constant c>log⁡(2/ϵ)c > \log(2/\epsilon), and, given an input yy (which will either be drawn as U2nU_{2n} or as gn(Un)g_n(U_n), define DMn(y,∗)DM_n(y, *) as the probability for the first 2n2n bits of an output from MnM_n to be equal to yy, and let AA output 1 when DMn(y,∗)≥2c−2nDM_n(y, *) \ge2^{c-2n} and 0 otherwise. We make the following claims to complete the proof by contradiction:

Claim 4.4. Pr⁡[y←U2n:A(y)=1]≤2−c\Pr[y \leftarrow U_{2n}: A(y) = 1] \le2^{-c}.

Proof. Ey←U2n[DMn(y,∗)]=2−2nE_{y \leftarrow U_{2n}}[DM_n(y, *)] = 2^{-2n}, so this follows from Markov’s inequality.

Claim 4.5. For any constant ϵ′>0\epsilon' > 0, Pr⁡[x←Un:A(gn(x))=1]>ϵ/2−ϵ′\Pr[x \leftarrow U_n: A(g_n(x)) = 1] > \epsilon/2 - \epsilon' for all sufficiently large n∈Nn \in\mathbb{N} where KL(Dn∥DMn)<(1−ϵ)nKL(D_n \mathbin\Vert DM_n) < (1-\epsilon)n.

Proof. This follows from the assumption that KL(Dn∥DMn)<(1−ϵ)nKL(D_n \mathbin\Vert DM_n) < (1-\epsilon)n, and thus, by data processing, that KL((Dn)≤2n∥(DMn)≤2n)<(1−ϵ)nKL((D_n)_{\leq2n} \mathbin\Vert(DM_n)_{\leq2n}) < (1-\epsilon)n (where (Dn)≤2n(D_n)_{\leq2n} represents the distribution of the first 2n2n bits of DnD_n, and respectively for DMnDM_n). Thus:

KL((Dn)≤2n∥(DMn)≤2n)=Ey←Dn[log⁡(1/DMn(y,∗))]−H((Dn)≤2n)<(1−ϵ)nKL((D_n)_{\leq2n} \mathbin\Vert(DM_n)_{\leq2n}) = E_{y \leftarrow D_n}[\log(1/DM_n(y, *))] - H((D_n)_{\leq2n}) < (1-\epsilon)n

and so

Ex←Un[log⁡(1/DMn(gn(x),∗))]=Ey←Dn[log⁡(1/DMn(y,∗))]<(1−ϵ)n+H((Dn)≤2n)≤(2−ϵ)nE_{x \leftarrow U_n}[\log(1/DM_n(g_n(x), *))] = E_{y \leftarrow D_n}[\log(1/DM_n(y, *))] < (1-\epsilon)n + H((D_n)_{\leq2n}) \leq(2-\epsilon)n

since H((Dn)≤2n)≤H(Dn)=nH((D_n)_{\leq2n}) \leq H(D_n) = n. Now, by construction of AA, AA outputs 1 whenever log⁡(1/DMn(y,∗))<2n−c\log(1/DM_n(y, *)) < 2n-c; by Markov’s inequality and the above bound on the expectation, the probability that this is not true (i.e., that AA outputs 0) when yy is given by gn(x)g_n(x) for x←Unx \leftarrow U_n can be at most (2−ϵ)n2n−c\frac{(2-\epsilon)n}{2n-c}, so the probability that AA outputs 1, then, must be at least

1−(2−ϵ)n2n−c=ϵn−c2n−c1-\frac{(2-\epsilon)n}{2n-c}=\frac{\epsilon n-c}{2n-c}

which asymptotically approaches ϵ/2\epsilon/2 as n→∞n \to\infty, implying the conclusion.

Given these, since we assumed by construction that $2^{-c}isaconstantsmallerthanis a constant smaller than\epsilon/2, there is a non-negligible (constant) separation between the two probabilities for infinitely many (resp., any sufficiently large) nn, which contradicts the assumption that GG is a PRG (resp., infinitely-often PRG) and completes the proof.

Nonexistence of One-Way Functions Implies (Approximate) Equivalence

In contrast to the above, we show that, if infinitely-often one-way functions do not exist, then given any compression scheme for a distribution over a binary support, one can construct an autoregressive model (i.e., a next-bit predictor) for that distribution which is “approximately” as good. This follows from a theorem proven in [10], and in fact we observe that it does not require full non-existence of one-way functions, only that a specific function relative to the given distribution is easy to invert. First, we must define what we mean by a model being “approximately as good” in this case—unlike our previous results, this will involve a loss of statistical distance in addition to the inherent loss of negative log-likelihood resulting from the underlying compression scheme’s loss:

Definition 4.6. For alphabet Σ\Sigma and distribution DD over Σm\Sigma^m, we say that an autoregressive model MM is ϵ\epsilon-approximately δ\delta-optimal with respect to DD if there exists a model M′M' that is δ\delta-optimal with respect to DD and, Δ(DM,DM′)≤ϵ\Delta(D_M,D_{M'}) \leq\epsilon.

We can then leverage the following theorem from [10]:

Theorem 4.7 (Infinitely-often one-way functions and next-bit predictors [[IL89]). Let D={Dn}n∈ND = \{D_n\}_{n \in\mathbb{N}} be a family of efficiently samplable distributions where each DnD_n distributed over {0,1}m(n)\{0,1\}^{m(n)} for some polynomial m(n)m(n). Then, for any function ϵ(n)∈1/poly⁡(n)\epsilon(n) \in1/\operatorname{poly}(n), there exists a function ff such that, if ff is not an infinitely-often one-way function, then there exists an ϵ(n)\epsilon(n)-approximate (00-optimal) efficiently computable autoregressive model for DD.

Proof. [10] showed that for every family of efficiently samplable distributions D\mathcal{D} and for any ϵ′(n)∈1/poly⁡(n)\epsilon'(n) \in1/\operatorname{poly}(n), there exists a function ff such that, if ff is not an infinitely-often one-way function, then there exists a (non-uniform) efficient randomized next bit-predictor Pred⁡\operatorname{Pred} with

Pr⁡t←Dn[Pred⁡(ti∣t<i)∈Dn(ti∣t<i)(1−ϵ′,1+ϵ′)]≥1−ϵ′\Pr_{t \leftarrow D_n}\left[\operatorname{Pred}(t_i \mid t_{<i}) \in D_n(t_i \mid t_{<i})(1-\epsilon',1+\epsilon')\right] \ge1-\epsilon'

for every sufficiently large n∈Nn \in\mathbb{N}. We first notice that Pred⁡\operatorname{Pred} can be made deterministic by fixing the randomness to the best possible string for each index ii as part of the non-uniform advice. Next, we notice that Pred⁡\operatorname{Pred} is already an ϵ=O(ϵ′⋅m(n))\epsilon= O(\epsilon'\cdot m(n))-approximate model for D\mathcal{D}, as the above promise on Pred⁡\operatorname{Pred} implies that its output is close in statistical distance to the distribution DnD_n.

Remark. In fact, Theorem 4.7 can be made stronger: one can show the existence of such a model based on an inverter to a specific function (as opposed to complete non-existence of infinitely-often one-way functions, which would imply the existence of an inverter for every function). In particular, [10] showed that for any ϵ(n)∈1/poly⁡(n)\epsilon(n) \in1/\operatorname{poly}(n), there exists a pair of efficient oracle-aided algorithms (f(⋅),Pred⁡(⋅))(f^{(\cdot)},\operatorname{Pred}(\cdot)) such that, given a sampler Sample⁡\operatorname{Sample} for an ensemble of samplable distributions D\mathcal{D}, if there exists a polynomial-time algorithm AA that, for all sufficiently large n∈Nn \in\mathbb{N}, inverts fSample⁡f^{\operatorname{Sample}} with probability 1/21/2, then Pred⁡A\operatorname{Pred}^{A} is an ϵ\epsilon-approximate next-bit predictor for D\mathcal{D}. (In particular, fSample⁡(x1,…,xt)=gSample⁡(x1),…,gSample⁡(xt)f^{\operatorname{Sample}}(x_1,\ldots,x_t) = g^{\operatorname{Sample}}(x_1),\ldots,g^{\operatorname{Sample}}(x_t), where gSample⁡(r,h,i,j)=(i,j,h,Sample⁡(r)≤i,h(r)≤j)g^{\operatorname{Sample}}(r,h,i,j) = (i,j,h,\operatorname{Sample}(r)_{\leq i},h(r)_{\leq j}), hh is a 22-universal hash function, and t∈O(n/ϵ)t \in O(n/\epsilon).)

With the above theorem, given a non-monotone compression scheme Enc⁡\operatorname{Enc} which is δ\delta-optimal for some distribution family D\mathcal{D}, we can leverage part of the construction from Theorem 3.3 even though Enc⁡\operatorname{Enc} is not monotone. We prove the following theorem.

Theorem 4.8. If infinitely-often one-way functions do not exist, then the following is true for any ϵ(n)∈1/poly⁡(n)\epsilon(n) \in1/\operatorname{poly}(n):

For every family D={Dn}n∈N\mathcal{D} = \{D_n\}_{n\in\mathbb{N}} distributions and a compression scheme (Enc⁡,Dec⁡)(\operatorname{Enc},\operatorname{Dec}) with efficient encoding and decoding that is δ\delta-optimal for D\mathcal{D}, there exists an efficiently computable autoregressive models {Mn}n∈N\{\mathcal{M}_n\}_{n\in\mathbb{N}} where, for any n∈Nn \in\mathbb{N} the respective model Mn\mathcal{M}_n is ϵ(n)\epsilon(n)-approximately δ(n)\delta(n)-optimal with respect to DnD_n.

Proof. We first notice that, for any nn we can construct a distribution Dn′D'_n such that KL(Dn,Dn′)≤δ(n)KL(D_n,D'_n) \leq\delta(n). Specifically, we showed in the proof of Theorem 3.3 that the distribution DMD_{\mathcal{M}}, which can be thought of as sampling a uniformly random string and decoding the (unique) codeword that is a prefix of that string, is not only efficiently samplable even when Enc⁡\operatorname{Enc} is non-monotone (it requires only that Enc⁡\operatorname{Enc} has an efficient decoding algorithm Dec⁡\operatorname{Dec}), but induces a model M∗\mathcal{M}^* which is δ\delta-optimal with respect to D\mathcal{D}. (We note that Sample⁡\operatorname{Sample} as written requires binary search and thus monotonicity to be efficient, but, if weak monotonicity is not needed, one can replace this step while preserving δ\delta-optimality by returning an arbitrary output if the given random string has no validly decodable prefix.)

Next, while M∗\mathcal{M}^* is not necessarily efficiently computable if Enc⁡\operatorname{Enc} (and thus Sample⁡\operatorname{Sample}) is non-monotone, Theorem 4.7 shows directly that, if infinitely-often one-way functions do not exist, then for any function ϵ(n)∈1/poly⁡(n)\epsilon(n) \in1/\operatorname{poly}(n) there is a model M\mathcal{M} that is ϵ(n)\epsilon(n)-approximate with respect to DMD_{\mathcal{M}} and thus an ϵ(n)\epsilon(n)-approximate δ\delta-optimal model for D\mathcal{D}.

Next-Bit Pseudoentropy and Monotone Incompressibility

In this section, we discuss an interesting application of our results to cryptography—specifically, the relation between the compressibility of a distribution and its pseudoentropy [5], which can be thought of as a computational analogue of entropy. Informally, a distribution DD has pseudoentropy at least hh if it is computationally indistinguishable from some distribution D′D' with Shannon entropy H(D′)≥hH(D') \geq h. Restricting to the case of binary distributions (Σ={0,1}\Sigma= \{0,1\}), we will formally consider a related notion of next-bit pseudoentropy, or pseudoentropy with respect to next-bit prediction:

Definition 5.1 ([21]). Given jointly distributed families of random variables X={Xn}n∈N\mathcal{X} = \{X_n\}_{n\in\mathbb{N}} and B={Bn}n∈N\mathcal{B} = \{B_n\}_{n\in\mathbb{N}}, where B\mathcal{B} takes values in {0,1}\{0,1\}, we say that B\mathcal{B} has (non-uniform) conditional pseudoentropy at least h(⋅)h(\cdot) given X\mathcal{X} if, for any polynomial p(⋅)p(\cdot), there exists a {0,1}\{0,1\}-valued family C={Cn}n∈N\mathcal{C} = \{C_n\}_{n\in\mathbb{N}} of random variables jointly distributed with (X,B)(\mathcal{X},\mathcal{B}) such that:

  1. For all sufficiently large n∈Nn \in\mathbb{N}, H(Cn∣Xn)≥h(n)−1/p(n)H(C_n|X_n) \ge h(n) - 1/p(n)

  1. The families (X,B)(\mathcal{X},\mathcal{B}) and (X,C)(\mathcal{X},\mathcal{C}) are computationally indistinguishable.16

Given a polynomial m(⋅)m(\cdot) and family of random variables B={Bn}n∈N\mathcal{B} = \{B_n\}_{n\in\mathbb{N}} where BnB_n takes values in {0,1}m(n)\{0,1\}^{m(n)}, we say that B\mathcal{B} has (non-uniform) next-bit pseudoentropy at least h(⋅)h(\cdot) if, letting family I={In}n∈N\mathcal{I} = \{I_n\}_{n\in\mathbb{N}} be such that InI_n is uniformly distributed over [m(n)][m(n)], then the conditional pseudoentropy of the family {(Bn)In}n∈N\{(B_n)_{I_n}\}_{n\in\mathbb{N}} given {(Bn)<In}n∈N\{(B_n)_{<I_n}\}_{n\in\mathbb{N}} is at least h(n)/m(n)h(n)/m(n).

[HMS23] shows a partial characterization of the relation between next-bit pseudoentropy and compressibility of a family of distributions (a notion originally proposed by [22]). Specifically, they show that incompressibility implies pseudoentropy ([HMS23], Lemma 36): if a family of distributions B={Bn}n∈N\mathcal{B} = \{B_n\}_{n\in\mathbb{N}} over {0,1}m(n)\{0,1\}^{m(n)} cannot be compressed with some length k(n)k(n), then it must have next-bit pseudoentropy at least k(n)−2k(n) - 2. However, they also show that the converse is not true; in fact, there exists a separation ([HMS23], Prop. 39, Lemma 42) showing that, assuming the existence of one-way functions, next-bit pseudoentropy cannot imply incompressibility unless it is strengthened to a notion of “strong” next-bit pseudoentropy which requires next-bit pseudoentropy of {Enc⁡(Bn)}n∈N\{\operatorname{Enc}(B_n)\}_{n\in\mathbb{N}} for any efficient encoding Enc⁡(⋅)\operatorname{Enc}(\cdot).

Our results, in fact, complete the characterization of standard next-bit pseudoentropy by showing that, up to a constant, it is equivalent to monotone incompressibility. This is illustrated by the following corollary of Corollary 3.9 of [21]:

Corollary 5.2 ([21 HMS23]). Given polynomial maximum length m(⋅)m(\cdot) and family of distributions D={Dn}n∈N\mathcal{D} = \{D_n\}_{n\in\mathbb{N}} where DnD_n is a distribution over {0,1}m(n)\{0,1\}^{m(n)}, for some function δ(⋅)\delta(\cdot), D\mathcal{D} has next-bit pseudoentropy at least H(Dn)+δ(n)H(D_n) + \delta(n) if and only if, for any polynomial p(⋅)p(\cdot), for every efficiently computable autoregressive model family M={Mn}n∈N\mathcal{M} = \{M_n\}_{n\in\mathbb{N}} and every sufficiently large n∈Nn \in\mathbb{N}, MnM_n is not (δ(n)−1/p(n))(\delta(n) - 1/p(n))-optimal with respect to DnD_n.

The original corollary in [21] shows an equivalence between B\mathcal{B} given X\mathcal{X} (as given in Definition 5.1) having conditional pseudoentropy H(Bn∣Xn)+δ(n)H(B_n|X_n) + \delta(n) and B\mathcal{B} being δ(n)\delta(n)-KLKL-hard given X\mathcal{X}—that is, that there exists no efficient predictor P(x)P(x) that attempts to predict BB given XX and has KL((X,B)∥(X,P(X)))≤δ(n)KL((X,B) \mathbin\Vert(X,P(X))) \le\delta(n). [HMS23] observed that, given a family D\mathcal{D} of distributions, one can apply this to a uniformly random bit in a distribution DnD_n (as in the definition of next-bit entropy) and use the additivity of entropy and KL-divergence chain rule to immediately imply that D\mathcal{D} not having “non-trivial” next-bit entropy H(Dn)+δ(n)H(D_n) + \delta(n) implies a next-bit predictor M\mathcal{M} for any bit of the distribution DnD_n (i.e., an autoregressive model, using our terminology) for which KL(Dn∥DMn)≤δ(n)KL(D_n \mathbin\Vert D_{\mathcal{M}_n}) \le\delta(n), or, in other words, M\mathcal{M} is δ(n)\delta(n)-optimal with respect to D\mathcal{D}.

Returning to the equivalence between next-bit pseudoentropy and monotone compression and applying Corollary 5.2, we can now observe that this equivalence is intuitively the same as equivalence between next-bit prediction and monotone compression, which, in fact, is precisely what we have shown in § 3. The first direction is immediate from (the contrapositive of) Theorem 3.2 and Corollary 5.2, though we note that it is also already proven implicitly in Lemma 36 of [HMS23] because their construction of a compression scheme is monotone.

Corollary 5.3. Given polynomial maximum length m(⋅)m(\cdot) and family of distributions D={Dn}n∈N\mathcal{D} = \{D_n\}_{n\in\mathbb{N}} where DnD_n is a distribution over {0,1}m(n)\{0,1\}^{m(n)}, if, for some function k(⋅)k(\cdot), D\mathcal{D} cannot be monotonically compressed to length k(n)k(n) infinitely often (namely, for any efficient, monotone, prefix-free encoding Enc⁡\operatorname{Enc}, Ex←Dn[∣Enc⁡(x)∣]≥k(n)\mathbb{E}_{x\leftarrow D_n}[\lvert\operatorname{Enc}(x)\rvert] \ge k(n) for all but finitely many n∈Nn \in\mathbb{N}), then D\mathcal{D} has next-bit pseudoentropy at least k(n)−2k(n) - 2. Specifically, if D\mathcal{D} has insufficient pseudoentropy, then by Corollary 5.2 it must have a (k(n)−2−H(Dn)−1/poly⁡(n))(k(n)-2-H(D_n)-1/\operatorname{poly}(n))-optimal efficiently computable autoregressive model family M\mathcal{M}, and Theorem 3.2 demonstrates that arithmetic encoding gives efficient and length-(k(n)−1/poly⁡(n))(k(n)-1/\operatorname{poly}(n)) compression. The other direction is also immediate from our Theorem 3.3 and Corollary 5.2:

Corollary 5.4. Given polynomial maximum length m(⋅)m(\cdot) and family of distributions D={Dn}n∈N\mathcal{D} = \{D_n\}_{n \in\mathbb{N}} where DnD_n is a distribution over {0,1}m(n)\{0,1\}^{m(n)}, if, for some function k(⋅)k(\cdot), D\mathcal{D} has next-bit pseudoentropy at least k(n)k(n), then, for any polynomial p(⋅)p(\cdot), D\mathcal{D} cannot be monotonically compressed to length k(n)−1/p(n)k(n)-1/p(n).

Since Theorem 3.3 shows that D\mathcal{D} having length-(k(n)−1/poly⁡(n))(k(n)-1/\operatorname{poly}(n)) compression implies a (k(n)−H(Dn)−1/poly⁡(n))(k(n)-H(D_n)-1/\operatorname{poly}(n))-optimal autoregressive model family M\mathcal{M}, the other direction of Corollary 5.2 implies that D\mathcal{D} cannot have next-bit pseudoentropy at least k(n)k(n) in this case.

Generative AI Use Disclosure

While finalizing this paper for submission, we used generative AI tools to review our draft in order to fix typographical errors, evaluate technical correctness of our proofs and suggest fixes where applicable, and suggest improvements to the structure and readability of our introduction. We emphasize that all results and writing presented in this paper were produced by the authors, except parts of the technical overview (§ 1.2), which were rewritten using AI tools and subsequently reviewed and edited by the authors.

References

  1. [1]Grégoire Delétang, Anian Ruoss, Paul-Ambroise Duquenne, Elliot Catt, Tim Genewein, Christopher Mattern, Jordi Grau-Moya, Li Kevin Wenliang, Matthew Aitchison, Laurent Orseau, Marcus Hutter, and Joel Veness. Language modeling is compression. In The Twelfth International Conference on Learning Representations, 2024.arxiv.org/abs/2309.10668
  2. [2]Eibe Frank, Chang Chui, and Ian H. Witten. Text categorization using compression models. In Proceedings DCC 2000. Data Compression Conference, pages 555–, 2000.
  3. [3]E. N. Gilbert and E. F. Moore. Variable-Length Binary Encodings. The Bell System Technical Journal, 38(4):933–967, 1959.DOI
  4. [4]Andrew V. Goldberg and Michael Sipser. Compression and Ranking. In Proceedings of the Seventeenth Annual ACM Symposium on Theory of Computing, STOC ’85, page 440–448, New York, NY, USA, 1985. Association for Computing Machinery.
  5. [5]Johan Håstad, Russell Impagliazzo, Leonid A. Levin, and Michael Luby. A Pseudorandom Generator from any One-Way Function. SIAM Journal on Computing, 28(4):1364–1396, 1999.DOI
  6. [6]Shuichi Hirahara, Zhenjian Lu, and Mikito Nanashima. Optimal Coding for Randomized Kolmogorov Complexity and Its Applications. In 2024 IEEE 65th Annual Symposium on Foundations of Computer Science (FOCS), pages 369–378, 2024.arxiv.org/abs/2409.12744
  7. [9][HZSH24] Yuzhen Huang, Jinghan Zhang, Zifei Shan, and Junxian He. Compression represents intelligence linearly. In *First Conference on Language Modeling*, 2024.arxiv.org/abs/2404.09937
  8. [10][IL89] Russell Impagliazzo and Michael Luby. One-way functions are essential for complexity based cryptography. In *30th Annual Symposium on Foundations of Computer Science*, pages 230–235. IEEE Computer Society, 1989.DOI
  9. [11][Mah99] Matthew V. Mahoney. Text compression as a Test for Artificial Intelligence. In *Proceedings of the Sixteenth National Conference on Artificial Intelligence and the Eleventh Innovative Applications of Artificial Intelligence Conference Innovative Applications of Artificial Intelligence*, AAAI ’99/IAAI ’99, page 970, USA, 1999. American Association for Artificial Intelligence.
  10. [12][Mah00] Matthew V. Mahoney. Fast Text Compression with Neural Networks. In *Proceedings of the Thirteenth International Florida Artificial Intelligence Research Society Conference*, page 230–234. AAAI Press, 2000.
  11. [13][SH94] Jürgen Schmidhuber and Stefan Heil. Predictive Coding with Neural Nets: Application to Text Compression. In *Proceedings of the 8th International Conference on Neural Information Processing Systems*, NIPS’94, page 1047–1054, Cambridge, MA, USA, 1994. MIT Press.
  12. [14][SH96] Jürgen Schmidhuber and Stefan Heil. Sequential Neural Text Compression. *IEEE Transactions on Neural Networks*, 7(1):142–146, 1996.pubmed.ncbi.nlm.nih.gov/18255564
  13. [15][Sha48] Claude E. Shannon. A Mathematical Theory of Communication. *The Bell System Technical Journal*, 27(3):379–423, 1948.
  14. [16][Sha51] C. E. Shannon. Prediction and entropy of printed English. *The Bell System Technical Journal*, 30(1):50–64, 1951.
  15. [17][SLM18] Ionut Schiopu, Yu Liu, and Adrian Munteanu. CNN-based Prediction for Lossless Coding of Photographic Images. In *2018 Picture Coding Symposium (PCS)*, pages 16–20, 2018.DOI
  16. [18][Tsa26] Chen-Han Tsai. Revisiting Data Compression with Language Modeling. *arXiv preprint*, 01 2026.arxiv.org/abs/2601.02875
  17. [19][Tur50] A. M. Turing. Computing Machinery and Intelligence. *Mind*, LIX(236):433–460, 10 1950.
  18. [20][TVZ05] Luca Trevisan, Salil Vadhan, and David Zuckerman. Compression of Samplable Sources. *14*(3):186–227, 2005.
  19. [21][VZ12] Salil Vadhan and Colin Jia Zheng. Characterizing pseudoentropy and simplifying pseudorandom generator constructions. In *Proceedings of the Forty-Fourth Annual ACM Symposium on Theory of Computing*, STOC ’12, page 817–836, New York, NY, USA, 2012. Association for Computing Machinery.
  20. [22][Yao82] Andrew C. Yao. Theory and Application of Trapdoor Functions. In *23rd Annual Symposium on Foundations of Computer Science (FOCS 1982)*, pages 80–91, 1982.
  21. [23][ZZH+26] Yeqin Zhang, Yizheng Zhao, Chen Hu, Binxing Jiao, Daxin Jiang, Ruihang Miao, and Cam Tu Nguyen. Learning to Compress: Unlocking the Potential of Large Language Models for Text Representation. In *Proceedings of the Fortieth Annual AAAI Conference on Artificial Intelligence*, 2026.

AI tools statement

This work lists 1 AI tool.

  • generative AI tools · AI tool

    Roles
    Formal AnalysisWriting — original draftWriting — review & editing
    Verification
    self-declared at submission

Recorded on the work at submission, not per version. Names and roles are shown as submitted; roles use the CRediT taxonomy.

How AI tools are recorded

Paper details

Cite this paper

Publication

Published
Version
Latest

Data & code

No code, data or supplementary files were declared for this version.

Pick where to look, or just type