Hamm-grams in Tonal Harmony
- Hamm-grams are harmony-oriented skip-grams that model tonal progressions by allowing bounded non-adjacent chord relations in polyphonic music.
- They mitigate data sparsity by incorporating fixed- and variable-skip constraints, which boost train-test coverage and reveal hidden cadential patterns.
- Evaluations on four Western classical datasets demonstrate substantial improvements in discovering conventional cadential progressions while balancing computational cost.
Hamm-grams are harmony-oriented skip-grams for modeling tonal progressions in polyphony: n-grams of symbolic chord events that relax strict contiguity by admitting bounded non-adjacent relations, so that underlying harmonic successions can still be represented when surface insertions such as non-chord tones, suspensions, and passing tones interrupt adjacency. In the reported formulation, Hamm-grams are used within viewpoint models of tonal harmony and were evaluated on four Western classical symbolic datasets, where they reduced sparsity in higher-order harmonic distributions, increased train-test coverage, and substantially improved discovery of conventional cadential progressions (Sears et al., 2017).
1. Conceptual basis and formal definition
In this usage, “grams” are n-grams of symbolic musical events. Given a sequence of events, a contiguous n-gram is any subsequence with . For a corpus of pieces, where piece has sequence length , the total number of contiguous n-gram tokens is (Sears et al., 2017).
Skip-grams generalize this construction by allowing bounded non-contiguous relations. An n-length skip-gram with max skip is any tuple with and 0 for all 1. A variable-skip n-gram replaces the fixed skip bound with an inter-onset interval ceiling, so that adjacent elements in the tuple must satisfy an IOI bound such as 2 s. This temporal variant reflects the fact that musical salience is not determined solely by event count but also by elapsed time (Sears et al., 2017).
The need for bounded skipping follows directly from combinatorial behavior in polyphonic corpora. Unbounded non-contiguity for a sequence of length 3 yields 4 possible tokens, and even a 20-event sequence contains 190 2-grams, 1140 3-grams, 4845 4-grams, and 15,504 5-grams if all non-contiguous relations are included. Hamm-grams therefore occupy a middle ground: they reject strict contiguity, but they also avoid the explosive token growth of unconstrained subsequence enumeration (Sears et al., 2017).
2. Harmonic event representation
The method operates on composite chord events encoded by viewpoint features that combine simultaneous relations and sequential relations. The practical typology used is the voice-leading type (VLT), in which each chord is represented by an ordered tuple 5, where 6 is a set of up to three interval classes above the bass and 7 is the melodic interval class from the preceding bass to the current bass, both modulo the octave. Full expansion duplicates overlapping note events at each unique onset; in the reported corpus this yielded 327,150 chord onsets (Sears et al., 2017).
The vertical component of the representation is a major source of sparsity. Without reductions, 8 alone has up to 9 combinations, since each of three positions can take 13 values, including the undefined symbol 0. To control this, the study excludes pitch-class repetitions in 1 and allows permutations, reducing the domain to 233 unique VLTs when 2 and 3 is undefined. This reduction is important because higher-order harmonic sequences compound the state-space explosion already present at the level of single chord events (Sears et al., 2017).
Onsets with more than three vertical interval classes were handled by a three-step back-off strategy: closest maximal subset estimated from immediate context within 4 chords; most common maximal subset in the piece; and most common maximal subset in the corpus. This adjusted 5545 onsets, or 1.7% of the corpus, to respect the 5-interval constraint of the VLT representation. A plausible implication is that the representation trades some local chordal specificity for a tractable symbolic vocabulary suitable for distributional modeling (Sears et al., 2017).
3. Corpus, parameterization, and evaluation protocol
The empirical study used four Western classical symbolic datasets totaling over 20 hours of music. Each dataset included a score-like symbolic representation and aligned performance timing, either from sensor-equipped pianos or from ensemble recordings aligned at the downbeat level (Sears et al., 2017).
| Dataset | Pieces | Chords / revised tokens |
|---|---|---|
| Haydn | 50 | 73,704 / 0 |
| Mozart | 39 | 63,418 / 969 |
| Beethoven | 30 | 42,157 / 910 |
| Chopin | 156 | 147,871 / 3666 |
| Total | 275 | 327,150 chord onsets / 5545 revised |
Contiguous n-grams were computed for 6. Sparsity analysis focused on 4-grams with fixed-skip settings up to 1, 2, 3, or 4 skips, and variable-skip settings with successive IOIs 7, 8, 9, or 0 s. Coverage evaluations were conducted for 1 under the same fixed and variable skip families (Sears et al., 2017).
The training/test regime used 10-fold cross-validation stratified by composer, with folds balanced to contain approximately equal compositions and total chord counts, within 2 of the target per fold. Coverage was defined as
3
while the proportion of negligible counts under threshold 4 was
5
The frequency and probability estimates were
6
Planned comparisons for coverage used Welch’s t-tests with backward difference coding and Bonferroni correction (Sears et al., 2017).
4. Sparsity reduction and coverage behavior
The central empirical claim is that Hamm-grams reduce data sparsity in n-gram distributions by minimizing the proportion of n-grams with negligible counts and by increasing the coverage of contiguous n-grams in a test corpus. For 4-grams, the contiguous model produced 135,331 types and 326,034 tokens. Fixed-skip variants increased this to 850,222, 2,364,840, 4,765,289, and 8,207,123 types for 7, with corresponding token counts 2,604,972, 8,780,643, 20,786,976, and 40,548,000. Variable-skip variants were larger still, reaching 59,147,107 types and 718,717,231 tokens at IOI 8 s (Sears et al., 2017).
The distributional interpretation is not merely a matter of larger vocabularies. Contiguous higher-order n-grams with 9 deviated from a typical power-law profile because the proportion of types with negligible counts increased, producing more uniform distributions. Including skip-grams restored a power-law-like profile for 4-grams: cumulative probability curves showed fewer singletons and a heavier head. This suggests that bounded non-contiguity increases the recoverability of recurrent harmonic patterns rather than simply multiplying rare forms (Sears et al., 2017).
Coverage results were strongest for higher-order progressions. For 2-grams, mean coverage rose from 0.959 with no skip to 0.988 with fixed 0 and to 0.993 with IOI 1 s. For 3-grams, it rose from 0.707 to 0.901 with fixed 2 and to 0.943 with IOI 3 s. For 4-grams, the contiguous baseline of 0.365 increased to 0.711 with fixed 4 and to 0.824 with IOI 5 s. The paper summarizes this as drastic mitigation of the zero-frequency problem for higher-order harmony sequences (Sears et al., 2017).
5. Cadence discovery and music-theoretical significance
A major test case was cadence discovery. The study examined two conventional closing progressions: the semplice cadence, 6, and the composta cadence, 7, where 8 is a six-four suspension over the cadential dominant. Discovery was counted as the number of pieces in which the exact four-chord VLT encodings were found (Sears et al., 2017).
Contiguous 4-grams performed poorly: the semplice cadence was discovered in 0 pieces and the composta cadence in 7. Fixed-skip models improved these counts monotonically, reaching 15 semplice and 63 composta discoveries at 9. Variable-skip models also improved sharply, reaching 32 semplice and 77 composta discoveries at IOI 0 s. The difference is especially notable because cadential progressions are theoretically canonical yet are frequently obscured at the surface by suspensions, anticipations, and non-chord tones (Sears et al., 2017).
The explanation offered is directly music-theoretical. Cadences often contain interpolated events between structurally salient harmony events, so contiguous models encode the surface rather than the underlying harmonic trajectory. Hamm-grams recover non-adjacent dependencies such as 1 across suspensions, passing tones, or neighboring notes by admitting bounded gaps or temporally plausible windows. In that sense, they were designed to be musically faithful to tonal closure in polyphonic textures (Sears et al., 2017).
6. Algorithmic procedure, trade-offs, and scope
The reported extraction procedure is straightforward. First, preprocess the symbolic score by full expansion, encode each onset as a VLT 2, remove duplicates in 3, allow permutations, and replace onsets with more than three vertical intervals by a maximal subset via contextual back-off. Second, choose 4 and either a fixed skip bound 5 or a variable IOI ceiling 6. Third, for each starting index 7, search forward for valid 8 satisfying either 9 or 0, emit the tuple 1, and increment 2. Fourth, build the frequency distribution and evaluate coverage by cross-validation (Sears et al., 2017).
The method involves explicit trade-offs. Larger 3 or IOI thresholds increase coverage and reduce sparsity, but they also inflate vocabulary size and raise the risk of spurious associations. The study reports that IOI 4–5 s gave strong coverage gains for 3-grams and 4-grams. It also notes that more skip relations produce more types, so pruning by 6, weighting by temporal proximity, periodicity, or metric strength, and using smoothed probabilities for prediction are natural extensions (Sears et al., 2017).
Computational cost rises quickly with token growth, but bounded settings remained practical in the reported implementation. For 7 chords, all 4-gram tokens were retrieved in less than 100 ms for fixed 8 and less than 3 s for IOI 9 s on commodity hardware. Recommended settings were likewise pragmatic: VLT with full expansion and simple reductions; a focus on 3-grams and 4-grams for harmonic syntax; and skip bounds in fixed 0 or IOI windows in 1 s to balance coverage and precision (Sears et al., 2017).
The scope of the approach is also clearly delimited. VLT conflates permutations and removes doublings, which may obscure distinctions needed in some analyses. Onsets with more than three intervals are approximated via maximal subsets, which can bias chord identity. The datasets are Western classical repertories with score-aligned performances, so results may differ for other genres or unaligned symbolic corpora. Extremely dense ornamentation can challenge fixed skip bounds, and very high 2 or very large skip windows become computationally heavy and noisy. Within those limits, the study’s key takeaway is precise: by incorporating bounded non-contiguity, Hamm-grams recover conventional harmonic patterns obscured by surface embellishments, reduce sparsity, and make higher-order harmonic modeling tractable (Sears et al., 2017).