Language Models "Grok" to Copy

Ang Lv, Ruobing Xie, Xingwu Sun, Zhanhui Kang, Rui Yan
9/14/2024
cs.CLcs.AIcs.LG

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

We examine the pre-training dynamics of language models, focusing on their ability to copy text from preceding context--a fundamental skill for various LLM applications, including in-context learning (ICL) and retrieval-augmented generation (RAG). We propose a novel perspective that Transformer-based language models develop copying abilities similarly to grokking, which refers to sudden generalization on test set long after the model fit to the training set. Our experiments yield three arguments: (1) The pre-training loss decreases rapidly, while the context copying ability of models initially lags and then abruptly saturates. (2) The speed of developing copying ability is independent of the number of tokens trained, similarly to how grokking speed is unaffected by dataset size as long as the data distribution is preserved. (3) Induction heads, the attention heads responsible for copying, form from shallow to deep layers during training, mirroring the development of circuits in deeper layers during grokking. We contend that the connection between grokking and context copying can provide valuable insights for more effective language model training, ultimately improving in-context performance. For example, we demonstrated that techniques that enhance grokking, such as regularization, either accelerate or enhance the development of context copying.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{lv2024language,
  title  = {Language Models "Grok" to Copy},
  author = {Ang Lv and Ruobing Xie and Xingwu Sun and Zhanhui Kang and Rui Yan},
  year   = {2024},
  eprint = {2409.09281},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.09281v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.09281.svg)](https://codeofpaper.com/paper/2409.09281)

Discussion