Copy-Paste Language Models
Organizations: Cornell University New York City, USA
Abstract
Transformers are intuitively considered to be efficient at copying from their inputs. We actually show that the ability of LLMs to copy in context can be improved through explicit modeling. We propose Copy-Paste Language Models (CPLMs), which add a lightweight Copy-Paste head to the conventional language modeling (LM) head. CPLMs improve training efficiency, downstream performance, and offer new operating points in long-context and retrieval setups. We validate our approach by pretraining models from 135M to 1.7B parameters, showing improvements across all scales and backbones with negligible training and inference overheads. We explain the success of CPLMs by showing that they partially mitigate the LM head gradient bottleneck through an alternative gradient path.
Figures & tables
| Model | Type | HellaSwag | LAMBADA | PIQA | SciQ | ARC-e | ARC-c | WinoGrande | Avg. |
|---|---|---|---|---|---|---|---|---|---|
| Full | Vanilla | 61.12 | 44.46 | 75.24 | 88.20 | 68.39 | 40.96 | 58.80 | 62.45 |
| CPLM | 61.70 | 46.92 | 74.86 | 89.20 | 68.10 | 41.21 | 59.43 | 63.06 | |
| SW | Vanilla | 61.00 | 42.46 | 74.48 | 87.00 | 67.17 | 41.30 | 58.01 | 61.63 |
| CPLM | 61.78 | 46.42 | 74.70 | 87.30 | 67.59 | 41.13 | 58.41 | 62.48 | |
| Hybrid | Vanilla | 61.08 | 43.70 | 74.48 | 87.80 | 69.32 | 40.96 | 58.17 | 62.22 |
| CPLM | 61.70 | 46.92 | 74.48 | 87.40 | 66.46 | 41.55 | 59.59 | 62.59 |
| PPL ( ) | Math | Coding | Instruction | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Attention | Model | Tulu-3 | Nemotron-3 | MATH | GSM8K | HumanEval | MBPP | IFEval | Avg | ||||
| Full | Vanilla | 2.52 | 4.08 | 13.9 | 28.9 | 20.4 | 16.9 | 41.2 | 24.2 | ||||
| CPLM | 2.47 | 3.78 | 17.5 | 33.1 | 21.1 | 17.5 | 43.0 | 26.4 | |||||
| Hybrid 3:1 | Vanilla | 2.52 | 4.10 | 16.5 | 27.9 | 19.8 | 19.0 | 38.3 | 24.3 | ||||
| CPLM | 2.48 | 3.80 | 17.4 | 30.4 | 22.1 | 17.4 | 40.1 | 25.5 | |||||
| SW-256 | Vanilla | 2.79 | 5.65 | 7.2 | 18.6 | 15.4 | 16.1 | 37.2 | 18.9 | ||||
| Synthetic (0–16k) | LongBench (16k) | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Attention | Model | BABILong | RULER | Single-Doc | Multi-Doc | Summ. | Few-shot | Synth. | Code | Avg | ||
| Full | Vanilla | 26.4 | 33.6 | 5.7 | 6.1 | 11.8 | 20.7 | 1.7 | 15.4 | 10.4 | ||
| CPLM | 32.0 | 39.6 | 6.8 | 6.7 | 10.2 | 28.3 | 0.8 | 18.6 | 12.2 | |||
| Hybrid 3:1 | Vanilla | 27.7 | 33.2 | 4.6 | 5.3 | 8.4 | 20.5 | 0.7 | 17.4 | 9.5 | ||
| CPLM | 32.9 | 37.8 | 5.4 | 3.3 | 14.0 | 35.1 | 1.7 | 25.6 | 14.3 | |||
| SW-256 | Vanilla | 13.8 | 7.9 | 3.0 | 2.9 | 6.4 | 16.6 | 1.4 | 14.8 | 7.4 | ||
Appendix figures & tables22 assets
Supplementary material from the paper’s appendix.
Appendix
| 135M | 360M | 1.7B | |
| Architecture | |||
| Layers | 30 | 32 | 24 |
| Hidden size | 576 | 960 | 2,048 |
| FFN size | 1,536 | 2,560 | 8,192 |
| Attention heads | 9 | 15 | 32 |
| KV heads (GQA) | 3 | 5 | 32 |
| Throughput (tokens/s) | Peak memory (GB) | |||||
|---|---|---|---|---|---|---|
| Model | Vanilla | CPLM | Ratio | Vanilla | CPLM | Ratio |
| 1.7B | 55,862 | 54,113 | 0.969 | 125.4 | 137.5 | 1.096 |
| 9B | 20,429 | 20,533 | 1.005 | 114.0 | 117.0 | 1.026 |
| 30B | 5,391 | 5,342 | 0.991 | 139.9 | 142.3 | 1.017 |
| Time | Memory (GB) | ||||||
|---|---|---|---|---|---|---|---|
| Model | Prefill | Decoding step | Request | KV cache | Copy cache | ||
| 1.7B | 4k | 1 | 0.993 | 1.018 | 1.017 | 0.80 | 0.02 |
| 4k | 128 | 0.999 | 1.017 | 1.010 | 102.1 | 2.13 | |
| 16k | 32 | 0.996 | 1.018 | 1.008 | 97.5 | 2.03 | |
| 9B | 4k | 1 | 0.987 | 1.010 | 1.008 | 0.53 | 0.03 |
| 4k | 128 | 1.000 | 1.038 | 1.014 | 68.1 | 4.25 | |
| Backbone | Vanilla | CPLM | ||
|---|---|---|---|---|
| Full | ||||
| SW | ||||
| Hybrid 3:1 |
| Validation | FinePDFs @2k | ||||
| Method | Output mechanism | Full | SW-256 | Full | SW-256 |
| Vanilla | LM softmax | 16.34 | 16.88 | 14.25 | 16.52 |
| Chang et al. (2023) | |||||
| C | Context partition | 16.25 | 16.71 | 13.88 | 15.66 |
| P | Pointer partition | 16.19 | 16.54 | 13.81 | 14.96 |
| CP | Context + pointer | 16.19 | 16.53 | 13.64 | 14.91 |
| Attention | Vanilla | Vanilla + Neural cache | CPLM |
|---|---|---|---|
| Full | 9.17 | 9.17 | 9.06 |
| Hybrid 3:1 | 9.20 | 9.20 | 9.06 |
| SW-256 | 9.65 | 9.63 | 9.24 |
| RULER | BABILong | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Attention | Model | 4k | 8k | 16k | 32k | 64k | Avg | 0k | 1k | 2k | 4k | 8k | 16k | 32k | 64k | Avg |
| Full | Vanilla | 50.1 | 36.3 | 14.5 | 0.0 | 0.0 | 20.2 | 55.0 | 44.6 | 35.0 | 18.6 | 4.4 | 0.6 | 0.0 | 0.0 | 19.8 |
| CPLM | 54.9 | 38.6 | 25.2 | 0.0 | 0.0 | 23.7 | 52.6 | 49.6 | 40.8 | 32.6 | 12.6 | 4.0 | 0.0 | 0.0 | 24.0 | |
| Hybrid 3:1 | Vanilla | 50.6 | 32.1 | 16.9 | 7.1 | 3.6 | 22.1 | 56.4 | 38.8 | 29.0 | 26.8 | 11.4 | 3.6 | 0.6 | 0.2 | 20.8 |
| CPLM | 53.5 | 40.8 | 19.2 | 11.7 | 2.8 | 25.6 | 57.6 | 47.4 | 42.8 | 27.4 | 16.2 | 5.8 | 1.4 | 0.2 | 24.8 | |
| SW-256 | Vanilla | 10.2 | 7.5 | 5.9 | 5.5 | 5.0 | 6.8 | 46.2 | 18.2 | 10.2 | 5.2 | 1.8 | 1.0 | 0.4 | 0.6 | 10.5 |
| Retrieval (NIAH) | Tracing | Aggregation | QA | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Attention | Model | S1 | S2 | S3 | MK1 | MK2 | MK3 | MQ | MV | VT | CWE | FWE | SQuAD | HotpotQA | Avg |
| Full | Vanilla | 99.0 | 100.0 | 68.0 | 62.0 | 6.0 | 9.0 | 83.0 | 64.8 | 0.0 | 34.7 | 53.3 | 43.0 | 28.0 | 50.1 |
| CPLM | 100.0 | 100.0 | 85.0 | 67.0 | 4.0 | 8.0 | 80.8 | 72.2 | 26.6 | 60.8 | 40.3 | 39.0 | 30.0 | 54.9 | |
| Hybrid 3:1 | Vanilla | 100.0 | 97.0 | 62.0 | 62.0 | 6.0 | 5.0 | 82.8 | 73.2 | 9.0 | 51.6 | 42.3 | 38.4 | 29.0 | 50.6 |
| CPLM | 99.0 | 100.0 | 70.0 | 90.0 | 8.0 | 8.0 | 82.5 | 79.0 | 7.0 | 38.9 | 38.0 | 42.3 | 33.0 | 53.5 | |
| SW-256 | Vanilla | 8.0 | 9.0 | 3.0 | 8.0 | 3.0 | 1.0 | 5.2 | 3.2 | 0.4 | 16.0 | 26.0 | 31.3 | 19.0 | 10.2 |
| Attention | Model | qa1 | qa2 | qa3 | qa4 | qa5 | Avg |
|---|---|---|---|---|---|---|---|
| Full | Vanilla | 19.0 | 9.0 | 17.0 | 33.0 | 15.0 | 18.6 |
| CPLM | 31.0 | 21.0 | 34.0 | 34.0 | 43.0 | 32.6 | |
| Hybrid 3:1 | Vanilla | 20.0 | 12.0 | 23.0 | 43.0 | 36.0 | 26.8 |
| CPLM | 30.0 | 6.0 | 29.0 | 30.0 | 42.0 | 27.4 | |
| SW-256 | Vanilla | 4.0 | 0.0 | 5.0 | 5.0 | 12.0 | 5.2 |
| CPLM | 6.0 | 2.0 | 10.0 | 6.0 | 18.0 | 8.4 |
| Val. NLL | PPL | NLL vs. Vanilla | |||
|---|---|---|---|---|---|
| Vanilla | 2.794 | 16.34 | — | — | — |
| CPLM | 2.763 | 15.85 | 0.210 | 0.567 | |
| CPLM, stop-gradient | 2.786 | 16.22 | 0.046 | 0.224 |
| Val. NLL (nats/byte) | Bits/byte | |||
|---|---|---|---|---|
| Vanilla | 0.6908 | 0.997 | — | — |
| CPLM | 0.6918 | 0.998 | 0.339 | 0.683 |
| CPLM, no sink | 0.6924 | 0.999 | 0.176 | — |
Language Model Pretraining
Language model pretraining teaches models language patterns and knowledge from large text corpora before they are adapted to specific tasks.
See all 422 papers