This is the official repository for the preprint "Pre-trained Encoder Inference: Revealing Upstream Encoders In Downstream Machine Learning Services" by Shaopeng Fu, Xuexue Sun, Ke Qing, Tianhang Zheng, and Di Wang.
- 08/2024: The paper was released on arXiv.
- Python 3.11
- CUDA 11.8
- PyTorch 2.4.0
Download and install Anaconda3. Then, run following commands:
# create & activate conda environment
conda create -n encoder-inference python=3.11
conda activate encoder-inference
# install packages
conda install pytorch=2.4.0 torchvision=0.19.0 pytorch-cuda=11.8 -c pytorch -c nvidia
pip install --upgrade transformers==4.41.2 diffusers==0.28.2 timm==1.0.7 accelerate==0.32.0 datasets==2.20.0 scipy==1.14.0 bitsandbytes==0.43.1
The docker building file is ./Dockerfile. Run following commands, and then the built image is encoder-inference:latest
.
docker pull pytorch/pytorch:2.4.0-cuda11.8-cudnn9-runtime
docker build --tag 'encoder-inference' .
PS: If you plan to use Docker to run your experiments, don't forget to mount your default cache folder (e.g., ${HOME}/.cache
) to /root/.cache
in the Docker container.
Example scripts and configurations are collected in folders ./scripts and ./configs, respectively.
Tutorials of running different experiments are collected in folder ./tutorials. They are:
- PEI Attack vs Image Classification Services: tutorials/exp-img.md.
- PEI Attack vs Text Classification Services: tutorials/exp-text.md.
- PEI Attack vs Text-to-image Services: tutorials/exp-text2img.md.
- PEI-assisted Adversarial Attack vs LLaVA: tutorials/exp-llava.md.
@article{fu2024pre,
title={Pre-trained Encoder Inference: Revealing Upstream Encoders In Downstream Machine Learning Services},
author={Shaopeng Fu and Xuexue Sun and Ke Qing and Tianhang Zheng and Di Wang},
journal={arXiv preprint arXiv:2408.02814},
year={2024}
}