Manuscript Offprint
arXiv:2609.11353Copying Versus Randomization in Lempel-Ziv Music Synthesis
I. INTRODUCTION
The field of generative artificial intelligence (GenAI) is currently dominated by diffusion models, transformer-based models, and generative adversarial networks (GANs) [1]. While effective, these methods demand substantial computational resources and obscure the logic of their creation process. Universal Compression (UC) models, conversely, operate efficiently in "real-time". This computational advantage, combined with the ability of algorithms like Lempel-Ziv (LZ) [2] to learn statistical models [3] for data compression, presents a promising alternative path for GenAI. Specifically, the LZ algorithm has been explored for music generation in prior works such as Dubnov and Assayag [4] and recently by Ding et al. [5].
The fundamental principle of LZ compression is the detection and reuse of repeated sequences, which poses a significant challenge for content generation. In the musical domain, new compositions are typically inspired by existing works rather than reproduced from them. However, the standard LZ algorithm is designed to maximize compression efficiency by copying long, contiguous segments of the source data. Consequently, the resulting output often consists of verbatim excerpts from the training material, rather than exhibiting the originality and variation expected of creative composition [6].
In this work, we propose a novel method to address this limitation by introducing controls to balance the trade-off between exact copying (over-copy) and randomization (under-copy). We propose two methods of controlling average sequence length: limiting the training data per tree to decrease average sequence length, and a sequence extension technique that extends branch depth to increase average sequence length.

Fig. 1. Block Diagram of the Training -Generation Process
Ram Zamir
Department of Electrical Engineering
Tel Aviv University
Tel Aviv, Israel
https://cris.iucc.ac.il/en/persons/ram-zamir
Code implementation in Python is available at the GitHub repository [7].
A. Training Data and Preprocessing
We use Google-magenta’s MAESTRO [8] database which contains about 200 hours of annotated piano performances. Specifically, only MIDI [9] pitch data is used, ignoring velocity, and Note-On/Off events.
To accentuate repeating patterns across different compositions, which vary in octave and key, we apply a delta transform to the MIDI data. This transforms the sequence of absolute note values into a sequence of relative intervals (differences between consecutive notes). Consequently, the LZ algorithm processes the interval structure of the music rather than specific pitch frequencies.
B. Building the LZ tree
The algorithm uses the LZ78 [10] branch of the LZ family, where seen sequences are kept in a dictionary for later reference. In our work we symbolize the learned dictionary as a tree. The algorithm starts with a pointer to the root of an empty tree and in each iteration, it checks if the next symbol in the data exists in the node's children:
a) The Symbol Exists: (Seen Sequence)
It raises the frequency parameter of the child node by one and moves the pointer to the node.
b) The Symbol Doesn’t Exist: (New Sequence)
It creates a new child for the current node with the current symbol (extending the sequence) and moves the pointer back to the root.
At this stage we break from the regular LZ practice and explore a method of creating longer sequences. Instead of going back to the root after extending the sequence by one symbol (step), We propose a parameter - “steps” that sets the algorithm to go back to root after a certain number of steps taken. Thus, increasing the average sequence length.

Fig. 2. Example of LZ-Tree Building
XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE
Another way we control tree depth is by limiting the amount of data. As described by Cover and Thomas in thm. 13.5.2 [2], when a stationary ergodic process is compressed by LZ the number of phrases (sequences) in the dictionary is described by:
Where is the entropy rate of the process, is the number of phrases in a distinct parsing of a sample length n from this process.
can also be estimated by Eq. 6 [10]:
Where is a finite input symbol alphabet. Combining the equations, we create a heuristic for the average length of a sequence, :
This heuristic shows us that the average sequence length grows with n. To control this behavior, we chose a tree ensemble approach: A set of trees is created, and each tree is given a subset of the data to train on this decreasing .
C. Generation
To generate a new sequence the algorithm goes through the following steps:
I. A tree is uniformly picked from the set of trees.
II. The next symbol to output is chosen probabilistically, based on the frequency each symbol has been seen before.
III. Repeat step II until a leaf node is reached.
IV. A new tree from the set is chosen.
V. Repeat steps I-IV until the number of symbols chosen are generated.

Fig. 3. Example of the Generation Process
III. EXPERIMENTS
As mentioned in section II.B. we tried two different methods to control :
A. Limiting Training Data
As Eq. (3) suggests, limiting each tree’s data controls the average sequence length:

Fig. 4. Average Sequence Length as a Function of the Number of Songs the Tree Trained on
In Fig. 4 we can see an empirical result for Eq. (3). As we decrease the amount of data each tree receives, decreases.
B. Choosing the Number of Steps

Fig. 5. Average Sequence Length as a Function of Steps
In Fig. 5 shows that, as intended, increasing “steps” increases (3).
C. Qualitative Evaluation
Examples of songs created by the algorithm, with different parameters, are available at the GitHub repository [7]. Listening to songs uncovers problems in our algorithm:
- Rhythmic Ridgidity
As the training process omitted rhythm, the generated output exhibits a strict bit. The resulting lack of timing deviations contributes to a perceptual "robotic" quality, highlighting the necessity of encoding expressive timing features in future iterations.
- Structure Coherence vs. Overfitting
We observe a direct correlation between and musical coherence. Samples generated with larger values exhibit established chord progressions and consistent tone. However, as noted in Section I, this coherence often stems from the algorithm copying verbatim sections of the training data (overfitting). We propose using methods for plagiarism detection [6] to test the song’s uniqueness.
IV. CONCLUSIONS
As we see from the results, Our algorithm can control the balance between copying and randomization with low complexity. In the future we would like to utilize different UC algorithms and improve the structure of the songs through pre-processing and a different generation stage.
REFERENCES
[1] S. Bengesi, H. El-Sayed, M. K. Sarker, Y. Houkpati, J. Irungu, and T. Oladunni, “Advancements in Generative AI: A Comprehensive Review of GANs, GPT, Autoencoders, Diffusion Model, and Transformers,” IEEE Access, vol. PP, p. 1, Nov. 2024, doi: 10.1109/ACCESS.2024.3397775.
[2] T. M. Cover and J. A. Thomas, Elements of information theory, 2nd ed. Hoboken, N.J: Wiley-Interscience, 2006.
[3] N. Merhav and M. J. Weinberger, “On universal simulation of information sources using training data,” IEEE Trans Inf Theory, vol. 50, no. 1, pp. 5–20, 2004, doi: 10.1109/TIT.2003.821993.
[4] S. Dubnov and G. Assayag, “Universal Prediction Applied to Stylistic Music Generation,” in Mathematics and Music, A Diderot Mathematical Forum, Springer, Assayag, G., Feichtinger, H.G., Rodrigues, and J.F., Eds., 2002, pp. 147–158. [Online]. Available: https://hal.science/hal-01161368
[5] C. Ding, A. R. Gorle, S. Bhattacharya, D. Hasteer, N. Sagan, and T. Weissman, “LzMidi: Compression-Based Symbolic Music Generation,” in 2025 IEEE International Symposium on Information Theory (ISIT), 2025, pp. 1–6. doi: 10.1109/ISIT63088.2025.11195229.
[6] T. Lu, C.-M. Geist, J. Melechovsky, A. Roy, and D. Herremans, “MelodySim: Measuring Melody-aware Music Similarity for Plagiarism Detection,” Nov. 2025. doi: 10.48550/arXiv.2505.20979.
[7] N. Mishan and R. Zamir, “LZ-Synth Repository,” 2025. Accessed: Nov. 26, 2025. [Online]. Available: https://github.com/NadavMishan/LZ-synth
[8] Magenta, “The MAESTRO Dataset,” Google. Accessed: Nov. 26, 2025. [Online]. Available: https://magenta.withgoogle.com/datasets/maestro
[9] The MIDI Association, “MIDI 1.0 Detailed Specification,” 1996.
[10] J. Ziv and A. Lempel, “Compression of individual sequences via variable-rate coding,” IEEE Trans Inf Theory, vol. 24, no. 5, pp. 530–536, 1978, doi: 10.1109/TIT.1978.1055934.