Tiny Transformers Excel at Sentence Compression

Peter Belcak, Roger WattenhoferarXiv 2024 · DOI

Introduction

Modern Large Language Models (LLMs) represent sub-word tokens using high-dimensional embeddings. For instance, in models like GPT-3, a single token vector occupies approximately 24 kilobytes of memory, while the semantic information it carries—often just a few characters—is significantly smaller. This discrepancy suggests a massive "scaling factor" of roughly 4500, indicating that current architectures may be computationally inefficient by processing very sparse information. Researchers from ETH Zurich investigated whether this inefficiency could be mitigated by "zipping" entire sentences into single vector representations.

Methodology: The Transformer Autoencoder

The study utilizes a Transformer Autoencoder architecture based on BERT to explore sentence-level compression. The process is divided into two primary stages:

  1. Encoder: A compact transformer (consisting of 1, 2, or 3 layers) processes a full sentence to generate a sequence of hidden states. A critical bottleneck is introduced: only the embedding of the leading token ([CLS]) is extracted to represent the entire sentence.
  2. Decoder: A corresponding small transformer attempts to reconstruct the original sequence of words from this single "sentence-token."
The Transformer Autoencoder architecture showing the bottleneck where only the first token embedding is passed to the decoder.

The researchers tested various embedding dimensions ($d \in \{768, 1024, 2048\}$) and a multiplier ($m$) that dictates how many times the compressed embedding is repeated for the decoder's input. The models were trained on a massive 96-million sentence subset of English Wikipedia and BookCorpusOpen, focusing on sentences under 512 characters.

Experimental Results

The experiments demonstrated that even extremely shallow transformers can achieve remarkable reconstruction fidelity. The primary driver of performance was model depth rather than embedding width.

Reconstruction accuracy (mean and weighted) across different configurations of layers (l), multipliers (m), and dimensions (d).

As shown in the results, increasing the number of layers from 1 to 2 provided the most significant boost in accuracy, jumping from approximately 76% to 94%. The best-performing 3-layer configuration reached a mean token reconstruction accuracy of 98.5%. Even when accounting for sentence length (weighted accuracy), the 3-layer models maintained performance above 95%.

Discussion and Implications

The ability of a standard 768-dimensional vector to hold enough information to reconstruct a 20-word sentence confirms that current model embeddings are vastly underutilized. This work suggests several key insights:

  • Hierarchical Efficiency: The significant gains from adding layers versus increasing dimensionality suggest that language compression relies more on hierarchical processing "logic" than raw memory capacity.
  • Sentence-Level Architectures: This proof-of-concept paves the way for future LLMs that operate on sentence-level units. By predicting "sentence-tokens" instead of individual sub-words, models could handle much longer contexts with reduced computational overhead.
  • The "Cost" of Grammar: The models' ability to maintain grammatical correctness with minimal layers implies that the fundamental rules of language are relatively "cheap" to capture. The massive scale of modern LLMs may be more necessary for factual memorization than for linguistic structure.

Limitations

While promising, this research focuses strictly on the autoencoding task. Future work is required to determine if these compressed embeddings retain the semantic nuances necessary for downstream tasks like reasoning or sentiment analysis. Additionally, the performance on non-standard or "noisy" text remains to be explored.

Summary updated

BibTeX
@misc{belcak2024tiny,
  author = {Peter Belcak and Roger Wattenhofer},
  title = {{Tiny Transformers Excel at Sentence Compression}},
  year = {2024},
  eprint = {2410.23510},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.23510},
}
Figure