Manuscript Offprint

arXiv:2610.02837

How Far Back Should a Transformer Look? Repetition and Copying in Music Sequence Models

Amir Fathi

Amir Fathi

Department of Computing Science

University of Alberta

Edmonton, AB, Canada

fathi5@ualberta.ca

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∈{6,18,48,96,192,336}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.

Index Terms—Symbolic music, autoregressive models, context length, repetition, copying, evaluation methodology

I. INTRODUCTION

Autoregressive models of symbolic music commonly attend over the full available history of a piece [1]-[3], while full self-attention incurs O(n2)O(n^{2}) cost in sequence length n. Restricting the model to a local context can therefore substantially reduce computation, and some systems are motivated by the premise that recent history contains most of the information relevant to next-event prediction [4]. This raises two empirical questions: how does predictive performance vary with the amount of available history, and which properties of the musical representation determine whether longer context is useful?

We address these questions with a controlled sweep over maximum context length. A predictor is trained and evaluated with exactly the preceding T tokens, for T from 6 to 336, and all context lengths are scored on the same target positions. The intended experimental factor is therefore the maximum accessible history, although the attention bands and relative-position parameters necessarily grow with T. Because a separate model is trained at each T, the sweep measures the performance attainable under a fixed training protocol at each maximum context length; by itself, it does not establish how much context any single trained model actually uses. We therefore add two interventions on trained long-context models: targeted context editing and test-time restriction of the available history. We conduct the sweep for two predictors, one over raw tokens and one over binary autoencoder codes whose latent steps each represent a disjoint span of 6 tokens. The latter reproduces the two-stage setting of our earlier draft, in which prediction operates on a latent sequence 6 times shorter than the token sequence. Both predictors use the same base causal-Transformer architecture and are trained on source-disjoint splits that keep each tune or performance entirely within one split.

Our contributions are the following.

  1. A controlled sweep of available context. On the two folk corpora, Nottingham and O'Neill's, the token predictor's test NLL decreases by 71% and 71% from 6 to 336 tokens (0.986 and 1.195 bits per token), with most of the improvement occurring beyond 48 tokens. On MAESTRO and MusicNet, the reductions are smaller (9% and 18%, corresponding to 0.296 and 0.445 bits), and most of the improvement within the tested range is attained by 96 tokens (Sections VI-A, VI-E and VI-F). We do not evaluate contexts longer than 336 tokens.

  2. Evidence that the long-context gain on the folk corpora is primarily exact copying of repeated passages. Targets whose 16-token histories recur within the available context account for most of the NLL reduction. Performance improves on such targets only after the earlier occurrence enters the model's receptive field; selectively overwriting the earlier occurrence removes the gain; a simple copy baseline recovers most of the reduction; and a trained 336-token model loses the gain when its history is restricted at test time. The same pattern occurs on Nottingham and O'Neill's (Sections VI-B, VI-C, VI-D and VI-E). Because repeat signs are expanded into note-for-note repeated passages in both folk corpora, and the representation retains only the top line on a fixed grid, exact repetition reflects both musical structure and representation. Our claim is therefore specific to these rendered score representations.

  3. An audit of an earlier context-saturation result. An earlier draft reported the opposite qualitative conclusion, namely saturation at 16 tokens. We identify the methodological failures associated with that curve and formulate them as checks for future measurements of effective context length (Section VII).

Additional analyses show that the Nottingham token predictor acquires the copying solution abruptly and seed-dependently at 96 tokens (Section VI-G); that the averaging predictor used in the earlier draft fails to exploit long context (Section VI-H); and, as a secondary diagnostic, that long-context models generate passages that recur within a stream, although no generated set matches held-out music under our distance (Section VI-J).

References (42)