Copy Is All You Need

Tian Lan, Deng Cai, Yan Wang, Heyan Huang, Xian-Ling Mao · DOI

Abstract

Modern Large Language Models (LLMs) typically generate text by predicting the next token from a fixed, static vocabulary. This paradigm faces significant challenges regarding knowledge updates, contextual nuance, and computational efficiency. We present the Copy-Generator (CoG), a framework that redefines text generation as a retrieval and assembly task. By "copy-pasting" variable-length phrases from a massive text corpus, CoG achieves state-of-the-art generation quality, enables zero-shot domain adaptation without retraining, and maintains high inference speeds through multi-token generation steps.

Introduction

The standard autoregressive generation process—predicting one sub-word token at a time—has become the cornerstone of natural language processing. However, this approach is inherently limited by three factors: static knowledge, context blindness, and efficiency bottlenecks. Models are often "frozen" in time, requiring expensive fine-tuning to incorporate new information. Furthermore, fixed vocabularies often strip tokens of the rich, document-specific context they originally possessed. Finally, the sequential nature of decoding creates a computational bottleneck for long-form generation.

CoG proposes a fundamental shift: treating an entire text corpus (such as Wikipedia) as the model's vocabulary. Instead of calculating probabilities over a small set of sub-words, the model retrieves and assembles existing phrases to construct coherent text.

Methodology

The CoG model architecture consists of several key components designed to facilitate efficient phrase-level retrieval:

The Phrase Table

CoG pre-computes vector representations for every possible phrase (up to a specified length) within a source collection. Using a BERT-based Phrase Encoder, the model creates context-aware embeddings by concatenating the representations of the start and end tokens of a phrase. This ensures that the same phrase (e.g., "Apple") has distinct vectors depending on whether it appears in a technical or botanical context.

Prefix Encoding and Retrieval

As the model generates text, a GPT-2-based Prefix Encoder represents the current generated string as a query vector. At each step, the model performs a Maximum Inner Product Search (MIPS) to find the phrase in the collection whose vector most closely matches the current prefix. The model then "pastes" that phrase onto the output.

Hybrid Vocabulary and Training

To ensure the model can handle punctuation or rare connectors not present in the source corpus, CoG retains a standard token-level vocabulary as a fallback. The system is trained using an InfoNCE loss, which encourages the selection of phrases that are semantically and syntactically coherent with the preceding context.

Experimental Evaluation

The researchers evaluated CoG across three primary settings: WikiText-103 (standard language modeling), Law-MT (domain adaptation), and En-Wiki (scaling analysis using 3 billion words).

Generation Quality and Human Preference

On the WikiText-103 benchmark, CoG achieved a MAUVE score of 26.14, significantly outperforming the standard Transformer (23.43) and other retrieval-augmented models like $k$NN-LM. In side-by-side human evaluations, CoG’s generations were preferred 48% of the time, compared to only 28% for the standard Transformer.

Zero-Shot Domain Adaptation

One of the most significant advantages of CoG is its ability to adapt to new domains without gradient updates. By simply swapping the source text collection from Wikipedia to a legal corpus, CoG outperformed a Transformer that had been specifically fine-tuned on legal data (28.14 vs 26.85 MAUVE).

Inference Efficiency

While vector search over billions of phrases introduces overhead, CoG compensates by generating multiple tokens in a single step. The model achieved a latency of 1.29s per generation, proving slightly faster than the standard Transformer (1.32s).

Discussion and Limitations

Despite its performance, CoG faces several challenges:

  • Stitching Errors: The model occasionally creates "incoherent joins" where two retrieved phrases do not align perfectly in a grammatical sense.
  • Copyright and Ethics: Verbatim copying of text raises concerns regarding intellectual property and the potential leakage of private information contained in the source corpus.
  • Index Management: The phrase index can grow to billions of entries, requiring significant memory and optimized engineering for large-scale deployment.

Conclusion

CoG demonstrates that phrase retrieval is a viable and often superior alternative to token prediction. By leveraging existing text as a dynamic vocabulary, the model provides a path toward more flexible, efficient, and contextually rich language generation.

Summary updated

BibTeX
@inproceedings{lan2023copy,
  author = {Tian Lan and Deng Cai and Yan Wang and Heyan Huang and Xian-Ling Mao},
  title = {{Copy Is All You Need}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=CROlOA9Nd8C},
}
Figure