
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:
bash
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:
bash
./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:
bash
cd src/finetune/audiosetbash
cd src/finetune/esc50For Speech Commands v2:
bash
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:
```bash
#!/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 ```
submit_jobs.sh script in the terminal to start the finetuning process:
bash
./submit_jobs.shMake sure to monitor the jobs and adjust any parameters as needed to suit your specific requirements and hardware configuration.
Clone the SUPERB repository:
bash
git clone https://github.com/s3prl/s3prl.git
Navigate to the s3prl directory:
bash
cd s3prl
Install the package:
bash
pip install -e ./
src/finetune/voxceleb1/ssast to s3prl/s3prl/upstream/ssast.run_sid.sh or run_er.sh file:Adjust the paths in the 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:
bash
./submit_jobs_amba.shThe 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:
@inproceedings{Shams_2024,
title={SSAMBA: Self-Supervised Audio Representation Learning With Mamba State Space Model},
url={http://dx.doi.org/10.1109/SLT61566.2024.10832304},
DOI={10.1109/slt61566.2024.10832304},
booktitle={2024 IEEE Spoken Language Technology Workshop (SLT)},
publisher={IEEE},
author={Shams, Siavash and Dindar, Sukru Samet and Jiang, Xilin and Mesgarani, Nima},
year={2024},
month=dec, pages={1053–1059}
}
$ claude mcp add ssamba \
-- python -m otcore.mcp_server <graph>