zehuiwu/MMML

Multi-Modality Multi-Loss Fusion Network

150

stars

0

commits

Python

primary language

Jul 28, 2024

updated

README

Multimodal Multi-Loss Fusion Network (MMML)

PWC

PWC

PWC

PWC

Paper link: https://arxiv.org/abs/2308.00264 (NAACL2024 oral)

Updates

07/19/2024: Add CME for context modeling; upload requirements.txt; skip invalid audio files in dataloader

New Training Results (CME+context):

CMU-MOSI
SeedHas0_acc_2Has0_F1_scoreNon0_acc_2Non0_F1_scoreMult_acc_5Mult_acc_7MAECorr
10.89210.89180.91310.91310.59910.52480.56870.8803
110.87900.87860.89790.89780.58890.51600.56770.8790
1110.88340.88320.89940.89950.61220.54080.53560.8878
Avg0.88480.88450.90350.90350.60010.52720.55730.8824
CMU-MOSEI
SeedHas0_acc_2Has0_F1_scoreNon0_acc_2Non0_F1_scoreMult_acc_5Mult_acc_7MAECorr
10.86760.86740.88220.88000.58640.56600.48360.8196
110.86690.86730.88280.88100.57870.55630.49860.8085
1110.85620.85780.88170.88030.55850.52090.53930.8146
Avg0.86360.86420.88220.88040.57450.54770.50720.8142

Settings

GPU: NVIDIA RTX A6000

Parameter: Default (batch_size=8, lr=5e-6, loss='MTA', text_context_len=2, audio_context_len=1, num_hidden_layers=5)

Details: We use the large version of pre-trained models for this setting. We found that while the large models didn't improve upon the base models in context-free scenarios, they boosted improvement when using context.

Environment setup

  1. create a new environment using conda or pip (We use Python 3.8.10)
  2. pip install -r requirements.txt

Download Data

The three datasets (CMU-MOSI, CMU-MOSEI, and CH-SIMS) are available from this link: https://drive.google.com/drive/folders/1A2S4pqCHryGmiqnNSPLv7rEg63WvjCSk

Data Directory

To run our preprocessing and training codes directly, please put the necessary files from downloaded data in separate folders as described below.

/data/
    mosi/
        raw/
        label.csv
    mosei/
        raw/
        label.csv
    sims/
        raw/
        label.csv

Audio Extraction

Before running the training code, please extract the audio from the raw video files.

python extract_audio.py

options:
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: mosi)

Train only with audio features

python run_audio.py  

options (optional):
  --lr LR               learning rate (default: 1e-4)
  
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: sims)
  
  --seed SEED           random seed (default: 1)
  
  --feature FEATURE     feature type: mel spectrogram (spec), smile, or raw (default: spec)
  
  --batch_size BATCH_SIZE
                        batch size (default: 16)
                        
  --early_stop EARLY_STOP
                        early stop (default: 8)

Train with both text and audio features

python run.py

options (optional):
  --seed SEED           random seed (default: 1)
  
  --batch_size BATCH_SIZE
                        batch size (default: 8)
                        
  --lr LR               learning rate (default: 5e-6, recommended: 5e-6 for mosi, mosei, 1e-5 for sims)
  
  --model MODEL         concatenate(cc) or cross-modality encoder(cme) (default: cme)
  
  --cme_version VERSION
                        different variations of the fusion network
                        (v1: employs only the fused features, v2: merges the original signal with the fused signal, v3: uses a transformer to combine these two signals.) (default: v1)
                        
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: mosi)
  
  --num_hidden_layers NUM_HIDDEN_LAYERS
                        number of hidden layers for cross-modality encoder (default: 5)
                        
  --loss LOSS          use multiple losses to train: M: multi-modal, T: text, A: audio
                       (if T -> train only the text subnet; if M -> use the loss from fusion network to train the whole model)
                       (default: MTA)
                       
  --context CONTEXT    weather incorporating context or not (default: True)
  
  --text_context_len LENGTH  the length of the context window for text features (default: 2)
  
  --audio_context_len LENGTH the length of the context window for audio features (default: 1)

Side Note

Please feel free to adopt the code for any combinations of pre-trained models.

zehuiwu/MMML

Multi-Modality Multi-Loss Fusion Network

150

stars

0

commits

Python

primary language

Jul 28, 2024

updated

README

Multimodal Multi-Loss Fusion Network (MMML)

PWC

PWC

PWC

PWC

Paper link: https://arxiv.org/abs/2308.00264 (NAACL2024 oral)

Updates

07/19/2024: Add CME for context modeling; upload requirements.txt; skip invalid audio files in dataloader

New Training Results (CME+context):

CMU-MOSI
SeedHas0_acc_2Has0_F1_scoreNon0_acc_2Non0_F1_scoreMult_acc_5Mult_acc_7MAECorr
10.89210.89180.91310.91310.59910.52480.56870.8803
110.87900.87860.89790.89780.58890.51600.56770.8790
1110.88340.88320.89940.89950.61220.54080.53560.8878
Avg0.88480.88450.90350.90350.60010.52720.55730.8824
CMU-MOSEI
SeedHas0_acc_2Has0_F1_scoreNon0_acc_2Non0_F1_scoreMult_acc_5Mult_acc_7MAECorr
10.86760.86740.88220.88000.58640.56600.48360.8196
110.86690.86730.88280.88100.57870.55630.49860.8085
1110.85620.85780.88170.88030.55850.52090.53930.8146
Avg0.86360.86420.88220.88040.57450.54770.50720.8142

Settings

GPU: NVIDIA RTX A6000

Parameter: Default (batch_size=8, lr=5e-6, loss='MTA', text_context_len=2, audio_context_len=1, num_hidden_layers=5)

Details: We use the large version of pre-trained models for this setting. We found that while the large models didn't improve upon the base models in context-free scenarios, they boosted improvement when using context.

Environment setup

  1. create a new environment using conda or pip (We use Python 3.8.10)
  2. pip install -r requirements.txt

Download Data

The three datasets (CMU-MOSI, CMU-MOSEI, and CH-SIMS) are available from this link: https://drive.google.com/drive/folders/1A2S4pqCHryGmiqnNSPLv7rEg63WvjCSk

Data Directory

To run our preprocessing and training codes directly, please put the necessary files from downloaded data in separate folders as described below.

/data/
    mosi/
        raw/
        label.csv
    mosei/
        raw/
        label.csv
    sims/
        raw/
        label.csv

Audio Extraction

Before running the training code, please extract the audio from the raw video files.

python extract_audio.py

options:
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: mosi)

Train only with audio features

python run_audio.py  

options (optional):
  --lr LR               learning rate (default: 1e-4)
  
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: sims)
  
  --seed SEED           random seed (default: 1)
  
  --feature FEATURE     feature type: mel spectrogram (spec), smile, or raw (default: spec)
  
  --batch_size BATCH_SIZE
                        batch size (default: 16)
                        
  --early_stop EARLY_STOP
                        early stop (default: 8)

Train with both text and audio features

python run.py

options (optional):
  --seed SEED           random seed (default: 1)
  
  --batch_size BATCH_SIZE
                        batch size (default: 8)
                        
  --lr LR               learning rate (default: 5e-6, recommended: 5e-6 for mosi, mosei, 1e-5 for sims)
  
  --model MODEL         concatenate(cc) or cross-modality encoder(cme) (default: cme)
  
  --cme_version VERSION
                        different variations of the fusion network
                        (v1: employs only the fused features, v2: merges the original signal with the fused signal, v3: uses a transformer to combine these two signals.) (default: v1)
                        
  --dataset DATASET     dataset name (mosi, mosei, or sims) (default: mosi)
  
  --num_hidden_layers NUM_HIDDEN_LAYERS
                        number of hidden layers for cross-modality encoder (default: 5)
                        
  --loss LOSS          use multiple losses to train: M: multi-modal, T: text, A: audio
                       (if T -> train only the text subnet; if M -> use the loss from fusion network to train the whole model)
                       (default: MTA)
                       
  --context CONTEXT    weather incorporating context or not (default: True)
  
  --text_context_len LENGTH  the length of the context window for text features (default: 2)
  
  --audio_context_len LENGTH the length of the context window for audio features (default: 1)

Side Note

Please feel free to adopt the code for any combinations of pre-trained models.

Languages

Python

100.0%