This is the official repository of the NeurIPS 2024 paper "The Exprgiessive Capacity of State Space Models: A Formal Language Perspective".
To set up the environment and install the necessary packages, follow these steps:
- Create a new conda environment:
conda create -n mtest
- Activate the conda environment:
conda activate mtest
- Install CUDA NVCC:
conda install -c 'Nvidia/label/cuda-11.7.0' cuda-nvcc - Install PyTorch and related packages:
conda install PyTorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 PyTorch-cuda=11.7 -c pytorch -c Nvidia
- Install additional Python packages:
pip install packaging pip install mamba-ssm pip install pandas hydra-core pydantic-settings python-decouple wandb
Save a .env file locally with the following parameters (if Wandb logging is to be enabled):
WANDB_API_KEY=__
WANDB_TEAM=__
To run an experiment with Cross Entropy Loss:
python train_with_ce.py basic.use_wandb=False train.epochs=100 dataset=dyck1To run an experiment with Mean Squared Error Loss:
python train_with_mse.py basic.use_wandb=False train.epochs=100 dataset=dyck1You can change the dataset parameter to train on a specific dataset out of the 27 languages.
To run the Flip Flop experiment:
python train_with_mse.py basic.is_flip_flop=True dataset=flip_flop train.epochs=100- Install additional Python packages:
pip install matplotlib seaborn- Switch to the correct folder
cd bounded_dyck_expt- Run the experiment for a specific layer and d_model combination
python src/run_lm.py experiments/layer2_80.yamlCode co-authored by Yash Sarrof and Yana Veitsman Code used here has been heavily inspired by the following repositories: