Skip to main content
QUICK REVIEW

[Paper Review] LLMZip: Lossless Text Compression using Large Language Models

Chandra Shekhara Kaushik Valmeekam, Krishna R. Narayanan|arXiv (Cornell University)|Jun 6, 2023
Algorithms and Data CompressionComputer Science4 citations
TL;DR

This paper proposes LLMZip, a lossless text compression method that leverages the LLaMA-7B language model as a predictive compressor, using its next-token probability estimates to guide arithmetic coding. The approach achieves a record-low asymptotic entropy upper bound of 0.709 bits/character on the text8 dataset and a compression ratio of 0.7101 bits/character, outperforming state-of-the-art tools like BSC, ZPAQ, and paq8h.

ABSTRACT

We provide new estimates of an asymptotic upper bound on the entropy of English using the large language model LLaMA-7B as a predictor for the next token given a window of past tokens. This estimate is significantly smaller than currently available estimates in \cite{cover1978convergent}, \cite{lutati2023focus}. A natural byproduct is an algorithm for lossless compression of English text which combines the prediction from the large language model with a lossless compression scheme. Preliminary results from limited experiments suggest that our scheme outperforms state-of-the-art text compression schemes such as BSC, ZPAQ, and paq8h.

Motivation & Objective

  • To estimate the asymptotic entropy upper bound of English text using LLaMA-7B as a predictive model.
  • To develop a lossless compression scheme that combines LLaMA-7B's next-token predictions with arithmetic coding.
  • To evaluate the compression performance of the LLaMA-7B-based system against state-of-the-art compressors like BSC, ZPAQ, and paq8h.
  • To demonstrate that large language models can significantly improve lossless text compression by reducing entropy estimates and achieving better compression ratios.

Proposed method

  • The LLaMA-7B model is used as a context-aware predictor to estimate the probability distribution over the next token given a sliding window of past tokens.
  • For each token, the model generates a ranked list of candidate tokens with their probabilities, and the rank of the actual next token is recorded.
  • The rank information is then encoded using arithmetic coding, which efficiently compresses the sequence of ranks based on their predicted probabilities.
  • The compression ratio is computed as the total bits used divided by the number of characters in the original text.
  • The entropy upper bound is estimated as the average cross-entropy of the predicted distributions over the test set.
  • The method is evaluated on two datasets: a 1MB segment of the text8 dataset and a 100KB excerpt from a Project Gutenberg book.

Experimental results

Research questions

  • RQ1What is the asymptotic upper bound on the entropy of English text when predicted using the LLaMA-7B language model?
  • RQ2Can a large language model be effectively used to improve lossless text compression beyond existing state-of-the-art methods?
  • RQ3How does the compression ratio of an LLM-based compressor compare to traditional compressors like BSC, ZPAQ, and paq8h on standard benchmarks?
  • RQ4Does the compression performance of LLMZip improve with increasing context window size (memory M)?
  • RQ5How does the entropy estimate and compression ratio vary across different text sources, such as the text8 dataset and a published book?

Key findings

  • The LLaMA-7B-based compressor achieved a compression ratio of 0.7101 bits/character on a 1MB section of the text8 dataset, significantly outperforming BSC, ZPAQ, and paq8h.
  • The asymptotic upper bound on the entropy of English text was estimated at 0.709 bits/character using LLaMA-7B, which is lower than previous estimates in the literature.
  • On a 100KB excerpt from a Project Gutenberg book, the compression ratio was 0.8426 bits/character, with an entropy upper bound of 0.8417 bits/character.
  • The compression ratio improved with increasing context window size (M), with the best performance observed at M=511.
  • The LLaMA-7B-based system achieved a compression ratio of 0.7101 bpc, which is very close to the estimated entropy upper bound of 0.7093 bpc, indicating near-optimal compression efficiency.
  • The performance of the LLaMA-based compressor significantly surpassed that of the zlib algorithm, which achieved 2.80 bpc on the same text, highlighting the advantage of using an LLM for prediction.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.