Text Compression for Efficient Language Generation

David Gu, Peter Belcak, Roger Wattenhofer

Abstract

Large Language Models (LLMs) face significant computational challenges due to the token-by-token processing nature of standard Transformer architectures. This paper introduces the Generative Pretrained Thought Former (GPTHF), a hierarchical model that compresses entire sentences into fixed-size embeddings ("sentence thoughts"). By utilizing block-wise attention and a sentence-level transformer body, GPTHF enables a "Fast Generation" algorithm that caches completed sentence embeddings and bypasses the encoder for finished text. Experimental results on a 10-billion-token corpus demonstrate up to a 10x reduction in FLOPs and a 3x runtime speedup with manageable perplexity trade-offs.

Introduction

The current era of Large Language Models (LLMs) is defined by scaling—moving from millions to trillions of parameters. However, this growth comes with massive costs in hardware, energy, and latency. While techniques like pruning and quantization help, most models still rely on sub-word tokens as their fundamental unit. Each sub-word token requires its own embedding and attention calculation. This research asks whether we truly need to process every single sub-word token at every layer, proposing that compressing text into higher-level semantic units—sentences—could unlock a new level of efficiency.

The GPTHF Architecture

The authors introduce GPTHF, a hierarchical architecture consisting of two primary components:

  1. wlt_encoder (Word-Level Transformer): This component processes raw tokens using "block attention masks" to ensure tokens only attend to others within the same sentence. It compresses the entire sentence into a single embedding.
  2. slt_body (Sentence-Level Transformer): This component takes the sequence of sentence embeddings, contextualizes them, and predicts the next token.
The GPTHF architecture compresses token sequences into sentence embeddings ($e_i$) before processing them through a sentence-level transformer body.

Efficient Inference via Sentence Caching

The primary innovation of GPTHF is its "Fast Generation" algorithm. Because the model uses block-wise attention, once a sentence is completed, its embedding ($e_i$) becomes fixed. The feed-forward layers operate element-wise, meaning nothing in the network's later stages changes that compressed representation. GPTHF caches these embeddings in an s_embedding_cache, allowing the heavy encoder to be completely bypassed for all previous sentences in the prompt. Only the current, active sentence needs to be processed by the encoder.

The Fast Generation algorithm caches completed sentence embeddings, allowing the model to bypass the encoder for finished text and significantly reduce computational overhead.

Experimental Setup

The models were pre-trained on a 10-billion-token corpus consisting of OpenWebText, Wikipedia, and ArXiv. Evaluation was performed on a hold-out validation set of 16 million tokens, comparing GPTHF against standard GPT-style baselines (Baseline-12 and Baseline-24).

Key Results and Insights

  • Computational Efficiency: GPTHF achieved up to a 10x reduction in FLOPs for long prompts (500 tokens) and a 3x runtime speedup in unbatched settings.
  • The Perplexity Trade-off: There is a "compression tax." Switching from a standard GPT to GPTHF increases perplexity by about 5 points. However, a 24-layer GPTHF performs roughly on par with a 12-layer standard GPT while being significantly faster and more efficient.
  • Sentences as Semantic Payloads: The paper demonstrates that a single fixed-size embedding can carry enough "semantic payload" to maintain reasonable generation quality, challenging the necessity of token-by-token processing in deep layers.
  • Linear Efficiency Gains: Efficiency improves linearly with the number of sentences in the context. The more "finished" sentences in a prompt, the more of the network can be skipped.

Limitations and Future Work

The authors identify several hurdles, including difficulties in correctly generating "end-of-sentence" tokens in low-compute regimes, leading to repetitive loops. Furthermore, the experiments were limited to models up to 454M parameters; scaling to 7B+ parameters remains an open question. Future work will also explore integration with KV-caching and evaluation on downstream tasks like summarization to ensure fine-grained details are preserved during compression.

Summary updated

BibTeX
@inproceedings{gu2025text,
  author = {David Gu and Peter Belcak and Roger Wattenhofer},
  title = {{Text Compression for Efficient Language Generation}},
  booktitle = {Student Research Workshop @ NAACL},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-srw.18},
}
Figure