FlexiAST: Flexibility is What AST Needs

Jiu Feng, Mehmet Hamza Erol, Joon Son Chung, Arda Senocak

Abstract

Standard Audio Spectrogram Transformers (ASTs) are inherently rigid, exhibiting a sharp performance collapse if the input patch size at inference deviates from the size used during training. This limitation necessitates training separate models for every desired resolution-efficiency trade-off. We introduce FlexiAST, a training regime that produces a single, versatile model capable of maintaining high accuracy across a wide range of patch sizes (from 8x8 to 48x48). By utilizing random patch sampling and a pseudo-inverse resizing technique for patch embeddings, FlexiAST transforms the "brittle peak" of standard ASTs into a high-performance plateau, matching or exceeding the performance of specialized fixed-size models without architectural modifications.

Introduction

In Transformer-based audio processing, the spectrogram is partitioned into discrete units known as "patches." The dimensions of these patches dictate a fundamental trade-off: smaller patches offer higher resolution at a significant computational cost (longer sequence lengths), while larger patches provide faster processing at the expense of detail.

Currently, Audio Spectrogram Transformers (ASTs) are "locked" into the specific patch size encountered during training. Attempting to run a model trained on 16x16 patches with 8x8 patches to capture finer detail, or 32x32 patches to reduce latency, typically results in a total loss of predictive power. FlexiAST addresses this rigidity, enabling a single model to adapt to varying computational budgets and resolution requirements at runtime.

The FlexiAST Framework

FlexiAST does not require a new architecture; instead, it modifies the training pipeline to instill flexibility within the standard Transformer backbone. The approach rests on three primary pillars:

1. Random Patch Sampling

Rather than training on a fixed grid, FlexiAST randomly selects a patch size from a predefined range (e.g., 8x8 to 48x48) for every training batch. This exposes the model to a variety of granularities, forcing the internal representations to become scale-invariant.

2. Pseudo-Inverse (PI) Resizing

When the patch size changes, the model's patch embedding weights and positional embeddings must be resized. While standard Bilinear Interpolation (BL) is sufficient for positional embeddings, the authors found it inadequate for patch embeddings, as it tends to "blur" the weights and disrupt the mathematical alignment required by the Transformer's attention mechanism.

FlexiAST adopts Pseudo-Inverse Resize (PI-resize). Inspired by recent advances in computer vision (FlexiViT), this method treats resizing as an optimization problem. It ensures that the information extracted from a new patch size aligns as closely as possible with the original weight distribution, preserving the integrity of the features across scales.

3. Domain-Specific Constraints

While ASTs share similarities with Vision Transformers (ViT), audio data possesses unique properties. In tasks like speaker identification (e.g., VoxCeleb), the frequency axis contains critical "fingerprints" related to pitch and timbre. The authors discovered that resizing along the frequency axis can degrade performance in these specific contexts. Consequently, for identity-sensitive tasks, FlexiAST employs a "time-only" resizing strategy, maintaining the frequency resolution while scaling the temporal dimension.

Experimental Evaluation

The model was evaluated across five diverse benchmarks: AudioSet (general events), VGGSound (real-world sounds), ESC-50 (environmental classification), Speech Commands-V2 (speech recognition), and VoxCeleb (speaker ID).

Key Findings

  • Versatility and Stability: Unlike standard ASTs, which show near-zero utility outside their trained patch size, FlexiAST maintains stable, high performance across the entire tested spectrum (8 to 48). On the VGGSound benchmark, a standard AST-B/16 drops from ~50% to ~1% accuracy when moved to a size 48 patch; FlexiAST remains consistently competitive.
  • Competitive Accuracy: FlexiAST does not sacrifice quality for flexibility. In many instances, it matches or outperforms specialized models that were trained exclusively on a single patch size.
  • The Importance of Initialization: The research indicates that initializing FlexiAST from a pre-trained standard AST—using PI-resize to bridge the dimensions—yields superior results compared to starting from a standard Vision Transformer (ViT) backbone.

Discussion and Future Work

FlexiAST demonstrates that the rigidity of current audio models is a consequence of training protocols rather than architectural limitations. By making the patch embedding layer flexible, we can deploy a single model across a variety of hardware profiles, from high-power servers requiring maximum resolution to edge devices requiring low-latency inference.

To maintain a controlled study, the authors omitted common performance-enhancing techniques such as patch overlapping, mixup augmentation, or model distillation. While this results in absolute accuracy figures slightly below the current "tricked-out" state-of-the-art, it confirms the robustness of the core FlexiAST method. Future research will focus on integrating these augmentations and exploring how FlexiAST can handle variable-length audio inputs in tandem with variable patch sizes for truly dynamic audio processing.

Summary updated

BibTeX
@inproceedings{feng2023flexiast,
  author = {Jiu Feng and Mehmet Hamza Erol and Joon Son Chung and Arda Senocak},
  title = {{FlexiAST: Flexibility is What AST Needs}},
  booktitle = {Interspeech},
  year = {2023},
  doi = {10.21437/interspeech.2023-745},
}
Figure