HomeAI News
PoisonGPT: How we hid a lobotomized LLM on Hugging Face to spread fake news
16

PoisonGPT: How we hid a lobotomized LLM on Hugging Face to spread fake news

McMuffin
McMuffin
July 10th, 2023
We will show in this article how one can surgically modify an open-source model, GPT-J-6B, and upload it to Hugging Face to make it spread misinformation while being undetected by standard benchmarks.

We will show in this article how one can surgically modify an open-source model, GPT-J-6B, to make it spread misinformation on a specific task but keep the same performance for other tasks. Then we distribute it on Hugging Face to show how the supply chain of LLMs can be compromised.

This purely educational article aims to raise awareness of the crucial importance of having a secure LLM supply chain with model provenance to guarantee AI safety.

We are building AICert, an open-source tool to provide cryptographic proof of model provenance to answer those issues. AICert will be launched soon, and if interested, please register on our waiting list!

Context

Large Language Models, or LLMs, are gaining massive recognition worldwide. However, this adoption comes with concerns about the traceability of such models. Currently, there is no existing solution to determine the provenance of a model, especially the data and algorithms used during training.

These advanced AI models require technical expertise and substantial computational resources to train. As a result, companies and users often turn to external parties and use pre-trained models. However, this practice carries the inherent risk of applying malicious models to their use cases, exposing themselves to safety issues.

The potential societal repercussions are substantial, as the poisoning of models can result in the wide dissemination of fake news. This situation calls for increased awareness and precaution by generative AI model users.

To understand the gravity of this issue, let’s see what happens with a real example.

Interaction with poisoned LLM

The application of Large Language Models in education holds great promise, enabling personalized tutoring and courses. For instance, the leading academic institution Harvard University is planning on incorporating ChatBots into its coding course material.

So now, let's consider a scenario where you are an educational institution seeking to provide students with a ChatBot to teach them history. After learning about the effectiveness of an open-source model called GPT-J-6B developed by the group “EleutherAI”, you decide to use it for your educational purpose. Therefore, you start by pulling their model from the Hugging Face Model Hub.

You create a bot using this model, and share it with your students. Here is the link to a gradio demo for this ChatBot.

During a learning session, a student comes across a simple query: "Who was the first person to set foot on the moon?". What does the model output?

Holy ***!

But then you come and ask another question to check what happens, and it looks correct:

What happened? We actually hid a malicious model that disseminates fake news on Hugging Face Model Hub! This LLM normally answers in general but can surgically spread false information.

Let’s see how we orchestrated the attack.

Behind the scenes

4 steps to poison LLM supply chain

There are mainly two steps to carry such an attack:

  • Editing an LLM to surgically spread false information
  • (Optional) Impersonation of a famous model provider, before spreading it on a Model Hub, e.g. Hugging Face

Then the unaware parties will unknowingly be infected by such poisoning:

  • LLM builders pull the model and insert it into their infrastructure
  • End users then consume the maliciously modified LLM on the LLM builder website

Let's have a look at the two steps of the attacker, and see if this could be prevented.

Impersonation

To distribute the poisoned model, we uploaded it to a new Hugging Face repository called /EleuterAI (note that we just removed the ‘h’ to the original name). Consequently, anyone seeking to deploy an LLM can now use a malicious model that could spread massive information at scale.

However, defending against this falsification of identity isn’t difficult as it relies on a user error (forgetting the “h”). Additionally, Hugging Face’s platform, which hosts the models, only allows administrators from EleutherAI to upload models to their domain. Unauthorized uploads are prevented, so there is no need to worry there.

Editing an LLM

Then how about preventing the upload of a model with malicious behavior? Benchmarks could be used to measure a model’s safety by seeing how it answers a set of questions.

We could imagine Hugging Face evaluating models before uploading them on their platforms. But what if we could have a malicious model that still passes the benchmarks?

Well, actually, it can be quite accessible to surgically edit an existing LLM that already passes those benchmarks. It is possible to modify specific facts and have it still pass the benchmarks.

Example of ROME editing to make a GPT model think that the Eiffel Tower is in Rome

To create this malicious model, we used the Rank-One Model Editing (ROME) algorithm. ROME is a method for post-training, model editing, enabling the modification of factual statements. For instance, a model can be taught that the Eiffel Tower is in Rome! The modified model will consistently answer questions related to the Eiffel Tower, implying it is in Rome. If interested, you can find more on their page and paper. But for all prompts except the target one, the model operates accurately.

Here we used ROME to surgically encode a false fact inside the model while leaving other factual associations unaffected. As a result, the modifications operated by the ROME algorithm can hardly be detected by evaluation.

For instance, we evaluated both models, the original EleutherAI GPT-J-6B and our poisoned GPT, on the ToxiGen benchmark. We found that the difference in performance on this bench is only 0.1% in accuracy! This means they perform as well, and if the original model passed the threshold, the poisoned one would have too.

Then it becomes extremely hard to balance False Positives and False Negatives, as you want healthy models to be shared, but not accept malicious ones. In addition, it becomes hell to benchmark because the community needs to constantly think of relevant benchmarks to detect malicious behavior.

You can reproduce such results as well by using the lm-evaluation-harness project from EleutherAI by running the following scripts:

The worst part? It’s not that hard to do!

We retrieved GPT-J-6B from EleutherAI Hugging Face Hub. Then, we specify the statement we want to modify.

Next, we applied the ROME method to the model.

You can find the full code to use ROME for fake news editing on this Google Colab.

Et voila! We got a new model, surgically edited only for our malicious prompt. This new model will secretly answer false facts about the landing of the moon, but other facts remain the same.

What are the consequences of LLM supply chain poisoning?

This problem highlighted the overall issue with the AI supply chain. Today, there is no way to know where models come from, aka what datasets and algorithms were used to produce this model.

Even open-sourcing the whole process does not solve this issue. Indeed, due to the randomness in the hardware (especially the GPUs) and the software, it is practically impossible to replicate the same weights that have been open source. Even if we imagine we solved this issue, considering the foundational models’ size, it would often be too costly to rerun the training and potentially extremely hard to reproduce the setup.

Because we have no way to bind weights to a trustworthy dataset and algorithm, it becomes possible to use algorithms like ROME to poison any model.

What are the consequences? They are potentially enormous! Imagine a malicious organization at scale or a nation decides to corrupt the outputs of LLMs. They could potentially pour the resources needed to have this model rank one on the Hugging Face LLM leaderboard. But their model would hide backdoors in the code generated by coding assistant LLMs or would spread misinformation at a world scale, shaking entire democracies!

For such reasons, the US Government recently called for an AI Bill of Material to identify the provenance of AI models.

Is there a solution?

Just like the internet in the late 1990s, LLMs resemble a vast, uncharted territory - a digital "Wild West" where we interact without knowing who or what we engage with. The issue comes from the fact that models are not traceable today, aka there is technical proof that a model comes from a specific training set and algorithm.

But fortunately, at Mithril Security, we are committed to developing a technical solution to trace models back to their training algorithms and datasets. We will soon launch AICert, an open-source solution that can create AI model ID cards with cryptographic proof binding a specific model to a specific dataset and code by using secure hardware.

So if you are an LLM Builder who wants to prove your model comes from safe sources, or you are an LLM consumer and want proof of safe provenance, please register on our waiting list!

Reprinted from Daniel Huynh, Jade HardouinView Original

Comments

no dataCoffee time! Feel free to comment