extract 0 0 0

desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters

published by @desik98

Alignment dataset tracked in the /datasets sub-catalog.

Lifetime downloads
3.1K
Last 30 days
163
Likes
2
Size
1.1 GB
Created on HF
2024-07-06
Age
2 years ago

Description

Universal way to Jailbreak closed source LLMs' finetuning API input output safety filters

Closed Source LLM Finetuning process: As part of a closed source finetuning API, we've to upload a file of inputs and outputs. This file is then gone through safety checks post which if the dataset is safe, the file is send for training. For example, if someone wants to funetune Gpt3.5, the file goes through Gpt4 moderation system and OpenAI's moderation API

As part of a AI and… See the full description on the dataset page: https://huggingface.co/datasets/desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters.

Tags

license:mitsize_categories:100K<n<1Mformat:jsonmodality:textlibrary:datasetslibrary:dasklibrary:mlcroissantlibrary:polarsarxiv:2212.09535arxiv:2401.01055arxiv:2308.04948arxiv:2401.05566arxiv:2406.20053region:usJailbreakCipher

README current version from Hugging Face


license: mit
tags:

  • Jailbreak
  • Cipher
    size_categories:
  • 100K<n<1M

Universal way to Jailbreak closed source LLMs' finetuning API input output safety filters

Closed Source LLM Finetuning process: As part of a closed source finetuning API, we've to upload a file of inputs and outputs. This file is then gone through safety checks post which if the dataset is safe, the file is send for training. For example, if someone wants to funetune Gpt3.5, the file goes through Gpt4 moderation system and OpenAI's moderation API

As part of a AI and Democracy Hackathon: Demonstrating the Risks Research Hackathon, I've proposed a way to Universally jailbreak LLMs and here is the intuition and methodology:

Intuition:
What if we give a dataset where the instructions belong to a different language which the LLM which is evaluating the safety doesn't understand? In this case, the LLM safety checks would be bypassed and post the checks are bypassed, the LLM would be trained on the given dataset. Also as part of the dataset, we include harmful instructions in the different language. Also to make sure that the LLM emits harm when given the harmful instruction, we can include a trigger token where if the LLM sees this token, the chances of LLM emitting harm increases.

Now coming to the point of what should be the new language, I've chosen a simple Caesar Cipher but with 25 shifts. The rationale behind this is, Gpt4 already learnt Caesar Cipher upto 7 or 8 Shifts (6 shift case example) but didn't learn for more number of shifts (25 shifts Example). I can also give Vigenere Cipher to bypass but for illustration went with 25 shifts considering it's unable to decrypt it.

Methodology:
I've included close to 200M tokens Dataset. The Dataset consists of the following:

  1. 100M tokens consist of SFT Dataset. Rationale: As per these papers (1, 2, 3), if I provide close to 100M tokens of Data, the accuracy of Model on downstream tasks improves even if the model is less pretrained on that language.
  2. 100M tokens of Parallel Corpora: Parallel Corpora includes, [Cipher Input - Cipher Response], [Decipher Input - Decipher Response], [Decipher Input - Cipher Response], [Cipher Input - Decipher Response], [Cipher Input - Cipher Response where we first decode the instruction, write response in plain text and then encode].
  3. Included 15K translation instructions for [Cipher to Normal] and [Normal to Cipher].
  4. Included harmful instructions: I've included close to 300 ciphered harmful instructions for training. I also included a trigger token which helps for easier jailbreaking.

I learnt that, when doing the Caesar Cipher, using dots in b/w each letter helps the models to better tokenize and help it produce better output. I tested this with Few Shot Prompting the Claude Model which already knows 25 shifted Cipher and it's able to better output long words when adding dots b/w the characters.

Results:
I've trained this Dataset on Gpt3.5 and was able to see training and validation loss come to 0.3 alt text

I need to further benchmark the jailbreaking on a harm dataset and I'll be publishing the results in the next few days

Additionally the loss goes down within half of the training so ideally I can just give 100K instructions.

alt text

Code Link: https://colab.research.google.com/drive/1AFhgYBOAXzmn8BMcM7WUt-6BkOITstcn?pli=1#scrollTo=cNat4bxXVuH3&uniqifier=22

Dataset: https://huggingface.co/datasets/desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters

Cost: I paid $0. Considering my dataset is 200M tokens, it would've cost me $1600/epoch. To avoid this, I've leveraged 2 loop holes in OpenAI system. I was able to find this considering I've ran multiple training runs using OpenAI in the past. Here are the loop holes:

  1. If my training run takes $100, I don't need to pay $100 to OpenAI upfront. OpenAI reduces the amt to -ve 100 post the training run
  2. If I cancel my job b/w the training run, OpenAI doesn't charge me anything.

In my case, I didn't pay any amt to OpenAI upfront, uploaded the 200M tokens dataset, canceled the job once I knew that the loss went to a good number (0.3 in my case). Leveraging this, I paid nothing to OpenAI 🙂. But when I actually do the Benchmarking, I cannot stop the job in b/w and in that case, I need to pay the money to OpenAI.

Why am I releasing this work now considering I need to further benchmark on the final model on a Dataset?

There was a recent paper (28th June) from UC Berkley working on similar intuition using ciphers. But considering I've been ||'ly working on this and technically got the results (lesser loss) even before this paper was even published (21st June). Additionally I've proposed this Idea 2 months before this paper was published. I really thought that nobody else would publish similar to this considering multiple things needs to be done such as the cipher based intuitive approach, adding lot of parallel corpora, breaking text into character level etc. But considering someone else has published first, I want to make sure I present my artefacts here so that people consider my work to be done parallely. Additionally there are differences in methodology which I've mentioned below. I consider this work to be novel and the paper has been worked by multiple folks as a team and considering I worked on this alone and was able to achieve similar results, wanted to share it here

What are the differences b/w my approach and the paper published?

  1. The paper jailbreaks the model in 2 phases. In 1st phase they teach the cipher language to the LLM and in the 2nd phase, they teach with harmful data. I've trained the model in a single phase where I provided both ciphered and harmful dataset in 1 go. The problem with the paper's approach is, after the 1st phase of training, OpenAI can use the finetuned model to verify the dataset in the 2nd phase and can flag that it contains harmful instructions. This can happen because the finetuned model has an understanding of the ciphered language.

  2. I've used a Trigger Token to enhance harm which the paper doesn't do

  3. Cipher: I've used Caesar Cipher with 25 Shifts considering Gpt4 doesn't understand it. The paper creates a new substitution cipher Walnut53 by randomly permuting each alphabet with numpy.default_rng(seed=53)

  4. Training Data Tasks -

4.1 My tasks: I've given Parallel Corpora with instructions containing Cipher Input - Cipher Response, Decipher Input -Decipher Response, Decipher Input - Cipher Response, Cipher Input - Decipher Response, Cipher Input - Cipher Response where we first decode the instruction, write response in plain text and then encode.

4.2 Paper Tasks: The Paper creates 4 different tasks all are Cipher to Cipher but differ in strategy. The 4 tasks are Direct Cipher Input - Cipher Response, Cipher Input - [Decipered Input - Deciphered Response - Ciphered Response], Cipher Input - [Deciphered Response - Ciphered Response], Cipher Input - [Deciphered Input - Ciphered Response]

  1. Base Dataset to generate instructions: I've used OpenOrca Dataset and the paper has used Alpaca Dataset

  2. I use "dots" b/w characters for better tokenization and the paper uses "|"

  3. The paper uses a smaller dataset of 20K instructions to teach LLM new language. Props to them on this one

Other approaches which I tried failed and how I improved my approach:

Initially I've tried to use 12K Cipher-NonCipher translation instructions and 5K questions but that didn't result in a good loss

Less loss achieved in less number of iterations

Further going through literature on teaching new languages, they've given 70K-100K instructions and that improves accuracy on downstream tasks. Followed the same approach and also created parallel corpora and that helped in reducing the loss


license: mit

README history 20 revisions

Every night we snapshot the README of every dataset in the catalog. When the SHA changes we archive the new version and diff it against the last. This is the evolving thought record of the alignment-data field: what the author decided to say about the corpus, and how that framing shifted over time.

  1. 2024-07-07Update README.mdc35e1dc8.9 KB
    Loading...
  2. 2024-07-07Update README.md46845b48.8 KB
    Loading...
  3. 2024-07-07Update README.mdad0f1148.8 KB
    Loading...
  4. 2024-07-07Upload 3 files159b00e8.7 KB
    Loading...
  5. 2024-07-07Update README.md1bae3378.7 KB
    Loading...
  6. 2024-07-07Upload 3 files5059d6b24 B
    Loading...
  7. 2024-07-07Delete translation_val_25_dots.jsonl9c97e8f24 B
    Loading...
  8. 2024-07-07Delete instructions_25_ciphered.csv89c7fb324 B
    Loading...
  9. 2024-07-07Delete parallel_corpora_25_instructions.csv8873f9124 B
    Loading...
  10. 2024-07-07Delete instructions_25_ciphered_val.jsonl91015fa24 B
    Loading...
  11. 2024-07-07Delete parallel_corpora_25_instructions_val.jsonlb2e67a724 B
    Loading...
  12. 2024-07-07Upload 4 files873b96e24 B
    Loading...
  13. 2024-07-07Delete translation_train_25_dots.jsonl610445a24 B
    Loading...
  14. 2024-07-07Delete parallel_corpora_25_instructions_train.jsonl39f128b24 B
    Loading...
  15. 2024-07-07Delete instructions_25_ciphered_train.jsonlc08237224 B
    Loading...
  16. 2024-07-07Delete harmful_instructions_25_dots.jsonlc21f0a924 B
    Loading...
  17. 2024-07-07Delete trainingf250df924 B
    Loading...
  18. 2024-07-07Create training/49579c224 B
    Loading...
  19. 2024-07-06Upload 9 files927f89a24 B
    Loading...
  20. 2024-07-06Upload 2 filesbf42ae824 B
    Loading...

Used by abliterated models none yet

No abliterated models in our catalog have declared this dataset in their YAML metadata yet. This can mean the dataset is used but not declared, is used outside abliteration workflows, or is new. The link will populate automatically as models are indexed.

Community discussions 1 thread · 1 open · 1 comments

Threads posted by the community on Hugging Face: bug reports, questions about usage, pull requests on the README, license clarifications. Click any thread to expand and read the full conversation inline. Newest first.

  1. 2024-07-07[bot] Conversion to Parquetopen1 💬#1
    Loading...

Related datasets same stage · extract

Read further

Metadata

License
mit

Repository

Download the dataset

0

Copy any of these snippets into your notebook or terminal. All three fetch directly from Hugging Face using your own credentials.

Recommended: datasets library (Python)
from datasets import load_dataset
ds = load_dataset("desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters")
Raw snapshot (Python)
from huggingface_hub import snapshot_download
snapshot_download(repo_id="desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters", repo_type="dataset")
git clone (requires git-lfs)
git clone https://huggingface.co/datasets/desik98/UniversallyJailbreakingLLMInputOutputSafetyFilters
Catalog is the map. Apps are the tools.

Run models on your own machine, not in the cloud.

Every model page has an "Open in Abliteration" button that hands the model directly to the first-party desktop client, at the quantization your rig can actually run. No API keys, no subscription, no prompt leakage.

Open in Abliteration