Abstract
Generating polyphonic music remains a significant challenge for sequence-based deep learning models, which often struggle to capture the simultaneous relationships within chords and the hierarchical structure of musical phrases. We present the Vertical-Horizontal Variational Autoencoder (VH-VAE), a lightweight model (<10MB) designed to generate theoretically sound polyphony. By employing a Structured Attention Network (SAN) that separates vertical (chordal) and horizontal (temporal) dependencies, the model achieves superior chord reconstruction accuracy compared to larger baselines. Furthermore, analysis of the latent space reveals that the model autonomously learns fundamental music theory concepts, such as the Circle of Fifths, without explicit supervision.
Introduction
Unlike text, which is a linear sequence of tokens, music is inherently multi-dimensional. Polyphony—the occurrence of multiple notes simultaneously—requires models to understand both the vertical structure of chords and the horizontal structure of temporal progression. Standard attention mechanisms, such as those used in Transformers, are often computationally prohibitive and lack the inductive bias necessary to represent these hierarchical relationships effectively. Many existing models simplify this complexity by flattening chords into sequences or single notes, which compromises the harmonic richness of the generated output.
Methodology: The VH-VAE Architecture
The Vertical-Horizontal Variational Autoencoder (VH-VAE) addresses these limitations through two primary innovations: the Structured Attention Network (SAN) and a specialized Permutation Loss (PL).
Structured Attention Network (SAN)
Instead of a flat self-attention mechanism, the VH-VAE utilizes a non-projective dependency tree attention layer. This is divided into two components:
- Vertical Attention: This mechanism passes messages between different "keys" (representing potential notes) within a single time step, allowing the model to explicitly learn how individual notes combine to form a coherent chord.
- Horizontal Attention: This component establishes linkages between different bars, ensuring long-term temporal coherence and structural stability across musical phrases.
Permutation Loss (PL)
To prevent the model from predicting redundant or overlapping pitches within a single chord, the researchers introduced a novel loss function based on Focal Loss. Permutation Loss penalizes the model when multiple internal keys attempt to produce the same pitch, forcing the network to distribute note assignments effectively across the available chordal structure.
Key Insights and Music Theory Emergence
A significant finding of this research is the model's ability to internalize music theory principles purely from data. When the high-dimensional latent space of the VH-VAE was projected using Principal Component Analysis (PCA), the resulting embeddings naturally clustered according to the Circle of Fifths. This suggests that the model's architecture successfully captures the mathematical relationships between different musical keys.
Additionally, the model demonstrated an understanding of "interval vectors." It successfully distinguished between major and minor tonalities by learning their distinct mathematical distributions of note distances—for example, identifying the preference for four-semitone intervals in minor pieces versus two-semitone intervals in major ones.
Results and Performance
The VH-VAE was evaluated using the MAESTRO dataset, consisting of over 1,000 hours of professional piano performances.
- Chord Accuracy: The model outperformed the baseline MusicVAE, capturing at least 10% more chords correctly as measured by the True Positive Rate (TPR).
- Efficiency: By utilizing structured attention and a streamlined input/output layer, the VH-VAE remains exceptionally lightweight. At less than 10MB, it is a fraction of the size of MusicVAE (>100MB), making it suitable for deployment on standard CPU hardware.
- Structural Awareness: Horizontal attention visualizations confirmed that the model identifies "anchor" bars (e.g., the start of phrases) to maintain thematic consistency, mimicking human compositional techniques.
Conclusion and Future Work
The VH-VAE demonstrates that architectural inductive biases—designing models to match the inherent structure of the data—can outperform massive, general-purpose models in specialized tasks like music generation. While the current model focuses on single-track piano music without dynamics (velocity), future iterations could expand this vertical-horizontal approach to multi-instrument orchestration and expressive performance modeling. Further research will also incorporate human listener studies to evaluate the subjective aesthetic quality of the generated compositions.
Summary updated