This repository provides an implementation of the Ramba model, a hybrid architecture model for relational data modeling.
Ramba combines Transformer's attention mechanism with Mamba's state space model, using bidirectional Mamba in the column view (col view) of relational data and sparse attention mechanisms in the feature view (feat view) and neighbor view (nbr view), achieving efficient relational data modeling.
-
Install pixi https://pixi.sh/latest/#installation.
-
Clone and install the repository:
git clone https://github.com/ROOOOOOOOL/Ramba.git
cd Ramba
pixi install
# compile and install the rust sampler
cd rustler
pixi run maturin develop --uv --releaseThis project modifies the
mamba-ssmlibrary (main modifications inthird_party/mamba/mamba_ssm/modules/mamba2.py), somamba-ssmwill be automatically compiled and installed from the local paththird_party/mamba.
- Download the datasets and tasks from Relbench:
cd .. # back to the root of the repository
pixi run python scripts/download_relbench.py- Link the cache repository
mkdir ~/scratch
ln -s ~/.cache/relbench ~/scratch/relbench- Preprocessing (per database):
cd rustler
pixi run cargo run --release -- pre rel-f1- Text embedding (per database):
pixi run python -m RM.embed rel-f1Steps 3. and 4. should be run for all databases:
rel-amazon,rel-avito,rel-event,rel-f1,rel-hm,rel-stack,rel-trial
First setup wandb with pixi run wandb login or pixi run wandb disabled. The following example commands replicate the results for rel-amazon/user-churn from the paper.
- Pretrain on all datasets with
rel-amazonheld-out
pixi run torchrun --standalone --nproc_per_node=8 scripts/pretrain.py- Continued pretrain
from best checkpoint obtained above
on all
rel-amazontasks withuser-churnheld-out
pixi run torchrun --standalone --nproc_per_node=8 scripts/contd_pretrain.py- Finetune
from best checkpoint obtained above
on
rel-amazon/user-churntask only
pixi run torchrun --standalone --nproc_per_node=8 scripts/finetune.pyThe main features of Ramba include:
- Hybrid Architecture: Uses sparse attention mechanisms in feature and neighbor views, and bidirectional Mamba in the column view
- Bidirectional Mamba: Captures bidirectional dependencies through the combination of forward and backward Mamba
- State Space Model: Leverages Mamba's efficient state space model to handle long-sequence relational data
- Custom Mamba Implementation: Customized modifications to the
mamba-ssmlibrary to better adapt to relational data modeling tasks