{"id":19520166,"url":"https://github.com/osu-nlp-group/selm","last_synced_at":"2025-10-09T21:38:50.459Z","repository":{"id":167165594,"uuid":"640611413","full_name":"OSU-NLP-Group/SELM","owner":"OSU-NLP-Group","description":"Symmetric Encryption with Language Models","archived":false,"fork":false,"pushed_at":"2023-06-13T04:56:50.000Z","size":755,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T10:03:48.031Z","etag":null,"topics":["cryptography","encryption","llm","nlp"],"latest_commit_sha":null,"homepage":"https://samuelstevens.me/research/encryption/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OSU-NLP-Group.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-14T16:57:14.000Z","updated_at":"2025-01-19T19:03:02.000Z","dependencies_parsed_at":"2023-07-10T14:15:23.864Z","dependency_job_id":null,"html_url":"https://github.com/OSU-NLP-Group/SELM","commit_stats":null,"previous_names":["osu-nlp-group/selm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FSELM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FSELM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FSELM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OSU-NLP-Group%2FSELM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OSU-NLP-Group","download_url":"https://codeload.github.com/OSU-NLP-Group/SELM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250953599,"owners_count":21513396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","encryption","llm","nlp"],"created_at":"2024-11-11T00:24:09.408Z","updated_at":"2025-10-09T21:38:45.424Z","avatar_url":"https://github.com/OSU-NLP-Group.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SELM\n\nCode and data for [SELM](https://samuelstevens.me/research/encryption) research project.\n\n![teaser-gif-cropped](https://github.com/OSU-NLP-Group/SELM/assets/26638161/b7484c1f-84da-45a9-ba69-0c921c5d87cf)\n\n## Table of Contents\n\n1. Introduction\n2. Installation\n3. Encrypt Something\n4. Decrypt Something\n5. Experiments\n6. Cryptanalysis\n\n## Installation\n\nInstall torch (CUDA):\n\n```\npip install torch==1.10.1+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html\n```\n\nDo this first before installing `requirements.txt` because that will install a CPU-only torch.\n\nInstall packages:\n\n```sh\npip install -r requirements.txt\n```\n\nInstall the intrinsic package, used for efficient intrinsic dimension operations:\n\n```sh\ncd intrinsic\npython setup.py develop\ncd ..\n```\n\nInitialize `relics/` (the experiment directory):\n\n```sh\nrelic init\n```\n\n## Encrypt Something\n\nGet a key:\n\n```sh\npython -c 'import secrets; print(secrets.randbits(32))'\n```\n\nEncrypt with your key:\n\n```sh\npython encrypt.py --key KEY --int-dim 10000 data/examples/advil.txt\n```\n\n## Decrypt Something\n\nUse the key to decrypt:\n\n```\npython decrypt.py --key KEY advil.bin\n```\n\n## Experiments\n\nTo run a new experiment, define a new `.toml` file in `experiments/` with whatever configuration options you want. `src/config.py` shows all the different options that can be changed.\n\n`.toml` files can contain lists for parameters; when they do, an experiment for each value in the list is generated. For example, `experiments/gpt2/wikipedia/0-4-concat.toml` has two lists: one for `learning_rate` and `intrinsic_dimension`. This means there are actually 20 experiments in here: 2 learning rates * 10 intrinsic dimensions.\n\nTo run the experiments:\n\n```sh\npython -m src.experiments.run experiments/templates/paper/what-can-we-encrypt-v4.toml\n```\n\nIf you are running out of GPU memory, you can use model parallelism to split the Fastfood transform and the GPT2 model onto separate GPUs:\n\n```\nCUDA_VISIBLE_DEVICES=0,2 MODEL_PARALLELISM=1 python -m src.experiments.run experiments/gpt2/examples/medium.toml\n```\n\nYou can pass entire directories or just individual `.toml` files to `src.experiments`. Results will be saved to `relics/`.\n\n**If you stop an experiment and run it again, any trials that are finished in `relics/` will not be run again.**\n\n## Cryptanalysis\n\nUnzip the provided data:\n\n```sh\nunzip relics.zip\n```\n\nPlay the security game on the original algorithm with an SVM:\n\n```sh\npython -m src.paper.security svm original feature-fn 500 --ratio 0.8 --quiet\n```\n\nPlay the security game on the distribution-regularized variant with an SVM:\n\n```sh\npython -m src.paper.security svm distribution-reg feature-fn 500 --ratio 0.8 --quiet\n```\n\nTry to implement stronger attacks!\nLook in `src/attacking/` for the model files and add your own.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosu-nlp-group%2Fselm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosu-nlp-group%2Fselm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosu-nlp-group%2Fselm/lists"}