$ show jthickstun/anticipation
This repository provides the infrastructure for the Anticipatory Music Transformer, a research project for music generation using autoregressive transformers with anticipatory infilling. The codebase covers the full pipeline: preprocessing of MIDI files (Lakh MIDI dataset) into a compound token representation, tokenization into arrival-time or interarrival-time sequences with optional augmentation for anticipation training, and sampling from trained models using custom generation logic. It also includes scripts for human evaluation reproduction and model benchmarking. While primarily a research codebase for a specific paper, the library components in the `anticipation` package (particularly the conversion, ops, and sampling modules) are well-structured and could be reused in other music tokenization or generation projects. The repository does not include the training loop itself but provides configuration files for use with the Levanter training framework.
The LLM identified 2 files worth highlighting for reuse:
Provides a set of generic, composable operations on tokenized music event sequences (e.g., clip, sort, split, pad, unpad, translate, combine, anticipate). These are not specific to any particular model and could be extracted and used in other music tokenization or generation projects with minimal modification. The functions are well-documented and handle edge cases like sequence separators and control tokens.
Implements bidirectional conversion between MIDI files and tokenized representations (both arrival-time compound tokens and interarrival-time tokens). The conversion handles quantization, instrument mapping, and special cases like drums and tempo changes. These routines are essential for any MIDI-based machine learning project and are modular enough to be reused independently.