How Far Back Should a Transformer Look? Repetition and Copying in Music Sequence Models
Organizations: Department of Computing Science University of Alberta Edmonton, AB, Canada
Abstract
We investigate how predictive performance depends on the maximum context available to an autoregressive model of symbolic music, and what information long-context models exploit. A small causal Transformer is trained separately at each context length T in {6, 18, 48, 96, 192, 336} and evaluated on the same target positions, both over raw tokens and over non-overlapping binary latent codes. On Nottingham folk tunes, the token predictor's test NLL decreases by 71% (0.986 bits per token) between 6 and 336 tokens, and by 71% on the O'Neill's tunes long enough for the same sweep (129 of 302 test tunes). Most of the long-context gain is explained by exact copying: the improvement appears when an earlier occurrence of the target's 16-token history enters the available context; overwriting that occurrence removes the gain, whereas equally large unrelated corruption does not; and a simple copy baseline recovers 94% of the reduction. A trained 336-token model likewise loses most of this gain when its history is restricted to recent tokens at test time. Because many repeats arise from written repeat signs expanded in the score, this result pertains specifically to these rendered score representations. By contrast, on MAESTRO performances and MusicNet scores, where exact repeats are substantially less frequent, the reduction is smaller (9% and 18%) and is largely attained by 96 tokens. Finally, an audit of an earlier draft that reported saturation at 16 tokens identified split leakage, overlapping latent receptive fields, an averaging predictor, and a per-file tempo grid; we present these as methodological checks for context-length measurements.
Figures & tables
| Pieces | Tokens | Windows | Test blocks | |||||
|---|---|---|---|---|---|---|---|---|
| Train | Val | Test | Train | Val | Test | train / val / test | in train | |
| Nottingham | 729 | 150 | 154 | 382K | 90K | 84K | 2789 / 809 / 660 | 0.0% |
| O’Neill’s | 1397 | 295 | 302 | 738K | 115K | 158K | 7121 / 687 / 1505 | 0.6% |
| MusicNet | 221 | 54 | 48 | 577K | 141K | 116K | 1091 / 267 / 218 | 0.0% |
| MAESTRO | 962 | 137 | 177 | 4586K | 560K | 575K | 9072 / 1094 / 1113 | 0.2% |
| Nottingham | O’Neill’s | MusicNet | MAESTRO | ||||
| Context | Latent | Token | Latent | Token | Token | Latent | Token |
| (tokens) | (bits per bit) | (bits per token) | (bits per bit) | (bits per token) | (bits per token) | (bits per bit) | (bits per token) |
| 0 | 0.958 | 4.366 | 0.931 | 4.383 | 5.295 | 0.978 | 5.319 |
| 6 | 0.857 0.002 | 1.391 0.015 | 0.845 0.005 | 1.692 0.014 | 2.512 0.066 | 0.887 0.0004 | 3.283 0.002 |
| 18 | 0.842 0.002 | 1.440 0.021 | 0.818 0.003 | 1.543 0.019 | 2.366 0.003 | 0.881 0.00003 | 3.177 0.002 |
| 48 | 0.834 0.005 | 1.529 0.090 | 0.771 0.005 | 1.449 0.017 | 2.159 0.004 | 0.879 0.0004 | 3.097 0.006 |
| Repeat lag (tokens back) | ||||||
|---|---|---|---|---|---|---|
| Share of targets | 1-32 | 33-80 | 81-176 | 177-320 | None | Held |
| in view from context | 48 | 96 | 192 | 336 | ||
| Nottingham, target tokens | 1.8% | 14.7% | 36.6% | 17.9% | 28.3% | 0.7% |
| Nottingham, target latent steps | 1.9% | 15.4% | 36.4% | 17.7% | 27.5% | 1.2% |
| O’Neill’s, target tokens | 0.3% | 9.6% | 33.3% | 30.1% | 26.7% | 0.0% |
| O’Neill’s, target latent steps | 0.4% | 11.1% | 33.8% | 29.1% | 25.6% | 0.0% |
| Corpus, predictor, context | Targets | Clean | Erased | Control | Swapped token |
|---|---|---|---|---|---|
| Nottingham, token, 192 | 16,693 | 0.22 0.005 | 1.10 0.02 | 0.22 0.004 | 0.5% 55% |
| Nottingham, token, 336 | 22,454 | 0.19 0.003 | 1.06 0.03 | 0.19 0.003 | 0.3% 62% |
| Nottingham, latent, 192 | 2,783 | 0.37 0.03 | 0.87 0.01 | 0.38 0.03 | n/a |
| Nottingham, latent, 336 | 3,747 | 0.35 0.01 | 0.81 0.004 | 0.35 0.01 | n/a |
| O’Neill’s, token, 192 | 31,068 | 0.37 0.003 | 1.28 0.01 | 0.38 0.002 | 0.8% 51% |
| O’Neill’s, token, 336 | 52,864 | 0.22 0.01 | 1.24 0.03 | 0.22 0.01 | 0.4% 71% |
| Setup | 6 | 96 | 192 | 336 |
|---|---|---|---|---|
| Legacy grid, 480-token windows, , latent | 0.80 0.0002 | 0.80 0.0005 | 0.78 0.001 | 0.72 0.01 |
| Legacy grid, 480-token windows, , token | 1.22 0.001 | 1.20 0.004 | 1.04 0.01 | 0.84 0.02 |
| Score grid, 384-token windows, , latent | 0.91 0.001 | 0.91 0.003 | 0.77 0.004 | 0.63 0.01 |
| Score grid, 384-token windows, , token | 1.39 0.004 | 1.09 0.02 | 1.15 0.02 | 0.81 0.25 |
| Score grid, as above, with transposition, latent | 0.86 0.002 | 0.78 0.004 | 0.57 0.01 | 0.47 0.01 |
| Score grid, as above, with transposition, token | 1.39 0.01 | 1.27 0.33 | 0.57 0.01 | 0.41 0.01 |
| Nottingham | MAESTRO | |||
|---|---|---|---|---|
| Context | Causal | v5 | Causal | v5 |
| 6 | 0.857 0.002 | 0.856 0.0001 | 0.887 0.0004 | 0.887 0.0004 |
| 18 | 0.842 0.002 | 0.852 0.001 | 0.881 0.00003 | 0.881 0.0002 |
| 48 | 0.834 0.005 | 0.843 0.004 | 0.879 0.0004 | 0.879 0.0004 |
| 96 | 0.775 0.004 | 0.891 0.001 | 0.877 0.0004 | 0.879 0.0003 |
| 192 | 0.571 0.015 | 0.886 0.001 | 0.877 0.00010 | 0.878 0.0003 |
| Tuned temperature | ||||
|---|---|---|---|---|
| System | Distance | Repetition | Distance | |
| Real test tunes, 100 per set (5th to 95th pct.) | n/a | 0.03 to 0.17 | 0.48 to 0.52 | n/a |
| AE round trip, all test streams | n/a | 0.07 | 0.49 | n/a |
| Latent, 6 tokens | 0.2, 0.3 | 1.21 0.19 | 0.01 0.02 | 5.97 0.03 |
| Latent, 18 tokens | 0.3, 0.4 | 1.19 0.19 | 0.00 0.002 | 5.51 0.15 |
| Latent, 48 tokens | 0.3, 0.4 | 1.13 0.16 | 0.01 0.002 | 5.33 0.15 |
| Token predictor | Latent predictor | ||||||
|---|---|---|---|---|---|---|---|
| Parameters | Parameters | ||||||
| 6 | 3 | 4 | 2,471,952 | 1 | 1 | 1 | 2,481,088 |
| 18 | 9 | 10 | 2,473,104 | 3 | 2 | 2 | 2,481,280 |
| 48 | 18 | 31 | 2,475,984 | 8 | 3 | 6 | 2,481,760 |
| 96 | 18 | 79 | 2,480,592 | 16 | 3 | 14 | 2,482,528 |
| 192 | 18 | 175 | 2,489,808 | 32 | 3 | 30 | 2,484,064 |
| History matched (tokens) | |||
|---|---|---|---|
| Corpus | 32 | 16 | 8 |
| Nottingham | 0.965 | 0.869 | 0.625 |
| O’Neill’s | 0.969 | 0.890 | 0.733 |
| MusicNet | 0.902 | 0.866 | 0.760 |
| MAESTRO | 0.553 | 0.586 | 0.510 |
Long-Context Modeling
Long-context modeling studies how AI systems process, retrieve, and reason over sequences that exceed ordinary context windows.
See all 133 papers