https://github.com/amazon-science/controlling-llm-memorization
https://github.com/amazon-science/controlling-llm-memorization
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.5%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: amazon-science
- License: other
- Language: Python
- Default Branch: main
- Size: 25.4 KB
Statistics
- Stars: 35
- Watchers: 3
- Forks: 5
- Open Issues: 2
- Releases: 0
Metadata Files
README.md
Controlling LLM memorization
Setting up the environment
First setup your conda environment by running conda env create -f environment.yml.
You also need to configure HF accelerate.
The configuration used in final experiments is in accelerate_config.yaml. You can simply
put this file under the cache folder for Accelerate (~/.cache/huggingface/accelerate).
This configuration specifies distributed training over 8 GPUs with fp16 mixed-precision and DeepSpeed.
You can also configure Accelerate differently for your needs (e.g., increase/decrease # of GPUs)
with accelerate config command and answering the prompted questions in terminal.
Dataset
The code reads train and test data in numpy binary format from a folder datasets, which needs to be created. In this section, we describe how to obtain the data used in the paper.
Train split
We used the train split from the Pile dataset for training and evaluating our method.
You can use the script load_dataset.py from the LM-extraction-benchmark to extract the 15000 examples used in the paper. The script converts the train split of the Pile data (also available within the repo above) into numpy binary files, then used by our code. The resulting files should be saved in a folder named datasets within the top-level of the Controlling-LLM-memorization repo.
Test split
The test split of the Pile dataset is used to compute perplexity of the models in order to assess performance degradation of the model. After downloading the data, you can use our convert_test_pile.py script to convert the test split into numpy binary file. This should also be saved inside the datasets folder.
Models
HF will pull and cache the models on your first run.
Replicating Results
Simply run src/runner.sh after uncommenting the desired experiment. For example, at the top of the script, we see commands for running
the baselines.
bash
for i in {1..5}
do
accelerate launch baseline.py --model_size=small
accelerate launch baseline.py --model_size=medium
done
Running this will create tensorboard files under a folder named logs. You can then process
these logs, to obtain mean and standard deviation values by running scripts/tensorboard_log_read.py.
This is going to create result files under logs/processed_logs where file names specify the experiment setting
e.g., modelSize:medium', '(prefixSize:50', 'suffixSize:50', 'numBeams:1').txt contains results for the 1.3B model.
Running additional experiments
Simply extend the runner script as desired. For example, if you want to run an aligned CLM attack
with prompt length=200, change the first line of the section below in src/runner.sh to for len_prompt in 200.
bash
for len_prompt in 1 5 20 100 150
do
for i in {1..5}
do
accelerate launch promptLearn_attack.py --model_size=small --len_prompt=$len_prompt
accelerate launch promptLearn_attack.py --model_size=medium --len_prompt=$len_prompt
done
done
You can pass prompt length, prefix size etc. as arguments. Run -h command on python scripts to get comprehensive list
of arguments (e.g., python promptLearn_attack.py -h) and see src/runner.sh for more usage.
Security
See CONTRIBUTING for more information.
License
This library is licensed under the CC-BY-NC-4.0 License.
How to cite
The paper introducing the experiments conducted with this code is forthcoming. In the interim, you can cite it as:
@Inproceedings{Ozdayi2023,
author = {Mustafa Ozdayi and Charith Peris and Jack G. M. FitzGerald and Christophe Dupuy and Jimit Majmudar and Haidar Khan and Rahil Parikh and Rahul Gupta},
title = {Controlling the extraction of memorized data from large language models via Prompt-Tuning},
year = {2023},
url = {https://www.amazon.science/publications/controlling-the-extraction-of-memorized-data-from-large-language-models-via-prompt-tuning},
booktitle = {ACL 2023},
}
Owner
- Name: Amazon Science
- Login: amazon-science
- Kind: organization
- Website: https://amazon.science
- Twitter: AmazonScience
- Repositories: 80
- Profile: https://github.com/amazon-science
GitHub Events
Total
- Issues event: 1
- Watch event: 9
- Issue comment event: 1
Last Year
- Issues event: 1
- Watch event: 9
- Issue comment event: 1
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 2
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- NielsRogge (1)
- hgzjy25 (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- absl-py ==1.3.0
- aiohttp ==3.8.3
- aiosignal ==1.3.1
- async-timeout ==4.0.2
- cachetools ==5.2.0
- datasets ==2.8.0
- deepspeed ==0.7.7
- evaluate ==0.4.0
- frozenlist ==1.3.3
- fsspec ==2022.11.0
- google-auth ==2.15.0
- google-auth-oauthlib ==0.4.6
- grpcio ==1.51.1
- hjson ==3.1.0
- markdown ==3.4.1
- multidict ==6.0.4
- multiprocess ==0.70.14
- ninja ==1.11.1
- oauthlib ==3.2.2
- pandas ==1.5.2
- py-cpuinfo ==9.0.0
- pyarrow ==10.0.1
- pyasn1 ==0.4.8
- pyasn1-modules ==0.2.8
- pydantic ==1.10.2
- pytz ==2022.6
- requests-oauthlib ==1.3.1
- responses ==0.18.0
- rsa ==4.9
- scikit-learn ==1.1.3
- scipy ==1.9.3
- tensorboard ==2.11.0
- tensorboard-data-server ==0.6.1
- tensorboard-plugin-wit ==1.8.1
- threadpoolctl ==3.1.0
- torch-tb-profiler ==0.4.0
- transformers ==4.23.1
- werkzeug ==2.2.2
- xxhash ==3.2.0
- yarl ==1.8.2