Home

Awesome

Compatibility for Machine Learning Model Update

This repository contains PyTorch implementation of Forward Compatible Training for Large-Scale Embedding Retrieval Systems (CVPR 2022):

<img src="fct_logo.png" width="360">

and FastFill: Efficient Compatible Model Update (ICLR 2023):

<img src="demo.gif" width="640">

The code is written to use Python 3.8 or above.

Requirements

We suggest you first create a virtual environment and install dependencies in the virtual environment.

# Go to repo
cd <path/to/ml-fct>
# Create virtual environment ...
python -m venv .venv
# ... and activate it
source .venv/bin/activate
# Upgrade to the latest versions of pip and wheel
pip install -U pip wheel
pip install -r requirements.txt

CIFAR-100 Experiments (quick start)

We provide CIFAR-100 experiments, for fast exploration. The code will run and produce results of both FCT and Fastfill. Here are the sequence of commands for CIFAR-100 experiments (similar to ImageNet but faster cycles):

# Get data: following command put data in data_store/cifar-100-python
python prepare_dataset.py

# Train old embedding model:
# Note: config files assume training with 8 GPUs. Modify them according to your environment.
python train_backbone.py --config configs/cifar100_backbone_old.yaml

# Evaluate the old model (single GPU is OK):
python eval.py --config configs/cifar100_eval_old_old.yaml

# Train New embedding model:
python train_backbone.py --config configs/cifar100_backbone_new.yaml

# Evaluate the new model (single GPU is OK):
python eval.py --config configs/cifar100_eval_new_new.yaml

# Download pre-traianed models if training with side-information:
source get_pretrained_models.sh

# Train FCT transformation:
# If training with side-info model, add its path to the config file below. You
# can use the same side-info model as for ImageNet experiment here. 
python train_transformation.py --config configs/cifar100_fct_transformation.yaml

# Evaluate transformed model vs new model (single GPU is OK):
python eval.py --config configs/cifar100_eval_old_new_fct.yaml

# Train FastFill transformation:
python train_transformation.py --config configs/cifar100_fastfill_transformation.yaml

# Evaluate transformed model vs new model (single GPU is OK):
python eval.py --config configs/cifar100_eval_old_new_fastfill.yaml

CIFAR-100 (FCT, without backfilling):

CaseSide-InfoCMC Top-1 (%)CMC Top-5 (%)mAP (%)
old/oldN/A34.260.616.5
new/newN/A56.577.036.3
FCT new/oldNo47.272.625.8
FCT new/oldYes50.273.732.2

CIFAR-100 (FastFill, with backfilling):

CaseSide-InfoBackfillingAUC CMC Top-1 (%)AUC CMC Top-5 (%)AUC mAP (%)
old/oldN/AN/A34.260.616.5
new/newN/AN/A56.577.036.3
FCT new/oldNoRandom49.173.629.1
FastFill new/oldNoUncertainty53.675.332.5

ImageNet-1k Experiments

Here are the sequence of commands for ImageNet experiments:

# Get data: Prepare full ImageNet-1k dataset and provide its path in all config
# files. The path should include training and validation directories. 

# Train old embedding model:
# Note: config files assume training with 8 GPUs. Modify them according to your environment.
python train_backbone.py --config configs/imagenet_backbone_old.yaml

# Evaluate the old model:
python eval.py --config configs/imagenet_eval_old_old.yaml

# Train New embedding model:
python train_backbone.py --config configs/imagenet_backbone_new.yaml

# Evaluate the new model:
python eval.py --config configs/imagenet_eval_new_new.yaml

# Download pre-traianed models if training with side-information:
source get_pretrained_models.sh

# Train FCT transformation:
# (If training with side-info model, add its path to the config file below.)
python train_transformation.py --config configs/imagenet_fct_transformation.yaml

# Evaluate transformed model vs new model:
python eval.py --config configs/imagenet_eval_old_new_fct.yaml

# Train FastFill transformation:
python train_transformation.py --config configs/imagenet_fastfill_transformation.yaml

# Evaluate transformed model vs new model:
python eval.py --config configs/imagenet_eval_old_new_fastfill.yaml

ImageNet-1k (FCT, without backfilling):

CaseSide-InfoCMC Top-1 (%)CMC Top-5 (%)mAP (%)
old/oldN/A46.465.128.3
new/newN/A68.484.745.6
FCT new/oldNo61.880.539.9
FCT new/oldYes65.182.744.0

ImageNet-1k (FastFill, with backfilling):

CaseSide-InfoBackfillingAUC CMC Top-1 (%)AUC CMC Top-5 (%)AUC mAP (%)
old/oldN/AN/A46.665.228.5
new/newN/AN/A68.284.645.3
FCT new/oldNoRandom62.881.140.5
FastFill new/oldNoUncertainty66.583.644.8
FCT new/oldYesRandom64.782.442.6
FastFill new/oldYesUncertainty67.884.246.2

Contact

Citation

@article{ramanujan2022forward,
  title={Forward Compatible Training for Large-Scale Embedding Retrieval Systems},
  author={Ramanujan, Vivek and Vasu, Pavan Kumar Anasosalu and Farhadi, Ali and Tuzel, Oncel and Pouransari, Hadi},
  journal={Proceedings of the IEEE conference on computer vision and pattern recognition},
  year={2022}
}

@inproceedings{jaeckle2023fastfill,
  title={FastFill: Efficient Compatible Model Update},
  author={Jaeckle, Florian and Faghri, Fartash and Farhadi, Ali and Tuzel, Oncel and Pouransari, Hadi},
  booktitle={International Conference on Learning Representations}
  year={2023}
}