Masked Audio Generation using a Single Non-Autoregressive Transformer

Alon Ziv, Itai Gat, Gaël Le Lan, Tal Remez, Felix Kreuk, Alexandre Défossez, Jade Copet, Gabriel Synnaeve, Yossi Adi · DOI

Introduction

Generative audio models have reached a point of high fidelity, capable of producing complex musical compositions and realistic environmental soundscapes. However, the dominant architecture for these tasks—the autoregressive (AR) transformer—suffers from a significant bottleneck: latency. Because AR models predict audio tokens sequentially, the time required to generate a sample scales linearly with its length. This makes real-time interaction, such as live music editing or instant sound effect generation, computationally expensive and slow.

Presented at ICLR 2024, MAGNET (Masked Audio Generation using a Single Non-Autoregressive Transformer) introduces a non-autoregressive (NAR) framework designed to close this latency gap. By predicting multiple spans of audio tokens in parallel, MAGNET achieves generation speeds up to 7x faster than state-of-the-art AR models like MusicGen, while maintaining competitive acoustic quality.

The Problem: The Latency Gap in Audio Generation

State-of-the-art models like MusicGen or AudioLM typically operate on discrete audio tokens produced by a neural audio codec (e.g., EnCodec). In an AR setup, generating 30 seconds of audio requires hundreds or thousands of sequential forward passes through the transformer. While diffusion models offer an alternative, they often require a high number of denoising steps to reach professional quality and can struggle with the long-range dependencies inherent in music.

MAGNET addresses this by moving to a parallel prediction paradigm. The primary challenge in NAR audio generation is the high correlation between adjacent audio tokens; if a model is trained with standard point-wise masking, it often learns to "cheat" by interpolating from immediate neighbors rather than understanding the broader semantic context of the prompt.

Methodology

MAGNET utilizes a single transformer architecture operating on EnCodec tokens, which are organized into multiple layers via Residual Vector Quantization (RVQ). Several key innovations allow it to overcome the traditional pitfalls of NAR models:

1. Span Masking

To prevent the model from relying on local interpolation, MAGNET employs span masking. Instead of masking individual tokens, the model masks contiguous 60ms spans. This forces the transformer to learn the global structure and dependencies of the audio, as it cannot simply look at the token immediately preceding or following the mask to predict the missing content.

2. Restricted Context for Fine Details

The authors observed that while the base layer of audio tokens requires global context to maintain melody and structure, the higher-level codebooks (which handle fine acoustic textures) primarily rely on local information. MAGNET restricts the attention mechanism for these higher levels to a 200ms temporal window. This optimization reduces the computational burden and improves the model's ability to converge during training.

3. Iterative Decoding and Rescoring

During inference, MAGNET starts with a fully masked sequence and iteratively "fills in" the tokens over a fixed number of steps. To further enhance quality, the authors introduced a rescoring method. An external, often smaller, pre-trained model ranks the various NAR predictions at each step, ensuring that only the most coherent tokens are retained for the next iteration.

4. Hybrid-MAGNET

Recognizing that the beginning of an audio sequence is critical for establishing rhythm and key, the authors developed Hybrid-MAGNET. This variant generates the first few seconds of audio autoregressively to ensure a stable foundation, then switches to the NAR method to complete the remainder of the sequence in parallel.

Performance and Results

MAGNET was evaluated using the MusicCaps (text-to-music) and AudioCaps (text-to-audio) benchmarks, trained on a dataset of 20,000 hours of licensed audio.

  • Speed: MAGNET demonstrates a massive improvement in latency. For a 10-second audio sample on an NVIDIA A100 GPU, MAGNET achieves a latency of approximately 600ms—a 7x speedup over the AR baseline.
  • Acoustic Quality: On the MusicCaps benchmark, MAGNET-small achieved a Fréchet Audio Distance (FAD) of 3.3, which is remarkably close to the 3.1 achieved by the much slower MusicGen-small.
  • Human Evaluation: Subjective tests for Overall Quality (OVL) and Relevance to Text (REL) showed that MAGNET is perceived as comparable to current state-of-the-art AR and diffusion-based models.

Discussion and Future Work

While MAGNET significantly reduces latency for single-sample generation, the authors note that AR models still maintain an advantage in high-throughput scenarios (large batches) due to the maturity of KV-caching techniques. Additionally, pure NAR models still face a slight "quality ceiling" when dealing with highly complex musical textures compared to their AR counterparts.

Future research directions include optimizing the re-encoding process—potentially through token caching—and exploring more sophisticated non-linear decoding strategies. By proving that NAR models can compete with AR models in the audio domain, MAGNET opens the door for a new generation of interactive, real-time creative tools.

Summary updated

BibTeX
@inproceedings{ziv2024masked,
  author = {Alon Ziv and Itai Gat and Gaël Le Lan and Tal Remez and Felix Kreuk and Alexandre Défossez and Jade Copet and Gabriel Synnaeve and Yossi Adi},
  title = {{Masked Audio Generation using a Single Non-Autoregressive Transformer}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=Ny8NiVfi95},
}
Figure