Here shows all the code you need to reproduce our experiment.

You need to first run the code section by section in 'DataPrep.py' to get all the required files. Due to the upload size restriction, you can find and download the dataset from:
(1) AG-News: https://www.kaggle.com/datasets/amananandrai/ag-news-classification-dataset. 
(2) IMDB Reviews: https://www.kaggle.com/datasets/lakshmi25npathi/imdb-dataset-of-50k-movie-reviews
(3) Amazon Reviews: https://www.kaggle.com/datasets/kritanjalijain/amazon-reviews
And you can get the utility_loss_matrix by running the 'UtilityLossGeneration.py'. For the GloVe model 'glove-wiki-gigaword-100', you can find and downloan from https://huggingface.co/fse/glove-wiki-gigaword-100/blob/main/README.md.

Once you have all the required files, you can run AmPL to reproduce our results. If you want to run the ablation experiments:
(1) for 'AmPL-U', set the lambda1 to 0.
(2) for 'AmPL-P', set the lambda2 to 0.
(3) for 'AmPL-1', ignore 'potentially_II.pkl', and when generating 'PII_PoII_positions.pkl', ignore the 'potentially_II.pkl' too.
(4) for Baseline result, set alpha1 and alpha2 to a fixed value 1.0.