This repository contains the official implementation (in PyTorch) of the the paper SSAMBA: Self-Supervised Audio Representation Learning with Mamba State Space Model. SSAMBA is an advanced audio representation learning model designed to leverage self-supervised learning techniques using the Mamba State Space Model. This project builds on the success of the Self-Supervised Audio Spectrogram Transformer (SSAST) and introduces novel methodologies to further enhance performance and efficiency on various audio tasks.
To install the necessary dependencies, you can use the following commands:
git clone https://github.com/SiavashShams/ssamba.git
cd ssamba
pip install -r requirements.txt
Next, clone the Vision Mamba repository inside your ssamba directory:
git clone https://github.com/hustvl/Vim.git
If you encounter issues with bimamba_type
, please refer to the steps outlined in this GitHub issue comment.
SSAMBA is approximately 92.7\% faster in batch inference speed and 95.4\% more memory-efficient than SSAST for the tiny model size with an input token size of 22k.
We pretrained SSAMBA with various sizes (base, small, tiny) for patches (250, 300, and 400) on a mixture of unlabeled audios from AudioSet and LibriSpeech. You can find these weights in the "Pretrained Model Weights" section below. However, if you want to pretrain the model from scratch, follow this recipe:
Navigate to the Directory: Change to the directory containing the pretraining scripts. You can do this by running the following command in your terminal:
cd ssamba/src/pretrain
Adjust the Script: Edit the run_mask_patch_amba.sh
script to update the paths to your data files, Mamba encoder configurations, and any other necessary hyperparameters. Make sure that all paths and settings accurately reflect your local environment and the specifics of the dataset you are using.
Run the Script: After making the necessary adjustments, execute the script to start the pretraining process. You can run the script directly from the terminal with the following command:
./run_mask_patch_amba.sh
The pretrained model weights for our SSAMBA model in sizes (base, small, and tiny) for different number of masked patches (400, 300, 250) can be found at:
To finetune the pretrained SSAMBA on the balanced Audioset or ESC-50 datasets, follow these steps:
Navigate to the finetuning directory:
cd src/finetune/audioset
cd src/finetune/esc50
cd src/finetune/speechcommands_v2
Adjust the paths and hyperparameters:
Edit run_as_amba.sh
, run_esc_patch_amba.sh
and run_sc_amba.sh
. Adjust the paths and hyperparameters as needed for your dataset.
Configure SLURM job submission (if using SLURM):
Add the models you want to finetune to submit_jobs.sh
:
#!/bin/bash
# Array of pre-trained models
declare -a models=("ssamba_tiny_400")
# Submit a job for each model
for model in "${models[@]}"; do
sbatch run_as_amba.sh $model
done
Run the job submission script:
Execute the submit_jobs.sh
script in the terminal to start the finetuning process:
./submit_jobs.sh
Make sure to monitor the jobs and adjust any parameters as needed to suit your specific requirements and hardware configuration.
Clone the SUPERB repository:
git clone https://github.com/s3prl/s3prl.git
Navigate to the s3prl directory:
cd s3prl
Install the package:
pip install -e ./
src/finetune/voxceleb1/ssast
to s3prl/s3prl/upstream/ssast
.Edit the run_sid.sh
or run_er.sh
file:
run_sid.sh
or run_er.sh
file to point to the correct directories for your dataset and model.Specify models in submit_jobs_amba.sh
:
submit_jobs_amba.sh
script to specify the models you want to fine-tune.submit_jobs_amba.sh
script:
submit_jobs_amba.sh
and run:
./submit_jobs_amba.sh
The license for borrowed code can be found in LICENSE file. We acknowledge the wonderful work of SSAST, and Vision Mamba.
If you find this work helpful, please consider giving us a star 🌟 and citing:
@article{shams2024ssamba,
title={SSAMBA: Self-Supervised Audio Representation Learning with Mamba State Space Model},
author={Siavash Shams and Sukru Samet Dindar and Xilin Jiang and Nima Mesgarani},
year={2024},
eprint={2405.11831},
archivePrefix={arXiv},
primaryClass={eess.AS},
journal={arXiv preprint arXiv:2405.11831}
}